protected void updateAccumulatedError(Instance inst){ double mean=0; nError=1+fadingErrorFactor*nError; if(n>0) mean=sum/n; errorSum=Math.abs(inst.classValue()-mean)+fadingErrorFactor*errorSum; }
protected void updateAccumulatedError(Instance inst){ double mean=0; nError=1+fadingErrorFactor*nError; if(n>0) mean=sum/n; errorSum=Math.abs(inst.classValue()-mean)+fadingErrorFactor*errorSum; }
private double normalizeActualClassValue(Instance inst) { double meanY = perceptronsumY / perceptronYSeen; double sdY = computeSD(squaredperceptronsumY, perceptronsumY, perceptronYSeen); double normalizedY; if (sdY > SD_THRESHOLD){ normalizedY = (inst.classValue() - meanY) / sdY; }else{ normalizedY = inst.classValue() - meanY; } return normalizedY; }
@Override public void trainOnInstanceImpl(Instance inst) { updateAccumulatedError(inst); ++this.n; this.sum+=inst.classValue(); } protected void updateAccumulatedError(Instance inst){
@Override public void trainOnInstanceImpl(Instance inst) { updateAccumulatedError(inst); ++this.n; this.sum+=inst.classValue(); } protected void updateAccumulatedError(Instance inst){
public double computeError(Instance instance) { double normalizedPrediction = getNormalizedPrediction(instance); double normalizedClassValue = normalize(instance.classValue()); return Math.abs(normalizedClassValue - normalizedPrediction); }
protected void updateAccumulatedError(Instance inst){ double mean=0; nError=inst.weight()+fadingErrorFactor*nError; if(n>0) mean=sum/n; errorSum=Math.abs(inst.classValue()-mean)*inst.weight()+fadingErrorFactor*errorSum; }
public double computeError(Instance instance) { double normalizedPrediction = getNormalizedPrediction(instance); double normalizedClassValue = normalize(instance.classValue()); return Math.abs(normalizedClassValue - normalizedPrediction); }
@Override public void addPrediction(double[] prediction, Instance inst) { double error=(prediction[0]-inst.classValue()); sumSquaredError=error*error*inst.weight()+fadingErrorFactor*sumSquaredError; weightSeen=inst.weight()+fadingErrorFactor*weightSeen; }
@Override void learnFromInstance(Instance inst, ModelAggregatorProcessor proc) { this.observedClassDistribution.addToValue( (int)inst.classValue(), inst.weight()); }
/** * Gets whether this classifier correctly classifies an instance. Uses * getVotesForInstance to obtain the prediction and the instance to obtain * its true class. * * * @param inst the instance to be classified * @return true if the instance is correctly classified */ private boolean correctlyClassifies(Instance inst) { return maxIndex(model.getVotesForInstance(inst)) == (int) inst.classValue(); }
@Override public Node learnFromInstance(Instance inst) { double[] classVotes = getMajorityClassVotes(inst); double error = (Utils.maxIndex(classVotes) == (int) inst.classValue()) ? 0.0 : 1.0; this.majorityClassError += error; classVotes = getNaiveBayesPrediction(inst); error = (Utils.maxIndex(classVotes) == (int) inst.classValue()) ? 0.0 : 1.0; this.naiveBayesError += error; return super.learnFromInstance(inst); }
/** * Creates a prediction history incrementally by using the previous predictions. */ private List<Integer> getIncrementalTestTrainPredHistory(Instances instances, int startIdx, List<Integer> predictionHistory){ for (int i= startIdx + this.kOption.getValue() + predictionHistory.size(); i < instances.numInstances(); i++){ predictionHistory.add((this.getLabelFct(distanceMatrixSTM[i], instances, startIdx, i-1)==instances.get(i).classValue()) ? 1 : 0); } return predictionHistory; } /**
@Override public void trainOnInstanceImpl(Instance inst) { updateAccumulatedError(inst); this.n+=inst.weight(); this.sum+=inst.classValue()*inst.weight(); } protected void updateAccumulatedError(Instance inst){
@Override public void trainOnInstanceImpl(Instance inst) { if (inst.classValue() > C) C = (int)inst.classValue(); if (this.window == null) { this.window = new Instances(inst.dataset()); } if (this.limitOption.getValue() <= this.window.numInstances()) { this.window.delete(0); } this.window.add(inst); }
@Override public void trainOnInstanceImpl(Instance inst) { updateAccumulatedError(inst); nD=inst.weight()+fadingFactor*nD; sum=inst.classValue()*inst.weight()+fadingFactor*sum; } @Override
@Override public Node learnFromInstance(Instance inst) { // test-then-train double[] classVotes = getMajorityClassVotes(inst); double error = (Utils.maxIndex(classVotes) == (int) inst.classValue()) ? 0.0 : 1.0; this.majorityClassError.input(error); classVotes = getNaiveBayesPrediction(inst); error = (Utils.maxIndex(classVotes) == (int) inst.classValue()) ? 0.0 : 1.0; this.naiveBayesError.input(error); return super.learnFromInstance(inst); } }
private ResultContentEvent newResultContentEvent(double[] prediction, Instance inst, InstancesContentEvent inEvent){ ResultContentEvent rce = new ResultContentEvent(inEvent.getInstanceIndex(), inst, (int) inst.classValue(), prediction, inEvent.isLastEvent()); rce.setClassifierIndex(this.processorId); rce.setEvaluationIndex(inEvent.getEvaluationIndex()); return rce; }
@Override public void learnFromInstance(Instance inst, HoeffdingTree ht) { int trueClass = (int) inst.classValue(); if (this.observedClassDistribution.maxIndex() == trueClass) { this.mcCorrectWeight += inst.weight(); } if (Utils.maxIndex(NaiveBayes.doNaiveBayesPrediction(inst, this.observedClassDistribution, this.attributeObservers)) == trueClass) { this.nbCorrectWeight += inst.weight(); } super.learnFromInstance(inst, ht); }
@Override public void learnFromInstance(Instance inst, HoeffdingTree ht) { int trueClass = (int) inst.classValue(); if (this.observedClassDistribution.maxIndex() == trueClass) { this.mcCorrectWeight += inst.weight(); } if (Utils.maxIndex(NaiveBayes.doNaiveBayesPrediction(inst, this.observedClassDistribution, this.attributeObservers)) == trueClass) { this.nbCorrectWeight += inst.weight(); } super.learnFromInstance(inst, ht); }