Interface Node

All Superinterfaces:
Serializable
All Known Implementing Classes:
DecisionNode, InternalNode, LeafNode, NominalNode, OrdinalNode, RegressionNode

public interface Node extends Serializable
CART tree node.
  • Method Summary

    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.
    double
    Returns the deviance of node.
    dot(StructType schema, StructField response, int id)
    Returns the dot representation of 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.
    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.
  • Method Details

    • predict

      LeafNode predict(Tuple x)
      Evaluate the tree over an instance.
      Parameters:
      x - the instance.
      Returns:
      the leaf node that the instance falls into.
    • dot

      String dot(StructType schema, StructField response, int id)
      Returns the dot representation of node.
      Parameters:
      schema - the schema of data
      response - the schema of response variable
      id - node id
      Returns:
      the dot representation of node.
    • size

      int size()
      Returns the number of samples in the node.
      Returns:
      the number of samples in the node.
    • leaves

      int leaves()
      Returns the number of leaf nodes in the subtree.
      Returns:
      the number of leaf nodes in the subtree.
    • depth

      int depth()
      Returns the maximum depth of the tree -- the number of nodes along the longest path from this node down to the farthest leaf node.
      Returns:
      the maximum depth of the subtree.
    • deviance

      double deviance()
      Returns the deviance of node.
      Returns:
      the deviance of node.
    • merge

      Node merge()
      Try to merge the children nodes and return a leaf node. If not able to merge, return this node itself.
      Returns:
      the merged node, or this node if merge fails.
    • toString

      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.
      Parameters:
      schema - the schema of data
      response - the schema of response variable
      parent - the parent node
      depth - the depth of node in the tree. The root node is at depth 0.
      id - node id
      lines - 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.