PassiveAggressive extends AbstractVectorClassifier implements OnlineLearner, Writable { public PassiveAggressive(int numCategories, int numFeatures) { this.numCategories = numCategories; weights = new DenseMatrix(numCategories, numFeatures); weights.assign(0.0); } PassiveAggressive(int numCategories, int numFeatures); PassiveAggressive learningRate(double learningRate); void copyFrom(PassiveAggressive other); @Override int numCategories(); @Override Vector classify(Vector instance); @Override Vector classifyNoLink(Vector instance); @Override double classifyScalar(Vector instance); int numFeatures(); PassiveAggressive copy(); @Override void write(DataOutput out); @Override void readFields(DataInput in); @Override void close(); @Override void train(long trackingKey, String groupKey, int actual, Vector instance); @Override void train(long trackingKey, int actual, Vector instance); @Override void train(int actual, Vector instance); static final int WRITABLE_VERSION; }
@Test public void testPassiveAggressive() throws IOException { Vector target = readStandardData(); PassiveAggressive pa = new PassiveAggressive(2,8).learningRate(0.1); train(getInput(), target, pa); test(getInput(), target, pa, 0.11, 0.31); }