Class SplitNode<T extends Output<T>>

java.lang.Object
org.tribuo.common.tree.SplitNode<T>
All Implemented Interfaces:
Serializable, Node<T>

public class SplitNode<T extends Output<T>> extends Object implements Node<T>
An immutable Node with a split and two child nodes.
See Also:
  • Field Details

    • CURRENT_VERSION

      public static final int CURRENT_VERSION
      Protobuf serialization version.
      See Also:
  • Constructor Details

    • SplitNode

      public SplitNode(double splitValue, int featureID, double impurity, Node<T> greaterThan, Node<T> lessThanOrEqual)
      Constructs a split node with the specified split value, feature id, impurity and child nodes.
      Parameters:
      splitValue - The feature value to split on.
      featureID - The feature id number.
      impurity - The impurity of this node at training time.
      greaterThan - The node to take if the feature value is greater than the split value.
      lessThanOrEqual - The node to take if the feature value is less than or equal to the split value.
  • Method Details

    • getNextNode

      public Node<T> getNextNode(SparseVector e)
      Return the appropriate child node. If the splitFeature is not present in the example it's value is treated as zero.
      Specified by:
      getNextNode in interface Node<T extends Output<T>>
      Parameters:
      e - The example to inspect.
      Returns:
      The corresponding child node.
    • isLeaf

      public boolean isLeaf()
      Description copied from interface: Node
      Is it a leaf node?
      Specified by:
      isLeaf in interface Node<T extends Output<T>>
      Returns:
      True if it's a leaf node.
    • getImpurity

      public double getImpurity()
      Description copied from interface: Node
      The impurity score of this node.
      Specified by:
      getImpurity in interface Node<T extends Output<T>>
      Returns:
      The node impurity.
    • copy

      public Node<T> copy()
      Description copied from interface: Node
      Copies the node and it's children.
      Specified by:
      copy in interface Node<T extends Output<T>>
      Returns:
      A deep copy.
    • getFeatureID

      public int getFeatureID()
      Gets the feature ID that this node uses for splitting.
      Returns:
      The feature ID.
    • splitValue

      public double splitValue()
      The threshold value.
      Returns:
      The threshold value.
    • getGreaterThan

      public Node<T> getGreaterThan()
      The node used if the value is greater than the splitValue.
      Returns:
      The greater than node.
    • getLessThanOrEqual

      public Node<T> getLessThanOrEqual()
      The node used if the value is less than or equal to the splitValue.
      Returns:
      The less than or equal to node.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object