Class Node
Object
org.apache.spark.mllib.tree.model.Node
- All Implemented Interfaces:
Serializable,org.apache.spark.internal.Logging
Node in a decision tree.
About node indexing: Nodes are indexed from 1. Node 1 is the root; nodes 2, 3 are the left, right children. Node index 0 is not used.
param: id integer node id, from 1 param: predict predicted value at the node param: impurity current node impurity param: isLeaf whether the node is a leaf param: split split to calculate left and right nodes param: leftNode left child param: rightNode right child param: stats information gain stats
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.spark.internal.Logging
org.apache.spark.internal.Logging.LogStringContext, org.apache.spark.internal.Logging.SparkShellLoggingFilter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic NodeConstruct a node with nodeIndex, predict, impurity and isLeaf parameters.intid()doubleimpurity()booleanisLeaf()static intleftChildIndex(int nodeIndex) Return the index of the left child of this node.scala.Option<Node>leftNode()predict()doublepredict value if node is not leafstatic intrightChildIndex(int nodeIndex) Return the index of the right child of this node.scala.Option<Node>scala.Option<Split>split()scala.Option<InformationGainStats>stats()toString()Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.spark.internal.Logging
initializeForcefully, initializeLogIfNecessary, initializeLogIfNecessary, initializeLogIfNecessary$default$2, isTraceEnabled, log, logBasedOnLevel, logDebug, logDebug, logDebug, logDebug, logError, logError, logError, logError, logInfo, logInfo, logInfo, logInfo, logName, LogStringContext, logTrace, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, logWarning, MDC, org$apache$spark$internal$Logging$$log_, org$apache$spark$internal$Logging$$log__$eq, withLogContext
-
Constructor Details
-
Node
public Node(int id, Predict predict, double impurity, boolean isLeaf, scala.Option<Split> split, scala.Option<Node> leftNode, scala.Option<Node> rightNode, scala.Option<InformationGainStats> stats)
-
-
Method Details
-
apply
Construct a node with nodeIndex, predict, impurity and isLeaf parameters. This is used inDecisionTree.findBestSplitsto construct child nodes after finding the best splits for parent nodes. Other fields are set at next level.- Parameters:
nodeIndex- integer node id, from 1predict- predicted value at the nodeimpurity- current node impurityisLeaf- whether the node is a leaf- Returns:
- new node instance
-
leftChildIndex
public static int leftChildIndex(int nodeIndex) Return the index of the left child of this node.- Parameters:
nodeIndex- (undocumented)- Returns:
- (undocumented)
-
rightChildIndex
public static int rightChildIndex(int nodeIndex) Return the index of the right child of this node.- Parameters:
nodeIndex- (undocumented)- Returns:
- (undocumented)
-
id
public int id() -
predict
-
impurity
public double impurity() -
isLeaf
public boolean isLeaf() -
split
-
leftNode
-
rightNode
-
stats
-
toString
-
predict
predict value if node is not leaf- Parameters:
features- feature value- Returns:
- predicted value
-