Class TreeFeature

java.lang.Object
org.tribuo.regression.rtree.impl.TreeFeature
All Implemented Interfaces:
Iterable<InvertedFeature>

public class TreeFeature extends Object implements Iterable<InvertedFeature>
An inverted feature, which stores a reference to all the values of this feature.

Can be split into two values based on an example index list.

  • Constructor Details

    • TreeFeature

      public TreeFeature(int id)
      Constructs an inverted feature with the specified feature id.
      Parameters:
      id - The feature id.
  • Method Details

    • iterator

      public Iterator<InvertedFeature> iterator()
      Specified by:
      iterator in interface Iterable<InvertedFeature>
    • getFeature

      public List<InvertedFeature> getFeature()
      Gets the inverted feature values for this feature.
      Returns:
      The list of feature values.
    • observeValue

      public void observeValue(double value, int exampleID)
      Observes a value for this feature.
      Parameters:
      value - The value observed.
      exampleID - The example id number.
    • sort

      public void sort()
      Sort the list using InvertedFeature's natural ordering. Must be done after all elements are inserted.
    • fixSize

      public void fixSize()
      Fixes the size of each InvertedFeature's inner arrays.
    • split

      public com.oracle.labs.mlrg.olcut.util.Pair<TreeFeature,TreeFeature> split(int[] leftIndices, int[] rightIndices, IntArrayContainer firstBuffer, IntArrayContainer secondBuffer)
      Splits this tree feature into two.
      Parameters:
      leftIndices - The indices to go in the left branch.
      rightIndices - The indices to go in the right branch.
      firstBuffer - A buffer for temporary work.
      secondBuffer - A buffer for temporary work.
      Returns:
      A pair of TreeFeatures, the first element is the left branch, the second the right.
    • toString

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

      public TreeFeature deepCopy()
      Returns a deep copy of this tree feature.
      Returns:
      A deep copy.