InputType - The input type of the tree.OutputType - The output type of the tree.InteriorType - The output of the decision at this node.public abstract class AbstractDecisionTreeNode<InputType,OutputType,InteriorType> extends AbstractCloneableSerializable implements DecisionTreeNode<InputType,OutputType>
AbstractDecisionTreeNode class implements common functionality
for a decision tree node. It keeps the internal decider plus the collection
of child nodes and the incoming label value for the node.| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<InteriorType,DecisionTreeNode<InputType,OutputType>> |
childMap
The mapping of decider decision values to child nodes.
|
protected Categorizer<? super InputType,? extends InteriorType> |
decider
The decider used to make a decision as to which child use.
|
protected java.lang.Object |
incomingValue
The incoming value for the node.
|
protected DecisionTreeNode<InputType,OutputType> |
parent
The parent node of this node.
|
| Constructor and Description |
|---|
AbstractDecisionTreeNode()
Creates a new instance of AbstractDecisionTreeNode
|
AbstractDecisionTreeNode(DecisionTreeNode<InputType,OutputType> parent,
Categorizer<? super InputType,? extends InteriorType> decider,
java.lang.Object incomingValue)
Creates a new instance of CategorizationTreeNode.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(InteriorType value,
DecisionTreeNode<InputType,OutputType> child)
Adds a child for a given interior type.
|
DecisionTreeNode<InputType,OutputType> |
chooseChild(InputType input)
Chooses the child node corresponding to the given input.
|
AbstractDecisionTreeNode<InputType,OutputType,InteriorType> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
java.util.Map<InteriorType,DecisionTreeNode<InputType,OutputType>> |
getChildMap()
Gets the mapping of decision values to child nodes.
|
java.util.Collection<? extends DecisionTreeNode<InputType,OutputType>> |
getChildren()
Gets the collection of children of the node.
|
Categorizer<? super InputType,? extends InteriorType> |
getDecider()
Gets the decider used at this node.
|
int |
getDepth()
Gets the depth of the node in the tree.
|
java.lang.Object |
getIncomingValue()
Gets the label of the incoming value to the node.
|
DecisionTreeNode<InputType,OutputType> |
getParent()
Gets the parent node for this node.
|
int |
getTreeSize()
Gets the size of the sub-tree from this node.
|
boolean |
isLeaf()
Returns true if this node is a leaf node (has no children) and false
otherwise.
|
protected void |
setChildMap(java.util.Map<InteriorType,DecisionTreeNode<InputType,OutputType>> childMap)
Sets the mapping of decision values to child nodes.
|
void |
setDecider(Categorizer<? super InputType,? extends InteriorType> decider)
Sets the decider used at this node.
|
void |
setIncomingValue(java.lang.Object incomingValue)
Sets the incoming value for the node.
|
void |
setParent(DecisionTreeNode<InputType,OutputType> parent)
Sets the parent node for this node.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetOutputprotected DecisionTreeNode<InputType,OutputType> parent
protected java.util.Map<InteriorType,DecisionTreeNode<InputType,OutputType>> childMap
protected Categorizer<? super InputType,? extends InteriorType> decider
protected java.lang.Object incomingValue
public AbstractDecisionTreeNode()
public AbstractDecisionTreeNode(DecisionTreeNode<InputType,OutputType> parent, Categorizer<? super InputType,? extends InteriorType> decider, java.lang.Object incomingValue)
parent - The parent node of this node.decider - The decision function.incomingValue - The incoming value.public AbstractDecisionTreeNode<InputType,OutputType,InteriorType> clone()
AbstractCloneableSerializableObject class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone() to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone() as the basis for your implementation.clone in interface CloneableSerializableclone in class AbstractCloneableSerializablepublic void addChild(InteriorType value, DecisionTreeNode<InputType,OutputType> child)
value - The interior type value for the child.child - The child node to add.public java.util.Collection<? extends DecisionTreeNode<InputType,OutputType>> getChildren()
DecisionTreeNodegetChildren in interface DecisionTreeNode<InputType,OutputType>public boolean isLeaf()
DecisionTreeNodeisLeaf in interface DecisionTreeNode<InputType,OutputType>public DecisionTreeNode<InputType,OutputType> chooseChild(InputType input)
DecisionTreeNodechooseChild in interface DecisionTreeNode<InputType,OutputType>input - The input.public int getDepth()
DecisionTreeNodegetDepth in interface DecisionTreeNode<InputType,OutputType>public int getTreeSize()
DecisionTreeNodegetTreeSize in interface DecisionTreeNode<InputType,OutputType>public DecisionTreeNode<InputType,OutputType> getParent()
getParent in interface DecisionTreeNode<InputType,OutputType>public void setParent(DecisionTreeNode<InputType,OutputType> parent)
parent - The parent node for this node.public Categorizer<? super InputType,? extends InteriorType> getDecider()
public void setDecider(Categorizer<? super InputType,? extends InteriorType> decider)
decider - The decider used.public java.util.Map<InteriorType,DecisionTreeNode<InputType,OutputType>> getChildMap()
protected void setChildMap(java.util.Map<InteriorType,DecisionTreeNode<InputType,OutputType>> childMap)
childMap - The child map.public java.lang.Object getIncomingValue()
getIncomingValue in interface DecisionTreeNode<InputType,OutputType>public void setIncomingValue(java.lang.Object incomingValue)
incomingValue - The incoming value for the node.