/** * 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) { ret = new double[dataset.numClasses()]; } else { ret = learner.getVotesForInstance(inst); } return ret; }
/** * 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; }
/** * 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; }
/** * 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; }
@Override public double[] getVotesForInstance(Instance inst) { if (this.treeRoot != null) { FoundNode foundNode = this.treeRoot.filterInstanceToLeaf(inst, null, -1); Node leafNode = foundNode.node; if (leafNode == null) { leafNode = foundNode.parent; } return leafNode.getClassVotes(inst, this); } else { int numClasses = inst.dataset().numClasses(); return new double[numClasses]; } }
@Override public void addResult(Example<Instance> example, double[] prediction) { Instance inst = example.getData(); double weight = inst.weight(); if (weight > 0.0) { if (TotalweightObserved == 0) { reset(inst.dataset().numClasses()); } this.TotalweightObserved += weight; this.weightObserved.add(weight); if (prediction.length > 0) { this.squareError.add((inst.classValue() - prediction[0]) * (inst.classValue() - prediction[0])); this.averageError.add(Math.abs(inst.classValue() - prediction[0])); } //System.out.println(inst.classValue()+", "+prediction[0]); } }
@Override public void addResult(Example<Instance> testInst, Prediction prediction) { MultiLabelInstance inst=(MultiLabelInstance) testInst.getData(); double weight = inst.weight(); if (numberOutputs == 0) { numberOutputs = inst.numberOutputTargets(); } if (weight > 0.0) { if (TotalweightObserved == 0) { reset(inst.dataset().numClasses()); } this.TotalweightObserved += weight; this.weightObserved.add(weight); if (prediction!=null) { for (int i = 0; i< numberOutputs;i++){ double error=(inst.valueOutputAttribute(i) - prediction.getVote(i, 0)); this.squareError.add( error*error); this.averageError.add(Math.abs(error)); } } //System.out.println(inst.classValue()+", "+prediction[0]); } } }
private double[] getVotesForInstance(Instance inst, boolean isTraining){ double[] ret = null; FoundNode foundNode = null; if(this.treeRoot != null){ foundNode = this.treeRoot.filterInstanceToLeaf(inst, null, -1); Node leafNode = foundNode.getNode(); if(leafNode == null){ leafNode = foundNode.getParent(); } ret = leafNode.getClassVotes(inst, this); } else { int numClasses = this.dataset.numClasses(); ret = new double[numClasses]; } //Training after testing to speed up the process if (isTraining == true){ if(this.treeRoot == null){ this.treeRoot = newLearningNode(this.parallelismHint); this.activeLeafNodeCount = 1; foundNode = this.treeRoot.filterInstanceToLeaf(inst, null, -1); } trainOnInstanceImpl(foundNode, inst); } return ret; }
private double[] getVotesForInstance(Instance inst, boolean isTraining){ double[] ret; FoundNode foundNode = null; if(this.treeRoot != null){ foundNode = this.treeRoot.filterInstanceToLeaf(inst, null, -1); Node leafNode = foundNode.getNode(); if(leafNode == null){ leafNode = foundNode.getParent(); } ret = leafNode.getClassVotes(inst, this); } else { int numClasses = this.dataset.numClasses(); ret = new double[numClasses]; } //Training after testing to speed up the process if (isTraining){ if(this.treeRoot == null){ this.treeRoot = newLearningNode(this.parallelismHint); this.activeLeafNodeCount = 1; foundNode = this.treeRoot.filterInstanceToLeaf(inst, null, -1); } trainOnInstanceImpl(foundNode, inst); } return ret; }
reset(inst.dataset().numClasses());
@Override public void addResult(Example<Instance> exampleInstance, double[] classVotes) { InstanceImpl inst = (InstanceImpl) exampleInstance.getData(); double weight = inst.weight(); if (inst.classIsMissing() == false) { int trueClass = (int) inst.classValue(); if (weight > 0.0) { // // initialize evaluator if (totalObservedInstances == 0) { reset(inst.dataset().numClasses()); } this.totalObservedInstances += 1; //// if classVotes has length == 1, then the negative (0) class //// got all the votes Double normalizedVote = 0.0; //// normalize and add score if (classVotes.length == 2) { normalizedVote = classVotes[1] / (classVotes[0] + classVotes[1]); } if (normalizedVote.isNaN()) { normalizedVote = 0.0; } this.aucEstimator.add(normalizedVote, trueClass == 1, Utils.maxIndex(classVotes) == trueClass); this.weightMajorityClassifier .add((this.aucEstimator.getRatio() <= 1 ? 0 : 1) == trueClass ? weight : 0); } } }
if (first.numClasses() < second.numClasses()) { classLabels = second.classAttribute(); } else {
if (weight > 0.0) { if (this.totalWeightObserved == 0) { reset(inst.dataset().numClasses());
reset(inst.dataset().numClasses());