Class InternalNode
java.lang.Object
smile.base.cart.InternalNode
- All Implemented Interfaces:
Serializable, Node
- Direct Known Subclasses:
NominalNode, OrdinalNode
-
Constructor Summary
ConstructorsConstructorDescriptionInternalNode(int feature, double score, double deviance, Node trueChild, Node falseChild) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanReturns true if the instance goes to the true branch.intdepth()Returns the maximum depth of the tree -- the number of nodes along the longest path from this node down to the farthest leaf node.doubledeviance()Returns the deviance of node.Returns the false branch child.intfeature()Returns the split feature.intleaves()Returns the number of leaf nodes in the subtree.merge()Try to merge the children nodes and return a leaf node.abstract LeafNodeEvaluate the tree over an instance.abstract InternalNodeReturns a new internal node with children replaced.doublescore()Returns the split score (reduction of impurity).intsize()Returns the number of samples in the node.abstract StringtoString(StructType schema, boolean trueBranch) Returns the string representation of branch.int[]toString(StructType schema, StructField response, InternalNode parent, int depth, BigInteger id, List<String> lines) Adds the string representation (R's rpart format) to a collection.Returns the true branch child.
-
Constructor Details
-
InternalNode
-
-
Method Details
-
predict
-
branch
Returns true if the instance goes to the true branch.- Parameters:
x- the instance.- Returns:
- true if the instance goes to the true branch.
-
replace
Returns a new internal node with children replaced.- Parameters:
trueChild- the new true branch child.falseChild- the new false branch child.- Returns:
- a new internal node with children replaced.
-
trueChild
-
falseChild
-
feature
public int feature()Returns the split feature.- Returns:
- the split feature.
-
score
public double score()Returns the split score (reduction of impurity).- Returns:
- the split score.
-
size
-
leaves
-
deviance
-
depth
-
merge
-
toString
Returns the string representation of branch.- Parameters:
schema- the schema of data.trueBranch- for true or false branch.- Returns:
- the string representation of branch.
-
toString
public int[] toString(StructType schema, StructField response, InternalNode parent, int depth, BigInteger id, List<String> lines) Description copied from interface:NodeAdds the string representation (R's rpart format) to a collection.- Specified by:
toStringin interfaceNode- Parameters:
schema- the schema of dataresponse- the schema of response variableparent- the parent nodedepth- the depth of node in the tree. The root node is at depth 0.id- node idlines- the collection of node's string representation.- Returns:
- the sample count of each class for decision tree; single element array [node size] for regression tree.
-