Package org.tribuo.regression.rtree.impl
Class TreeFeature
java.lang.Object
org.tribuo.regression.rtree.impl.TreeFeature
- All Implemented Interfaces:
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 Summary
ConstructorDescriptionTreeFeature
(int id) Constructs an inverted feature with the specified feature id. -
Method Summary
Modifier and TypeMethodDescriptiondeepCopy()
Returns a deep copy of this tree feature.void
fixSize()
Fixes the size of eachInvertedFeature
's inner arrays.Gets the inverted feature values for this feature.iterator()
void
observeValue
(double value, int exampleID) Observes a value for this feature.void
sort()
Sort the list using InvertedFeature's natural ordering.com.oracle.labs.mlrg.olcut.util.Pair<TreeFeature,
TreeFeature> split
(int[] leftIndices, int[] rightIndices, IntArrayContainer firstBuffer, IntArrayContainer secondBuffer) Splits this tree feature into two.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TreeFeature
public TreeFeature(int id) Constructs an inverted feature with the specified feature id.- Parameters:
id
- The feature id.
-
-
Method Details
-
iterator
- Specified by:
iterator
in interfaceIterable<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 eachInvertedFeature
'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
-
deepCopy
Returns a deep copy of this tree feature.- Returns:
- A deep copy.
-