T
- the type of the features in this example.public class ListExample<T extends Output<T>> extends Example<T> implements Serializable
ArrayExample
.
An example that's a simple list of features. It is not guaranteed that feature instances are preserved.
DEFAULT_METADATA_SIZE, DEFAULT_WEIGHT, metadata, NAME, output, weight
Constructor and Description |
---|
ListExample(Example<T> other) |
ListExample(T output) |
ListExample(T output,
float weight) |
ListExample(T output,
List<? extends Feature> features) |
ListExample(T output,
String[] featureNames,
double[] featureValues) |
Modifier and Type | Method and Description |
---|---|
void |
add(Feature feature)
Adds a feature.
|
void |
addAll(Collection<? extends Feature> features)
Adds a collection of features.
|
void |
canonicalize(FeatureMap featureMap)
Reassigns feature name Strings in the Example to point to those in the
FeatureMap . |
void |
clear() |
ListExample<T> |
copy()
Returns a deep copy of this Example.
|
protected void |
densify(List<String> featureList)
Converts all implicit zeros into explicit zeros based on the supplied feature names.
|
boolean |
equals(Object o) |
int |
hashCode() |
Iterator<Feature> |
iterator() |
Feature |
lookup(String i)
Returns the Feature in this Example which has the supplied name, if it's present.
|
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.
|
void |
set(Feature feature)
Overwrites the feature with the matching name.
|
int |
size()
Return how many features are in this example.
|
protected void |
sort()
Sorts the feature list to maintain the lexicographic order invariant.
|
String |
toString() |
void |
transform(TransformerMap transformerMap)
Transforms this example by applying the transformations from the supplied
TransformerMap . |
boolean |
validateExample()
Checks the example to see if all the feature names are unique,
the feature values are not NaN, and there is at least one feature.
|
containsMetadata, densify, getMetadata, getMetadataValue, getOutput, getWeight, setMetadataValue, setWeight
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public ListExample(T output, float weight)
public ListExample(T output)
public void add(Feature feature)
Example
public void addAll(Collection<? extends Feature> features)
Example
public void clear()
public int size()
Example
public ListExample<T> copy()
Example
protected void sort()
public void removeFeatures(List<Feature> featureList)
Example
removeFeatures
in class Example<T extends Output<T>>
featureList
- Features to remove from this Example.public void reduceByName(Merger merger)
Example
Merger
.reduceByName
in class Example<T extends Output<T>>
merger
- A function to merge two doubles.public Feature lookup(String i)
Example
public void set(Feature feature)
Example
Throws IllegalArgumentException
if there isn't a feature with that
name in this example.
public boolean validateExample()
Example
validateExample
in class Example<T extends Output<T>>
public void transform(TransformerMap transformerMap)
Example
TransformerMap
.
Can be overridden for performance reasons.
protected void densify(List<String> featureList)
Example
public void canonicalize(FeatureMap featureMap)
Example
FeatureMap
.
This significantly reduces memory allocation. It is called when an Example is added
to a MutableDataset
, and should not be called outside of that context as it may interact
unexpectedly with HashedFeatureMap
.canonicalize
in class Example<T extends Output<T>>
featureMap
- The feature map containing canonical feature names.Copyright © 2015–2021 Oracle and/or its affiliates. All rights reserved.