Example usage for org.apache.mahout.classifier.sgd PassiveAggressive PassiveAggressive

List of usage examples for org.apache.mahout.classifier.sgd PassiveAggressive PassiveAggressive

Introduction

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

Prototype

public PassiveAggressive(int numCategories, int numFeatures) 

Source Link

Usage

From source file:opennlp.addons.mahout.PassiveAggressiveTrainer.java

License:Apache License

@Override
public MaxentModel doTrain(DataIndexer indexer) throws IOException {

    // TODO: Lets use the predMap here as well for encoding
    int numberOfOutcomes = indexer.getOutcomeLabels().length;
    int numberOfFeatures = indexer.getPredLabels().length;

    PassiveAggressive pa = new PassiveAggressive(numberOfOutcomes, numberOfFeatures);

    for (int k = 0; k < iterations; k++) {
        trainOnlineLearner(indexer, pa);

        // What should be reported at the end of every iteration ?!
        System.out.println("Iteration " + (k + 1));
    }//from ww w . j a v a2s.c  o  m

    pa.close();

    return new VectorClassifierModel(pa, indexer.getOutcomeLabels(), createPrepMap(indexer));
}