/** * Predicts the class memberships for a given instance. If an instance is unclassified, the * returned array elements must be all zero. * * @param inst the instance to be classified * @return an array containing the estimated membership probabilities of the test instance in each * class */ @Override public double[] getVotesForInstance(Instance inst) { double[] ret; inst.setDataset(dataset); if (this.isInit == false) { ret = new double[dataset.numClasses()]; } else { ret = learner.getVotesForInstance(inst); } return ret; }
/** * Trains this classifier incrementally using the given instance. * * @param inst the instance to be used for training */ @Override public void trainOnInstance(Instance inst) { if (this.isInit == false) { this.isInit = true; InstancesHeader instances = new InstancesHeader(dataset); this.learner.setModelContext(instances); this.learner.prepareForUse(); } if (inst.weight() > 0) { inst.setDataset(dataset); learner.trainOnInstance(inst); } }
/** * Instantiates a new learner. * * @param learner the learner * @param dataset the dataset */ public SimpleClassifierAdapter( com.yahoo.labs.samoa.moa.classifiers.Classifier learner, Instances dataset) { this.learner = learner.copy(); this.isInit = false; this.dataset = dataset; }
/** Resets this classifier. It must be similar to starting a new classifier from scratch. */ @Override public void resetLearning() { learner.resetLearning(); }