Class InvertedFeature

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

public class InvertedFeature extends Object implements Comparable<InvertedFeature>
Internal datastructure for implementing a decision tree.

Represents a single value and feature tuple, with associated arrays for the indicies where that combination occurs.

Indices and values must be inserted in sorted ascending order or everything will break. This code does not check that this invariant is maintained.

Note: this class has a natural ordering that is inconsistent with equals.

  • Field Details

    • value

      public final double value
      The feature value of this object.
  • Constructor Details

    • InvertedFeature

      public InvertedFeature(double value, int[] indices)
      Constructs an inverted feature for the specified value which occurs at the specified indices.
      Parameters:
      value - The value.
      indices - The indices where the value occurs.
    • InvertedFeature

      public InvertedFeature(double value, int index)
      Constructs an inverted feature for the specifed value which occurs at a single index.
      Parameters:
      value - The value.
      index - The index where the value occurs.
  • Method Details

    • add

      public void add(int index)
      Adds an index where the feature value occurs.
      Parameters:
      index - The index.
    • indices

      public int[] indices()
      Gets the indices where this feature value occurs.
      Returns:
      The indices.
    • fixSize

      public void fixSize()
      Fixes the size of the backing array.

      Used when all the feature values have been observed.

    • split

      public com.oracle.labs.mlrg.olcut.util.Pair<InvertedFeature,InvertedFeature> split(IntArrayContainer allLeftIndices, IntArrayContainer buffer)
      Relies upon allLeftIndices being sorted in ascending order. Undefined when it's not.
      Parameters:
      allLeftIndices - The indices of the left branch.
      buffer - The buffer to write out the unused indices to.
      Returns:
      A pair, with the first element the left branch and the second element the right branch.
    • compareTo

      public int compareTo(InvertedFeature o)
      Specified by:
      compareTo in interface Comparable<InvertedFeature>
    • toString

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

      public InvertedFeature deepCopy()
      Copies this inverted feature.
      Returns:
      A copy of this feature.