Class ClassifierTrainingNode

java.lang.Object
org.tribuo.common.tree.AbstractTrainingNode<Label>
org.tribuo.classification.dtree.impl.ClassifierTrainingNode
All Implemented Interfaces:
Serializable, Node<Label>

public class ClassifierTrainingNode extends AbstractTrainingNode<Label>
A decision tree node used at training time. Contains a list of the example indices currently found in this node, the current impurity and a bunch of other statistics.
See Also:
  • Constructor Details

    • ClassifierTrainingNode

      public ClassifierTrainingNode(LabelImpurity impurity, Dataset<Label> examples, AbstractTrainingNode.LeafDeterminer leafDeterminer)
      Constructor which creates the inverted file.
      Parameters:
      impurity - The impurity function to use.
      examples - The training data.
      leafDeterminer - Contains parameters needed to determine whether a child node will be a leaf.
  • Method Details

    • getWeightSum

      public float getWeightSum()
      Description copied from class: AbstractTrainingNode
      The sum of the weights associated with this node's examples.
      Specified by:
      getWeightSum in class AbstractTrainingNode<Label>
      Returns:
      the sum of the weights associated with this node's examples.
    • getImpurity

      public double getImpurity()
      Description copied from interface: Node
      The impurity score of this node.
      Returns:
      The node impurity.
    • buildTree

      public List<AbstractTrainingNode<Label>> buildTree(int[] featureIDs, SplittableRandom rng, boolean useRandomSplitPoints)
      Builds a tree according to CART (as it does not do multi-way splits on categorical values like C4.5).
      Specified by:
      buildTree in class AbstractTrainingNode<Label>
      Parameters:
      featureIDs - Indices of the features available in this split.
      rng - Splittable random number generator.
      useRandomSplitPoints - Whether to choose split points for features at random.
      Returns:
      A possibly empty list of TrainingNodes.
    • buildRandomTree

      public List<AbstractTrainingNode<Label>> buildRandomTree(int[] featureIDs, SplittableRandom rng)
      Builds a CART tree with randomly chosen split points.
      Parameters:
      featureIDs - Indices of the features available in this split.
      rng - Splittable random number generator.
      Returns:
      A possibly empty list of TrainingNodes.
    • convertTree

      public Node<Label> convertTree()
      Generates a test time tree (made of SplitNode and LeafNode) from the tree rooted at this node.
      Specified by:
      convertTree in class AbstractTrainingNode<Label>
      Returns:
      A subtree using the SplitNode and LeafNode classes.