ML in JAVA with WEKA (on Android)

WEKA can easily be used to perform some simple Machine Learning in JAVA. While developing a small project for classifying some data derived from a wearable for activity recognition, I missed a short summary what is needed to classify with WEKA in a JAVA project. So this post serves as a memo to myself (or anyone who finds it usefull).

A standard WEKA installation contains all the needed java files. Normally in your WEKA installation folder there resides a weka-src.jar file. Extract it with an archive manager which is able to handle the ZIP format. Create a lib directory (if not present) and run ANT.

Now it’s pretty straight forward to create some code that builds a model from some data (in this case stored in a CSV file) .
I’ve setup a short GIST containing everything needed to build the model, Evaluate a model and classify some live captured data (aka classify a single datum).

This is just a starting point to get setup. It is possible to implement much more sophisticated ML Pipelines with WEKA 😉 The Documentation under http://weka.sourceforge.net/doc.stable-3-8/ might help you.

If you want to use that on Android you can do that. The Problem is that WEKA makes use of the JAVA Swing libs to realise the GUI. This can be solved by just stripping these parts out, or just use the this repo where someone did it for us: https://github.com/rjmarsan/Weka-for-Android.

CORS and NodeJS with Express

If you’re building an RESTfull API with NodeJS (and Express), you’ll probably need CORS.
Otherwise nobody will be able to user your public API via Browsers.
So this is important vor Third-Party JQuery, Angular, whatever… Clients.

With this small Piece of Code you could make your API public and answer the CORS (Preflight) Requests.

This small function can be used via:
var express = require('express');
var app = express();
app.use(allowCrossDomain);

Duff’s Device

Duff’s Device:

Discovered some awesome piece of ANSI C Code using switch/case statements!

send(to, from, count)
register short *to, *from;
register count;
{
        register n = (count + 7) / 8;
        switch(count % 8) {
        case 0: do {    *to = *from++;
        case 7:         *to = *from++;
        case 6:         *to = *from++;
        case 5:         *to = *from++;
        case 4:         *to = *from++;
        case 3:         *to = *from++;
        case 2:         *to = *from++;
        case 1:         *to = *from++;
                } while(--n > 0);
        }
}

How is it working? Here’s the answer!

 

Managing Multiple WordPress Sites

OLYMPUS DIGITAL CAMERA

If you have to manage different WordPress Sites at once, then you know how much time it could take to update around 20 blogs. WordPress supports since version 3.0 Site Networks. This WordPress feature is great, but has some limitations. So for example you have to run your Site Network on one Server. So I had to get something which allows me to manage blogs over different Webhoster. There are some Tools which can reduce the time to a get updates and that stuff to a minimum. Weiterlesen…