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 TypeMethodDescriptionvoidAdds a feature.voidaddAll(Collection<? extends Feature> features) Adds a collection of features.voidcanonicalize(FeatureMap featureMap) Reassigns feature name Strings in the Example to point to those in theFeatureMap.voidclear()copy()Returns a deep copy of this Example.protected voidConverts all implicit zeros into explicit zeros based on the supplied feature names.booleaninthashCode()booleanisDense(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.voidreduceByName(Merger merger) Merges features with the same name using the suppliedMerger.voidremoveFeatures(List<Feature> featureList) Removes all features in this list from the Example.voidOverwrites the feature with the matching name.intsize()Return how many features are in this example.protected voidsort()Sorts the feature list to maintain the lexicographic order invariant.toString()voidtransform(TransformerMap transformerMap) Transforms this example by applying the transformations from the suppliedTransformerMap.booleanChecks 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, setWeightMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ListExample
-
ListExample
-
ListExample
-
ListExample
-
ListExample
-
-
Method Details
-
add
-
addAll
Description copied from class:ExampleAdds 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:ExampleOverwrites the feature with the matching name.Throws
IllegalArgumentExceptionif there isn't a feature with that name in this example. -
validateExample
public boolean validateExample()Description copied from class:ExampleChecks 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:
validateExamplein classExample<T extends Output<T>>- Returns:
- true if the example is valid.
-
transform
Description copied from class:ExampleTransforms this example by applying the transformations from the suppliedTransformerMap.Can be overridden for performance reasons.
-
isDense
Description copied from class:ExampleIs 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:ExampleReassigns 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:
canonicalizein classExample<T extends Output<T>>- Parameters:
featureMap- The feature map containing canonical feature names.
-
equals
-
hashCode
-