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

(Brent) #1

15.1 AN EXAMPLE CLASSIFIER 473


package weka.classifiers.trees;

import weka.classifiers.*;
import weka.core.*;
import java.io.*;
import java.util.*;

/**
* Class implementing an Id3 decision tree classifier.
*/
public class Id3 extends Classifier {

/** The node's successors. */
private Id3[] m_Successors;

/** Attribute used for splitting. */
private Attribute m_Attribute;

/** Class value if node is leaf. */
private double m_ClassValue;

/** Class distribution if node is leaf. */
private double[] m_Distribution;

/** Class attribute of dataset. */
private Attribute m_ClassAttribute;

/**
* Returns a string describing the classifier.
* @return a description suitable for the GUI.
*/
public String globalInfo() {

return "Class for constructing an unpruned decision tree based on the ID3 "
+ "algorithm. Can only deal with nominal attributes. No missing values "
+ "allowed. Empty leaves may result in unclassified instances. For more "
+ "information see: \n\n"
+ " R. Quinlan (1986). \"Induction of decision "
+ "trees\". Machine Learning. Vol.1, No.1, pp. 81-106";
}

Figure 15.1Source code for the ID3 decision tree learner.

Free download pdf