public class IndexedArrayExample<T extends Output<T>> extends ArrayExample<T>
Used in feature selection to provide log n lookups. May be used elsewhere in the future as a performance optimisation.
Modifier and Type | Class and Description |
---|---|
static class |
IndexedArrayExample.FeatureTuple
A tuple of the feature name, id and value.
|
Modifier and Type | Field and Description |
---|---|
protected int[] |
featureIDs |
protected int |
outputID |
DEFAULT_SIZE, featureNames, featureValues, size
DEFAULT_METADATA_SIZE, DEFAULT_WEIGHT, metadata, NAME, output, weight
Constructor and Description |
---|
IndexedArrayExample(Example<T> other,
ImmutableFeatureMap featureMap,
ImmutableOutputInfo<T> outputMap)
This constructor removes unknown features.
|
IndexedArrayExample(IndexedArrayExample<T> other)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Feature feature)
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.
|
IndexedArrayExample<T> |
copy()
Returns a deep copy of this Example.
|
void |
densify(List<String> featureList)
Converts all implicit zeros into explicit zeros based on the supplied feature names.
|
boolean |
equals(Object o) |
int |
getIdx(int i)
Gets the feature at internal index i.
|
int |
getOutputID()
Gets the output id dimension number.
|
protected void |
growArray(int minCapacity)
Grows the backing arrays storing the names and values.
|
int |
hashCode() |
Iterable<IndexedArrayExample.FeatureTuple> |
idIterator()
Iterator over the feature ids and values.
|
void |
reduceByName(Merger merger)
Merges features with the same name using the
supplied
Merger . |
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.
|
add, canonicalize, copyValues, growArray, iterator, lookup, newCapacity, set, size, toString, transform, validateExample
containsMetadata, densify, getMetadata, getMetadataValue, getOutput, getWeight, setMetadataValue, setWeight
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public IndexedArrayExample(IndexedArrayExample<T> other)
other
- The example to copy.public IndexedArrayExample(Example<T> other, ImmutableFeatureMap featureMap, ImmutableOutputInfo<T> outputMap)
other
- The example to copy from.featureMap
- The feature map.outputMap
- The output info.public int hashCode()
hashCode
in class ArrayExample<T extends Output<T>>
protected void growArray(int minCapacity)
ArrayExample
growArray
in class ArrayExample<T extends Output<T>>
minCapacity
- The new minimum capacity required.public void add(Feature feature)
Example
add
in class ArrayExample<T extends Output<T>>
feature
- The feature to add.public void addAll(Collection<? extends Feature> features)
Example
addAll
in class ArrayExample<T extends Output<T>>
features
- The features to add.protected void sort()
ArrayExample
sort
in class ArrayExample<T extends Output<T>>
public void reduceByName(Merger merger)
Example
Merger
.reduceByName
in class ArrayExample<T extends Output<T>>
merger
- A function to merge two doubles.public void removeFeatures(List<Feature> featureList)
Example
removeFeatures
in class ArrayExample<T extends Output<T>>
featureList
- Features to remove from this Example.public boolean contains(int i)
i
- The index to check.public IndexedArrayExample<T> copy()
Example
copy
in class ArrayExample<T extends Output<T>>
public void densify(List<String> featureList)
Example
densify
in class ArrayExample<T extends Output<T>>
featureList
- A *sorted* list of feature names.public int getIdx(int i)
i
- The internal index.public int getOutputID()
public Iterable<IndexedArrayExample.FeatureTuple> idIterator()
Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.