Class IndexedArrayExample<T extends Output<T>>
java.lang.Object
org.tribuo.Example<T>
org.tribuo.impl.ArrayExample<T>
org.tribuo.impl.IndexedArrayExample<T>
- All Implemented Interfaces:
Serializable
,Iterable<Feature>
A version of ArrayExample which also has the id numbers.
Used in feature selection to provide log n lookups. May be used elsewhere in the future as a performance optimisation.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
A tuple of the feature name, id and value. -
Field Summary
FieldsFields inherited from class org.tribuo.impl.ArrayExample
DEFAULT_SIZE, featureNames, featureValues, size
Fields inherited from class org.tribuo.Example
DEFAULT_METADATA_SIZE, DEFAULT_WEIGHT, metadata, NAME, output, weight
-
Constructor Summary
ConstructorsConstructorDescriptionIndexedArrayExample
(Example<T> other, ImmutableFeatureMap featureMap, ImmutableOutputInfo<T> outputMap) This constructor removes unknown features.IndexedArrayExample
(IndexedArrayExample<T> other) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a feature.void
addAll
(Collection<? extends Feature> features) Adds a collection of features.boolean
contains
(int i) Does this example contain a feature with id i.copy()
Returns a deep copy of this Example.void
Converts all implicit zeros into explicit zeros based on the supplied feature names.boolean
int
getIdx
(int i) Gets the feature at internal index i.int
Gets the output id dimension number.protected void
growArray
(int minCapacity) Grows the backing arrays storing the names and values.int
hashCode()
Iterator over the feature ids and values.void
reduceByName
(Merger merger) Merges features with the same name using the suppliedMerger
.void
removeFeatures
(List<Feature> featureList) Removes all features in this list from the Example.protected void
sort()
Sorts the feature list to maintain the lexicographic order invariant.Methods inherited from class org.tribuo.impl.ArrayExample
add, canonicalize, copyValues, growArray, iterator, lookup, newCapacity, set, size, toString, transform, validateExample
Methods inherited from class org.tribuo.Example
containsMetadata, densify, getMetadata, getMetadataValue, getOutput, getWeight, setMetadataValue, setWeight
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
featureIDs
-
outputID
-
-
Constructor Details
-
IndexedArrayExample
Copy constructor.- Parameters:
other
- The example to copy.
-
IndexedArrayExample
public IndexedArrayExample(Example<T> other, ImmutableFeatureMap featureMap, ImmutableOutputInfo<T> outputMap) This constructor removes unknown features.- Parameters:
other
- The example to copy from.featureMap
- The feature map.outputMap
- The output info.
-
-
Method Details
-
equals
-
hashCode
-
growArray
Description copied from class:ArrayExample
Grows the backing arrays storing the names and values.- Overrides:
growArray
in classArrayExample<T extends Output<T>>
- Parameters:
minCapacity
- The new minimum capacity required.
-
add
-
addAll
-
sort
Description copied from class:ArrayExample
Sorts the feature list to maintain the lexicographic order invariant.- Overrides:
sort
in classArrayExample<T extends Output<T>>
-
reduceByName
Description copied from class:Example
Merges features with the same name using the suppliedMerger
.- Overrides:
reduceByName
in classArrayExample<T extends Output<T>>
- Parameters:
merger
- A function to merge two doubles.
-
removeFeatures
Description copied from class:Example
Removes all features in this list from the Example.- Overrides:
removeFeatures
in classArrayExample<T extends Output<T>>
- Parameters:
featureList
- Features to remove from this Example.
-
contains
Does this example contain a feature with id i.- Parameters:
i
- The index to check.- Returns:
- True if the example contains the id.
-
copy
-
densify
-
getIdx
Gets the feature at internal index i.- Parameters:
i
- The internal index.- Returns:
- The feature index.
-
getOutputID
-
idIterator
Iterator over the feature ids and values.- Returns:
- The feature ids and values.
-