node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

jubatus

jubatus-node-client

Build Status npm version Codacy Badge Codacy Badge

Jubatus client for Node.js (unofficial)

Usage

See also http://jubat.us/en/api/index.html

Classifier

const jubatus = require("jubatus");
 
const classifier = new jubatus.classifier.client.Classifier(9199, "localhost");

Train

const datum = new jubatus.common.types.Datum().addString("foo", "bar").addNumber("quux", 0.1);
const labeledDatum = new jubatus.classifier.types.LabeledDatum("baz", datum);
const data = [labeledDatum];
 
classifier.train(data).then(([ result ]) => {
    console.error(result);
}).catch(error => {
    console.error(error);
});

Classify

var stringValues = [ [ "foo", "qux" ] ],
    numValues = [ [ "quux", 1 ] ],
    datum = new jubatus.common.types.Datum(stringValues, numValues),
    data = [ datum ];
 
classifier.classify(data).then(([ result ]) => {
    result.forEach(estimateResults => {
        var mostLikely = estimateResults
                .reduce((previous, current) => previous.score > current.score ? previous : current);
        console.log("estimate = %j", mostLikely);
    });
}).catch(error => {
    console.error(error);
});

Tutorial

see https://github.com/naokikimura/jubatus-tutorial-node