Class DecisionNode

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

public class DecisionNode extends LeafNode
A leaf node in decision tree.
See Also:
  • Field Summary

    Fields inherited from class smile.base.cart.LeafNode

    size
  • Constructor Summary

    Constructors
    Constructor
    Description
    DecisionNode(int[] count)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    int[]
    Returns the number of node samples in each class.
    double
    Returns the deviance of node.
    static double
    deviance(int[] count, double[] prob)
    Returns the deviance of node.
    dot(smile.data.type.StructType schema, smile.data.type.StructField response, int id)
    Returns the dot representation of node.
    boolean
     
    double
    Returns the impurity of node.
    static double
    impurity(SplitRule rule, int size, int[] count)
    Returns the impurity of samples.
    int
    Returns the predicted value.
    double[]
    posteriori(double[] prob)
    Returns the class probability.
    static double[]
    posteriori(int[] count, double[] prob)
    Returns the class probability.
    int[]
    toString(smile.data.type.StructType schema, smile.data.type.StructField response, InternalNode parent, int depth, BigInteger id, List<String> lines)
    Adds the string representation (R's rpart format) to a collection.

    Methods inherited from class smile.base.cart.LeafNode

    depth, leaves, merge, predict, size

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DecisionNode

      public DecisionNode(int[] count)
      Constructor.
      Parameters:
      count - the number of node samples in each class.
  • Method Details

    • output

      public int output()
      Returns the predicted value.
      Returns:
      the predicted value.
    • count

      public int[] count()
      Returns the number of node samples in each class.
      Returns:
      the number of node samples in each class.
    • deviance

      public double deviance()
      Description copied from interface: Node
      Returns the deviance of node.
      Returns:
      the deviance of node.
    • dot

      public String dot(smile.data.type.StructType schema, smile.data.type.StructField response, int id)
      Description copied from interface: Node
      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.
    • toString

      public int[] toString(smile.data.type.StructType schema, smile.data.type.StructField response, InternalNode parent, int depth, BigInteger id, List<String> lines)
      Description copied from interface: Node
      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.
    • impurity

      public double impurity(SplitRule rule)
      Returns the impurity of node.
      Parameters:
      rule - the node split rule.
      Returns:
      the impurity of node
    • impurity

      public static double impurity(SplitRule rule, int size, int[] count)
      Returns the impurity of samples.
      Parameters:
      rule - the node split rule.
      size - the number of samples.
      count - the number of samples in each class.
      Returns:
      the impurity of node
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • posteriori

      public double[] posteriori(double[] prob)
      Returns the class probability.
      Parameters:
      prob - the output variable of posteriori probabilities.
      Returns:
      the posteriori probabilities.
    • posteriori

      public static double[] posteriori(int[] count, double[] prob)
      Returns the class probability.
      Parameters:
      count - the input variable of the number of samples per class.
      prob - the output variable of posteriori probabilities.
      Returns:
      the posteriori probabilities.
    • deviance

      public static double deviance(int[] count, double[] prob)
      Returns the deviance of node.
      Parameters:
      count - the input variable of the number of samples per class.
      prob - the output variable of posteriori probabilities.
      Returns:
      the deviance of node.