Class FeatureMap
java.lang.Object
org.tribuo.FeatureMap
- All Implemented Interfaces:
Serializable,Iterable<VariableInfo>,ProtoSerializable<org.tribuo.protos.core.FeatureDomainProto>
- Direct Known Subclasses:
ImmutableFeatureMap,MutableFeatureMap
public abstract class FeatureMap
extends Object
implements Serializable, ProtoSerializable<org.tribuo.protos.core.FeatureDomainProto>, Iterable<VariableInfo>
A map from Strings to
VariableInfo objects storing
information about a feature.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<String, VariableInfo> Map from the feature names to their info.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs an empty feature map.protectedFeatureMap(Map<String, ? extends VariableInfo> m) Constructs a feature map wrapping the supplied map.protectedFeatureMap(FeatureMap map) Constructs a deep copy of the supplied feature map. -
Method Summary
Modifier and TypeMethodDescriptionstatic FeatureMapdeserialize(org.tribuo.protos.core.FeatureDomainProto proto) Deserializes aFeatureDomainProtointo aFeatureMapsubclass.booleandomainEquals(FeatureMap other) Check if this feature map contains the same features as the supplied one.booleanGets the variable info associated with that feature name, or null if it's unknown.inthashCode()iterator()keySet()Returns all the feature names in the domain.intsize()Returns the number of features in the domain.Same as the toString, but ordered by name, and with newlines.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.tribuo.protos.ProtoSerializable
serialize
-
Field Details
-
m
Map from the feature names to their info.
-
-
Constructor Details
-
FeatureMap
protected FeatureMap()Constructs an empty feature map. -
FeatureMap
Constructs a deep copy of the supplied feature map.- Parameters:
map- The map to copy.
-
FeatureMap
Constructs a feature map wrapping the supplied map.Note the map is not defensively copied.
- Parameters:
m- The map to wrap.
-
-
Method Details
-
get
Gets the variable info associated with that feature name, or null if it's unknown.- Parameters:
name- The feature name.- Returns:
- The variable info or null.
-
size
public int size()Returns the number of features in the domain.- Returns:
- The number of features.
-
toString
-
keySet
-
iterator
- Specified by:
iteratorin interfaceIterable<VariableInfo>
-
equals
-
hashCode
-
toReadableString
Same as the toString, but ordered by name, and with newlines.- Returns:
- A String representation of this FeatureMap.
-
domainEquals
Check if this feature map contains the same features as the supplied one.- Parameters:
other- The feature map to check.- Returns:
- True if the two feature maps contain the same named features.
-
deserialize
Deserializes aFeatureDomainProtointo aFeatureMapsubclass.- Parameters:
proto- The proto to deserialize.- Returns:
- The deserialized FeatureMap.
-