Class DecisionTreeNode
java.lang.Object
DecisionTreeNode
public class DecisionTreeNode
- extends java.lang.Object
A DecisionTreeNode represents a single node in a decision tree. A node is
either a leaf or an internal node. Leaf nodes have a fixed "decision" for any
instance that matches them, whereas internal nodes have a number of children
nodes, and a "split attribute" on which a matching instance can be "split".
The instance's value for the given split attribute is used to pass the
instance on to the corresponding child node.
- Author:
- jmac
Constructor Summary |
DecisionTreeNode(java.util.ArrayList<Attribute> availableAttributes,
int level,
java.lang.String selectionValue,
InstanceSet instanceSet)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DecisionTreeNode
public DecisionTreeNode(java.util.ArrayList<Attribute> availableAttributes,
int level,
java.lang.String selectionValue,
InstanceSet instanceSet)
- Parameters:
availableAttributes
- a list of attributes on which this graph node is permitted to
splitlevel
- the depth of this node in the decision tree (the root node has
level 0, its children have level 1, and so on)selectionValue
- the attribute value that would appear on the edge leading to
this node's parent, in the conventional way of drawing
decision trees -- see for example Figure 4.4 of Witten and
Frank (second edition)instanceSet
- the set of instances on which this node is to be trained
getMatchingLeaf
public DecisionTreeNode getMatchingLeaf(Instance instance)
- Parameters:
instance
- the instance whose matching node is to be found
- Returns:
- the leaf node in which the given instance would end up if it
walked down the decision tree from this point, at each node
choosing the child whose selectionValue field matches the
instance's value for this node's split attribute
print
public void print()
- print some details about this DecisionTreeNode
getDecision
public java.lang.String getDecision()
throws java.lang.Exception
- Returns:
- the decision made by this node, provided the node is a leaf
- Throws:
java.lang.Exception
- if the node is an internal node
getClassProbabilities
public java.util.Hashtable<java.lang.String,java.lang.Double> getClassProbabilities()
throws java.lang.Exception
- Returns:
- the table mapping class values to their probabilities, provided
this node is a leaf
- Throws:
java.lang.Exception
- if the node is an internal node