Package org.tribuo.common.tree
Class LeafNode<T extends Output<T>>
java.lang.Object
org.tribuo.common.tree.LeafNode<T>
- All Implemented Interfaces:
Serializable
,Node<T>
An immutable leaf
Node
that can create a prediction.
equals(java.lang.Object)
uses the Output.fullEquals(Output)
method
to determine equality of two leaves.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncopy()
Copies the node and it's children.boolean
Gets the distribution over scores in this node.double
The impurity score of this node.Returns the next node in the tree based on the supplied example, or null if it's a leaf.Gets the output in this node.getPrediction
(int numUsed, Example<T> example) Constructs a new prediction object based on this node's scores.int
hashCode()
boolean
isLeaf()
Is it a leaf node?toString()
-
Constructor Details
-
LeafNode
Constructs a leaf node.- Parameters:
impurity
- The impurity value calculated at training time.output
- The output value from this node.scores
- The score map for the other outputs.generatesProbabilities
- If the scores are probabilities.
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
getNextNode
Description copied from interface:Node
Returns the next node in the tree based on the supplied example, or null if it's a leaf.- Specified by:
getNextNode
in interfaceNode<T extends Output<T>>
- Parameters:
e
- The example.- Returns:
- The next node down in the tree.
-
isLeaf
public boolean isLeaf()Description copied from interface:Node
Is it a leaf node? -
getImpurity
public double getImpurity()Description copied from interface:Node
The impurity score of this node.- Specified by:
getImpurity
in interfaceNode<T extends Output<T>>
- Returns:
- The node impurity.
-
copy
Description copied from interface:Node
Copies the node and it's children. -
getOutput
Gets the output in this node.- Returns:
- The output.
-
getDistribution
Gets the distribution over scores in this node.- Returns:
- The score distribution.
-
getPrediction
Constructs a new prediction object based on this node's scores.- Parameters:
numUsed
- The number of features used.example
- The example to be scored.- Returns:
- The prediction for the supplied example.
-
toString
-