public boolean evaluate(MultiLabelInstance instance) { if (instance.isMissing(inputAttributeIndex)) { return false; } boolean evaluation=false; if (instance.valueInputAttribute(inputAttributeIndex)==attributeValue) { evaluation=true; } return (isEqual ? evaluation : (!evaluation)); }
public boolean evaluate(MultiLabelInstance instance) { if (instance.isMissing(inputAttributeIndex)) { return false; } boolean evaluation=false; if (instance.valueInputAttribute(inputAttributeIndex)<=attributeValue) { evaluation=true; } return (isEqualOrLower ? evaluation : (!evaluation)); }
protected double [] getNormalizedInput(MultiLabelInstance instance) { int numInputs=numericIndices.size(); double [] normalizedInput=new double[numInputs]; Iterator<Integer> it=numericIndices.iterator(); int i=0; while(it.hasNext()){ double mean=inAttrSum[i]/count; double std=Utils.computeSD(inAttrSquaredSum[i], inAttrSum[i], count); normalizedInput[i]=instance.valueInputAttribute(it.next())-mean; if (std > SD_THRESHOLD) normalizedInput[i]/=std; i++; } return normalizedInput; }
/** * Method for updating (training) the model using a new instance */ public void trainOnInstanceImpl(MultiLabelInstance inst) { if (inst.weight() > 0) { checkRoot(); double[] prediction = treeRoot.getPrediction(inst); double[] normalError = getNormalizedError(inst, prediction); //normalError.scaleValues(inst.weight()); processInstance(inst, treeRoot, prediction, normalError, true, false); examplesSeen += inst.weight(); for (int i = 0; i < inst.numberOutputTargets(); i++) { sumOfValues.addToValue(i, inst.weight() * inst.valueOutputAttribute(i)); sumOfSquares.addToValue(i, inst.weight() * inst.valueOutputAttribute(i) * inst.valueOutputAttribute(i)); } for (int i = 0; i < inst.numInputAttributes(); i++) { sumOfAttrValues.addToValue(i, inst.weight() * inst.valueInputAttribute(i)); sumOfAttrSquares.addToValue(i, inst.weight() * inst.valueInputAttribute(i) * inst.valueInputAttribute(i)); } } }
int ct=0; while(it.hasNext()){ double value=instance.valueInputAttribute(it.next()); inAttrSum[ct]+=value*w; inAttrSquaredSum[ct]+=value*value*w;
public double[] normalizedInputVector(MultiLabelInstance inst) { // Normalize Instance double[] normalizedInput = new double[inst.numInputAttributes()+1]; if (normalize()) { for (int j = 0; j < inst.numInputAttributes(); j++) { Attribute attr = inst.inputAttribute(j); double value = inst.valueInputAttribute(j); double mean = sumOfAttrValues.getValue(j) / examplesSeen; double sd = computeSD(sumOfAttrSquares.getValue(j), sumOfAttrValues.getValue(j), examplesSeen); if (examplesSeen > 1 && sd > 0.00001) { if (attr.isNumeric()) normalizedInput[j] = (value - mean) / sd; else normalizedInput[j] = value; } else normalizedInput[j] = 0; } if (examplesSeen > 1) normalizedInput[inst.numInputAttributes()] = 1.0; // Value to be multiplied with the constant factor else normalizedInput[inst.numInputAttributes()] = 0.0; } else { for (int j = 0; j < inst.numInputAttributes(); j++) { normalizedInput[j] = inst.valueInputAttribute(j); } normalizedInput[inst.numInputAttributes()] = 1.0; } return normalizedInput; }
double [] stats=sufficientStatistics.get(i); if(instance.attribute(i).isNumeric()){ double val=instance.valueInputAttribute(i); double sd=Utils.computeSD(stats[1], stats[0], weightSeen); if(sd>MINSTD){ double [] stats=sufficientStatistics.get(i); if(instance.attribute(i).isNumeric()){ double val=instance.valueInputAttribute(i); if(stats!=null){
double [] stats=sufficientStatistics.get(i); if(instance.attribute(i).isNumeric()){ double val=instance.valueInputAttribute(i); double sd=Utils.computeSD(stats[1], stats[0], weightSeen); if(sd>MINSTD){ double [] stats=sufficientStatistics.get(i); if(instance.attribute(i).isNumeric()){ double val=instance.valueInputAttribute(i); if(stats!=null){
double[] attVals = new double[numAttributes+1]; //JD - +1 for class for (int attributeIndex = 0; attributeIndex < numAttributes; attributeIndex++) { attVals[attributeIndex] = inst.valueInputAttribute(attributeIndex);
double[] attVals = new double[numAttributes+1]; //JD - +1 for class for (int attributeIndex = 0; attributeIndex < numAttributes; attributeIndex++) { attVals[attributeIndex] = inst.valueInputAttribute(attributeIndex);
obs.observeAttribute(instance.valueInputAttribute(inputsToLearn[i]), exampleStatistics);
obs.observeAttribute(instance.valueInputAttribute(inputsToLearn[i]), exampleStatistics);
observations[j].setValue(2, inst.weight() * inst.valueOutputAttribute(j) * inst.valueOutputAttribute(j)); obs.observeAttribute(inst.valueInputAttribute(i), observations);