/** * Returns true if the value of the given dimension is smaller or equal the * value to be compared with. * * @param instance the instance where the value should be taken of * @param dim the dimension of the value * @param value the value to compare with * @return true if value of instance is smaller or equal value */ public boolean valueIsSmallerEqual(Instance instance, int dim, double value) { //This stays return instance.value(dim) <= value; }
public List<Integer> getRelevantLabels(Instance x) { List<Integer> classValues = new LinkedList<Integer>(); //get all class attributes for (int j = 0; j < m_L; j++) { if (x.value(j) > 0.0) { classValues.add(j); } } return classValues; }
@Override public int branchForInstance(Instance inst) { int instAttIndex = this.attIndex ; //< inst.classIndex() ? this.attIndex //: this.attIndex + 1; return inst.isMissing(instAttIndex) ? -1 : (int) inst.value(instAttIndex); }
public double getCenterDistance(Instance instance) { double distance = 0.0; //get the center through getCenter so subclass have a chance double[] center = getCenter(); for (int i = 0; i < center.length; i++) { double d = center[i] - instance.value(i); distance += d * d; } return Math.sqrt(distance); }
@Override public int branchForInstance(Instance inst) { int instAttIndex = this.attIndex ; //< inst.classIndex() ? this.attIndex //: this.attIndex + 1; return inst.isMissing(instAttIndex) ? -1 : (int) inst.value(instAttIndex); }
public double[] getInstanceValues(Instance inst) { int length = inst.numValues()-1; double[] values = new double[length]; // last attribute is the class for (int i = 0; i < length; i++) { values[i] = inst.value(i); } return values; }
@Override public int branchForInstance(Instance inst) { int instAttIndex = this.attIndex ; //< inst.classIndex() ? this.attIndex //: this.attIndex + 1; return inst.isMissing(instAttIndex) ? -1 : (int) inst.value(instAttIndex); }
@Override public int branchForInstance(Instance inst) { int instAttIndex = this.attIndex ; // < inst.classIndex() ? this.attIndex // : this.attIndex + 1; if (inst.isMissing(instAttIndex)) { return -1; } double v = inst.value(instAttIndex); if (v == this.attValue) { return this.equalsPassesTest ? 0 : 1; } return v < this.attValue ? 0 : 1; }
public double getCenterDistance(Instance instance) { double distance = 0.0; //get the center through getCenter so subclass have a chance double[] center = getCenter(); for (int i = 0; i < center.length; i++) { double d = center[i] - instance.value(i); distance += d * d; } return Math.sqrt(distance); }
public double getCenterDistance(Instance instance) { double distance = 0.0; //get the center through getCenter so subclass have a chance double[] center = getCenter(); for (int i = 0; i < center.length; i++) { double d = center[i] - instance.value(i); distance += d * d; } return Math.sqrt(distance); }
@Override public void trainOnInstanceImpl(Instance inst) { this.driftDetectionMethod.input(inst.value(0)); }
@Override public int branchForInstance(Instance inst) { int instAttIndex = this.attIndex < inst.classIndex() ? this.attIndex : this.attIndex + 1; return inst.isMissing(instAttIndex) ? -1 : ((int) inst.value(instAttIndex) == this.attValue ? 0 : 1); }
@Override public Node learnFromInstance(Instance instance) { this.numericAttClassObserver.addValue(instance.value(this.attIndex), (int) instance.value(instance.classIndex()), instance.weight()); this.classValueDist.addToValue((int) instance.value(instance.classIndex()), instance.weight()); this.heuristicMeasureUpdated = false; return this; }
@Override public int branchForInstance(Instance inst) { int instAttIndex = this.attIndex < inst.classIndex() ? this.attIndex : this.attIndex + 1; return inst.isMissing(instAttIndex) ? -1 : ((int) inst.value(instAttIndex) == this.attValue ? 0 : 1); }
@Override public int branchForInstance(Instance inst) { int instAttIndex = this.attIndex < inst.classIndex() ? this.attIndex : this.attIndex + 1; return inst.isMissing(instAttIndex) ? -1 : ((int) inst.value(instAttIndex) == this.attValue ? 0 : 1); }
@Override public Node learnFromInstance(Instance inst) { double attValue = inst.value(attIndex); if (Utils.isMissingValue(attValue)) { } else { updateCountersForChange(inst); } return super.learnFromInstance(inst); }
public double[] normalizedInstance(Instance inst){ // Normalize Instance double[] normalizedInstance = new double[inst.numAttributes()]; for(int j = 0; j < inst.numAttributes() -1; j++) { int instAttIndex = modelAttIndexToInstanceAttIndex(j); double mean = perceptronattributeStatistics.getValue(j) / perceptronYSeen; double sd = computeSD(squaredperceptronattributeStatistics.getValue(j), perceptronattributeStatistics.getValue(j), perceptronYSeen); if (sd > SD_THRESHOLD) normalizedInstance[j] = (inst.value(instAttIndex) - mean)/ sd; else normalizedInstance[j] = inst.value(instAttIndex) - mean; } return normalizedInstance; }
public void PrintInstance(Instance inst) { Print("instance: [ "); for (int i = 0; i < inst.numValues()-1; i++) { // -1 last value is the class Printf("%.2f ", inst.value(i)); } Print("] "); Println(""); }