Class TreeNode

java.lang.Object
com.imsl.datamining.decisionTree.TreeNode
All Implemented Interfaces:
Serializable, Cloneable

public class TreeNode extends Object implements Serializable, Cloneable
A DecisionTree node that is a child node of Tree.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a DecisionTreeNode object.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected TreeNode
    Returns a clone of a TreeNode.
    int
    getChildId(int i)
    Returns the id of a child node.
    int[]
    Returns the array of child node id's.
    double
    Returns the misclassification cost of a node (in-sample cost measure at the current node).
    int
    Returns the id of the current node.
    double
    Returns the value of the split criteria at the node.
    double
    Returns the value around which the node may be split, if the split variable is of a continuous type.
    int
    Returns the indicator value for the i-th value of the split variable in the current node, if the split variable is categorical
    int[]
    Returns the array indicating which values of the split variable apply in the current node, if the split variable is of discrete type.
    int
    Returns the id of the variable that defines the split in the current node.
    double
    Returns the number of cases in the training data that fall into the current node.
    int
    Returns the number of child nodes associated with the current node.
    int
    Returns the id of the parent node of the current node.
    int
    Returns the predicted class at the current node, for response variables of categorical type.
    double
    Returns the predicted value at the current node for response variables of continuous type.
    double[]
    Returns the surrogate split information array.
    double
    Returns a value from the surrogate split information array.
    double
    getYProb(int i)
    Returns a class probability at the current node, if the response variable is of categorical type.
    double[]
    Returns the class probabilities at the current node, if the response variable is of categorical type.

    Methods inherited from class java.lang.Object

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

    • TreeNode

      public TreeNode()
      Constructs a DecisionTreeNode object.
  • Method Details

    • getChildId

      public int getChildId(int i)
      Returns the id of a child node.
      Parameters:
      i - an int specifying the index of the child node
      Returns:
      an int, the id of the child node at index i
    • getChildrenIds

      public int[] getChildrenIds()
      Returns the array of child node id's.

      Note that the length of this array may exceed the actual number of child nodes. Use getNumberOfChildren() to determine the actual number of children.

      Returns:
      an int array containing id's of the child nodes
    • getCost

      public double getCost()
      Returns the misclassification cost of a node (in-sample cost measure at the current node).
      Returns:
      a double, the misclassification cost of a node
    • getNodeId

      public int getNodeId()
      Returns the id of the current node.

      The root node has nodeId = 0.

      Returns:
      an int, the node id
    • getNodeSplitValue

      public double getNodeSplitValue()
      Returns the value around which the node may be split, if the split variable is of a continuous type.
      Returns:
      a double, the value around which the node may be split
    • getNodeSplitCriteriaValue

      public double getNodeSplitCriteriaValue()
      Returns the value of the split criteria at the node.
      Returns:
      a double, the value of the split criteria at the node
    • getNodeValuesIndicator

      public int[] getNodeValuesIndicator()
      Returns the array indicating which values of the split variable apply in the current node, if the split variable is of discrete type.

      The array at index i will be 1 if the i-th value of the discrete variable belongs in the node. If it does not belong to the node, the array has value 0.

      Returns:
      an int array containing the indicators
    • getNodeValueIndicator

      public int getNodeValueIndicator(int i)
      Returns the indicator value for the i-th value of the split variable in the current node, if the split variable is categorical
      Returns:
      an int, that if 0, the value is not in the node; if 1, it is in the node, meaning that it is in the subset that defines the data partition of the node
    • getNodeVariableId

      public int getNodeVariableId()
      Returns the id of the variable that defines the split in the current node.
      Returns:
      an int, the variable that defines the split in the current node
    • getNumberOfCases

      public double getNumberOfCases()
      Returns the number of cases in the training data that fall into the current node.
      Returns:
      a double, the number of cases (or total case weight) in the training data that fall into the current node
    • getNumberOfChildren

      public int getNumberOfChildren()
      Returns the number of child nodes associated with the current node.
      Returns:
      an int, the number of child nodes associated with this TreeNode instance
    • getParentId

      public int getParentId()
      Returns the id of the parent node of the current node.
      Returns:
      an int, the id of the parent node
    • getPredictedClass

      public int getPredictedClass()
      Returns the predicted class at the current node, for response variables of categorical type.
      Returns:
      an int, the predicted class
    • getPredictedVal

      public double getPredictedVal()
      Returns the predicted value at the current node for response variables of continuous type.
      Returns:
      a double, the predicted value at the current node
    • getSurrogateInfo

      public double getSurrogateInfo(int i)
      Returns a value from the surrogate split information array.
      Parameters:
      i - an int specifying which value to return
      Returns:
      a double, the value at index i
    • getSurrogateInfo

      public double[] getSurrogateInfo()
      Returns the surrogate split information array.
      Returns:
      a double array containing the surrogate split values
    • getYProb

      public double getYProb(int i)
      Returns a class probability at the current node, if the response variable is of categorical type.
      Parameters:
      i - an int specifying the index of the class
      Returns:
      a double, the probability of the class at index i
    • getYProbs

      public double[] getYProbs()
      Returns the class probabilities at the current node, if the response variable is of categorical type.
      Returns:
      a double array containing the class probabilities at the current node
    • clone

      protected TreeNode clone()
      Returns a clone of a TreeNode.
      Overrides:
      clone in class Object
      Returns:
      a TreeNode object that is a clone of the node