Package org.tribuo.regression.rtree.impl
Class InvertedFeature
java.lang.Object
org.tribuo.regression.rtree.impl.InvertedFeature
- All Implemented Interfaces:
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 Summary
-
Constructor Summary
ConstructorDescriptionInvertedFeature
(double value, int index) Constructs an inverted feature for the specifed value which occurs at a single index.InvertedFeature
(double value, int[] indices) Constructs an inverted feature for the specified value which occurs at the specified indices. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int index) Adds an index where the feature value occurs.int
deepCopy()
Copies this inverted feature.void
fixSize()
Fixes the size of the backing array.int[]
indices()
Gets the indices where this feature value occurs.com.oracle.labs.mlrg.olcut.util.Pair<InvertedFeature,
InvertedFeature> split
(IntArrayContainer allLeftIndices, IntArrayContainer buffer) Relies upon allLeftIndices being sorted in ascending order.toString()
-
Field Details
-
value
public final double valueThe 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
- Specified by:
compareTo
in interfaceComparable<InvertedFeature>
-
toString
-
deepCopy
Copies this inverted feature.- Returns:
- A copy of this feature.
-