Class ListExample<T extends Output<T>>
java.lang.Object
org.tribuo.Example<T>
org.tribuo.impl.ListExample<T>
- Type Parameters:
T
- the type of the features in this example.
- All Implemented Interfaces:
Serializable
,Iterable<Feature>
This class will not be performant until value types are available in Java. Prefer
ArrayExample
.
An example that's a simple list of features. It is not guaranteed that feature instances are preserved.
- See Also:
-
Field Summary
Fields inherited from class org.tribuo.Example
DEFAULT_METADATA_SIZE, DEFAULT_WEIGHT, metadata, NAME, output, weight
-
Constructor Summary
ConstructorsConstructorDescriptionListExample
(Example<T> other) ListExample
(T output) ListExample
(T output, float weight) ListExample
(T output, String[] featureNames, double[] featureValues) ListExample
(T output, List<? extends Feature> features) -
Method Summary
Modifier and TypeMethodDescriptionvoid
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 theFeatureMap
.void
clear()
copy()
Returns a deep copy of this Example.protected void
Converts all implicit zeros into explicit zeros based on the supplied feature names.boolean
int
hashCode()
boolean
isDense
(FeatureMap fMap) Is this example dense wrt the supplied feature map.iterator()
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 suppliedMerger
.void
removeFeatures
(List<Feature> featureList) Removes all features in this list from the Example.void
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.toString()
void
transform
(TransformerMap transformerMap) Transforms this example by applying the transformations from the suppliedTransformerMap
.boolean
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.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
-
Constructor Details
-
ListExample
-
ListExample
-
ListExample
-
ListExample
-
ListExample
-
-
Method Details
-
add
-
addAll
Description copied from class:Example
Adds a collection of features. This maintains the sorted invariant but is more efficient than adding one at a time due to allocation. -
clear
public void clear() -
size
-
copy
-
iterator
-
toString
-
sort
-
removeFeatures
-
reduceByName
-
lookup
-
set
Description copied from class:Example
Overwrites the feature with the matching name.Throws
IllegalArgumentException
if there isn't a feature with that name in this example. -
validateExample
public boolean validateExample()Description copied from class:Example
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.- Specified by:
validateExample
in classExample<T extends Output<T>>
- Returns:
- true if the example is valid.
-
transform
Description copied from class:Example
Transforms this example by applying the transformations from the suppliedTransformerMap
.Can be overridden for performance reasons.
-
isDense
Description copied from class:Example
Is this example dense wrt the supplied feature map.An example is "dense" if it contains all the features in the map, and only those features.
-
densify
-
canonicalize
Description copied from class:Example
Reassigns feature name Strings in the Example to point to those in theFeatureMap
. This significantly reduces memory allocation. It is called when an Example is added to aMutableDataset
, and should not be called outside of that context as it may interact unexpectedly withHashedFeatureMap
.- Specified by:
canonicalize
in classExample<T extends Output<T>>
- Parameters:
featureMap
- The feature map containing canonical feature names.
-
equals
-
hashCode
-