Class LeafNode

java.lang.Object
smile.base.cart.LeafNode
All Implemented Interfaces:
Serializable, Node
Direct Known Subclasses:
DecisionNode, RegressionNode

public abstract class LeafNode extends Object implements Node
A leaf node in decision tree.
See Also:
  • Field Summary Link icon

    Fields
    Modifier and Type
    Field
    Description
    protected final int
    The number of samples in the node.
  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
    LeafNode(int size)
    Constructor.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    int
    Returns the maximum depth of the tree -- the number of nodes along the longest path from this node down to the farthest leaf node.
    int
    Returns the number of leaf nodes in the subtree.
    Try to merge the children nodes and return a leaf node.
    Evaluate the tree over an instance.
    int
    Returns the number of samples in the node.

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface smile.base.cart.Node Link icon

    deviance, dot, toString
  • Field Details Link icon

    • size Link icon

      protected final int size
      The number of samples in the node.
  • Constructor Details Link icon

    • LeafNode Link icon

      public LeafNode(int size)
      Constructor.
      Parameters:
      size - the number of samples in the node
  • Method Details Link icon

    • size Link icon

      public int size()
      Description copied from interface: Node
      Returns the number of samples in the node.
      Specified by:
      size in interface Node
      Returns:
      the number of samples in the node.
    • leaves Link icon

      public int leaves()
      Description copied from interface: Node
      Returns the number of leaf nodes in the subtree.
      Specified by:
      leaves in interface Node
      Returns:
      the number of leaf nodes in the subtree.
    • predict Link icon

      public LeafNode predict(Tuple x)
      Description copied from interface: Node
      Evaluate the tree over an instance.
      Specified by:
      predict in interface Node
      Parameters:
      x - the instance.
      Returns:
      the leaf node that the instance falls into.
    • depth Link icon

      public int depth()
      Description copied from interface: Node
      Returns the maximum depth of the tree -- the number of nodes along the longest path from this node down to the farthest leaf node.
      Specified by:
      depth in interface Node
      Returns:
      the maximum depth of the subtree.
    • merge Link icon

      public Node merge()
      Description copied from interface: Node
      Try to merge the children nodes and return a leaf node. If not able to merge, return this node itself.
      Specified by:
      merge in interface Node
      Returns:
      the merged node, or this node if merge fails.