Example usage for org.apache.mahout.classifier.sgd OnlineLogisticRegression classify

List of usage examples for org.apache.mahout.classifier.sgd OnlineLogisticRegression classify

Introduction

In this page you can find the example usage for org.apache.mahout.classifier.sgd OnlineLogisticRegression classify.

Prototype

@Override
public Vector classify(Vector instance) 

Source Link

Document

Returns n-1 probabilities, one for each category but the 0-th.

Usage

From source file:de.isabeldrostfromm.sof.Trainer.java

License:Open Source License

@Override
public List<String> apply(OnlineLogisticRegression model, ExampleProvider provider) {
    List<String> result = new ArrayList<String>();
    for (Example instance : provider) {
        Vector labeled = model.classify(instance.getVector());
        double max = -1;
        int maxIndex = -1;
        for (Vector.Element element : labeled) {
            if (element.get() > max) {
                max = element.get();/*from   w  w  w.  j ava  2  s . c o  m*/
                maxIndex = element.index();
            }
        }
        result.add(ModelTargets.INDECES.get(maxIndex));
    }
    return result;
}