|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectDecisionTree
public abstract class DecisionTree
A DecisionTree object represents a decision tree, as described in, for example, the book "Artificial Intelligence" by Russell and Norvig (3rd edition). A DecisionTree is constructed using a set of training examples, and is capable of deciding the class of a novel example. Because decision trees are recursive data structures, any given DecisionTree object could be a node in a larger decision tree, referred to as the full decision tree in the documentation below.
Field Summary | |
---|---|
static java.lang.String |
ROOT_LABEL
The label assigned to the root node of a decision tree. |
Method Summary | |
---|---|
double |
computeErrorRate(InstanceSet testSet)
Compute the error rate of the decision tree on the given test set. |
static DecisionTree |
constructDecisionTree(InstanceSet examples,
java.util.ArrayList<Attribute> attributes,
InstanceSet parentExamples,
java.lang.String label,
int depth)
Construct a decision tree according to the recursive algorithm given in figure 18.5 of Russell and Norvig (third edition). |
abstract java.lang.String |
decide(AttributeSet attributes,
Instance instance)
Return the decision tree's decision for the given instance: that is, the classification that should be assigned to the instance. |
static void |
main(java.lang.String[] arguments)
Constructs a decision tree from the data in a .arff file, prints out the tree, the error rate on the training set, and the decisions on each instance in the training set. |
void |
print()
Print out the DecisionTree in a human-readable form |
void |
printDecisions(InstanceSet testSet)
Print out the decision of this decision tree on every instance in the given test set. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ROOT_LABEL
Method Detail |
---|
public static DecisionTree constructDecisionTree(InstanceSet examples, java.util.ArrayList<Attribute> attributes, InstanceSet parentExamples, java.lang.String label, int depth) throws DecisionTreeException
examples
- The examples from which this tree should be learned.attributes
- A list of attributes on which this tree is permitted to make
decisions.parentExamples
- The examples from which the parent node of this DecisionTree
object were learned. to construct the root node,
parentExamples
should be null.label
- The label on the edge leading to this DecisionTree node, or
DecisionTree.ROOT_LABEL
for the root.depth
- The depth of this node in the full decision tree.
DecisionTreeException
public abstract java.lang.String decide(AttributeSet attributes, Instance instance)
attributes
- The set of attributes employed by the instance.instance
- The instance to be classified.
public void print()
public double computeErrorRate(InstanceSet testSet)
testSet
- A set of examples on which the error rate will be computed.
public void printDecisions(InstanceSet testSet)
testSet
- The set of instances whose decisions will be printed.public static void main(java.lang.String[] arguments) throws DecisionTreeException, java.io.FileNotFoundException, java.io.IOException
arguments
- Requires a single command line argument, what should be the
name of a data file in .arff format.
DecisionTreeException
java.io.FileNotFoundException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |