public abstract class TreeNodeVisitor extends Object implements Serializable, Cloneable
childrenCount()
may choose to return 0, otherwise - it must return the original number of
paths to children nodes.
The implementation for a given tree should override
localClassify(jsat.classifiers.DataPoint)
and
localRegress(jsat.classifiers.DataPoint)
if the operations are
supported.TreeLearner
,
TreePruner
,
Serialized FormConstructor and Description |
---|
TreeNodeVisitor() |
Modifier and Type | Method and Description |
---|---|
abstract int |
childrenCount()
Returns the number of children this node of the tree has, and may return
a non zero value even if the node is a leaf
|
CategoricalResults |
classify(DataPoint dp) |
abstract TreeNodeVisitor |
clone() |
abstract void |
disablePath(int child)
Disables the selected path to the specified child from the current node.
|
abstract Collection<Integer> |
featuresUsed()
Returns a collection of the indices of the features used by this node in
the tree to make its decision about what branch to use next.
|
abstract TreeNodeVisitor |
getChild(int child)
Returns the node for the specific child, or null if the child index was
not valid
|
abstract int |
getPath(DataPoint dp)
Returns the path down the tree the given data point would have taken, or
-1 if this node was a leaf node OR if a missing value prevent traversal
down the path
|
double |
getPathWeight(int path)
Returns the relative weight of each path, which should be an indication
of how much of the training data went down each path.
|
abstract boolean |
isLeaf()
Returns true if the node is a leaf, meaning it has no valid paths to any
children
|
abstract boolean |
isPathDisabled(int child)
Returns true if the path to the specified child is disabled, meaning it
can not be traveled to.
|
CategoricalResults |
localClassify(DataPoint dp)
Returns the classification result that would have been obtained if the
current node was a leaf node.
|
double |
localRegress(DataPoint dp)
Returns the regression result that would have been obtained if the
current node was a leaf node.
|
double |
regress(DataPoint dp)
Performs regression on the given data point by following it down the tree
until it finds the correct terminal node.
|
void |
setPath(int child,
TreeNodeVisitor node)
Optional operation!
This method, if supported, will set the path so that the child is set to the given value. |
public abstract int childrenCount()
public abstract boolean isLeaf()
public abstract TreeNodeVisitor getChild(int child)
child
- the index of the child node to obtainpublic abstract void disablePath(int child)
child
- the index of the child to disable the path toopublic void setPath(int child, TreeNodeVisitor node)
child
- the child pathnode
- the node to make the childpublic abstract boolean isPathDisabled(int child)
child
- the child index to check the path forpublic CategoricalResults localClassify(DataPoint dp)
dp
- the data point to localClassifyUnsupportedOperationException
- if the tree node does not support
or was not trained for classificationpublic abstract int getPath(DataPoint dp)
dp
- the data point to send down the treepublic double getPathWeight(int path)
childrenCount()
. The result should sum to onepath
- the path to selectpublic CategoricalResults classify(DataPoint dp)
public double localRegress(DataPoint dp)
dp
- the data point to regressUnsupportedOperationException
- if the tree node does not support
or was not trained for classificationpublic double regress(DataPoint dp)
dp
- the data point to regresspublic abstract Collection<Integer> featuresUsed()
public abstract TreeNodeVisitor clone()
Copyright © 2017. All rights reserved.