Class DecisionNode
java.lang.Object
|
+----DecisionNode
- public class DecisionNode
- extends Object
This class provides the nodes for the decision tree.
-
DecisionNode(StringBag)
-
-
chooseCategory()
-
-
getCategories()
-
-
getDecisionLink(Example)
-
-
getNoLink()
-
-
getYesLink()
-
-
setFeature(String)
-
-
setNoLink(DecisionNode)
-
-
setPosition(int)
-
-
setYesLink(DecisionNode)
-
-
write()
- This mothod writes out the nodes decision feature information if it
is a non-leaf (internal) node.
DecisionNode
public DecisionNode(StringBag possibleCategories)
- Parameters:
- possibleCategories - the list of categories (includes duplicates)
of all training examples consistent with the parents' decisions
- Postcondition
- The node has the list of categories
consistent with parent (if any) decision. The node has no children
or decision feature (yet).
getYesLink
public DecisionNode getYesLink()
- Returns:
- the link to follow if the example has the node's feature
getNoLink
public DecisionNode getNoLink()
- Returns:
- the link to follow if the example does not have the node's feature
setFeature
public void setFeature(String featureValue)
- Parameters:
- featureValue - the value this node will use for its decision
setPosition
public void setPosition(int positionOfFeature)
- Parameters:
- positionOfFeature - the position of the feature value in an example
that this node will use for its decision
setYesLink
public void setYesLink(DecisionNode link)
- Parameters:
- link - the link to follow if the example has the
node's feature
setNoLink
public void setNoLink(DecisionNode link)
- Parameters:
- link - the link to follow if the example does not have the
node's feature
getDecisionLink
public DecisionNode getDecisionLink(Example testExample)
- Parameters:
- testExample - the example to be classified
- Precondition
- This node has a decision feature
- Returns:
- the reference to the next node for continuing the classification
getCategories
public StringBag getCategories()
- Returns:
- the collection of categories (includes duplicates) consistent
with the parents' decisions
chooseCategory
public String chooseCategory()
- Returns:
- a randomly chosen category for the collection of categories
consistent with the parents' decisions
write
public void write()
- This mothod writes out the nodes decision feature information if it
is a non-leaf (internal) node. If it is a leaf node, it writes out
the node's categories