Data Mining: Practical Machine Learning Tools and Techniques, Second Edition

(Brent) #1

476 CHAPTER 15 | WRITING NEW LEARNING SCHEMES


if (instance.hasMissingValue()) {
throw new NoSupportForMissingValuesException("Id3: no missing values, "
+ "please.");
}
if (m_Attribute == null) {
return m_ClassValue;
} else {
return m_Successors[(int) instance.value(m_Attribute)].
classifyInstance(instance);
}
}

/**
* Computes class distribution for instance using decision tree.
*
* @param instance the instance for which distribution is to be computed
* @return the class distribution for the given instance
*/
public double[] distributionForInstance(Instance instance)
throws NoSupportForMissingValuesException {

if (instance.hasMissingValue()) {
throw new NoSupportForMissingValuesException("Id3: no missing values, "
+ "please.");
}
if (m_Attribute == null) {
return m_Distribution;
} else {
return m_Successors[(int) instance.value(m_Attribute)].
distributionForInstance(instance);
}
}

* @return the classification
*/
public double classifyInstance(Instance instance)
throws NoSupportForMissingValuesException {

/**
* Prints the decision tree using the private toString method from below.
*

Figure 15.1(continued)

Free download pdf