Package org.tribuo
Class MutableFeatureMap
java.lang.Object
org.tribuo.FeatureMap
org.tribuo.MutableFeatureMap
- All Implemented Interfaces:
Serializable
,Iterable<VariableInfo>
,ProtoSerializable<org.tribuo.protos.core.FeatureDomainProto>
A feature map that can record new feature value observations.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Protobuf serialization version.Fields inherited from class org.tribuo.FeatureMap
m
Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER
-
Constructor Summary
ConstructorDescriptionCreates an empty feature map which converts high cardinality categorical variable infos into reals.MutableFeatureMap
(boolean convertHighCardinality) Creates an empty feature map which can optionally convert high cardinality categorical variable infos into reals. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an occurrence of a feature with a given name.void
clear()
Clears all the feature observations.static MutableFeatureMap
deserializeFromProto
(int version, String className, com.google.protobuf.Any message) Deserialization factory.boolean
int
hashCode()
put
(VariableInfo info) Adds a variable info into the feature map.org.tribuo.protos.core.FeatureDomainProto
Serializes this object to a protobuf.Methods inherited from class org.tribuo.FeatureMap
deserialize, domainEquals, get, iterator, keySet, size, toReadableString, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
CURRENT_VERSION
public static final int CURRENT_VERSIONProtobuf serialization version.- See Also:
-
-
Constructor Details
-
MutableFeatureMap
public MutableFeatureMap()Creates an empty feature map which converts high cardinality categorical variable infos into reals.The conversion threshold is
CategoricalInfo.THRESHOLD
. -
MutableFeatureMap
public MutableFeatureMap(boolean convertHighCardinality) Creates an empty feature map which can optionally convert high cardinality categorical variable infos into reals.The conversion threshold is
CategoricalInfo.THRESHOLD
.- Parameters:
convertHighCardinality
- Should this feature map convert high cardinality categorical variables into real variables?
-
-
Method Details
-
deserializeFromProto
public static MutableFeatureMap deserializeFromProto(int version, String className, com.google.protobuf.Any message) throws com.google.protobuf.InvalidProtocolBufferException Deserialization factory.- Parameters:
version
- The serialized object version.className
- The class name.message
- The serialized data.- Returns:
- The deserialized object.
- Throws:
com.google.protobuf.InvalidProtocolBufferException
- If the protobuf could not be parsed from themessage
.
-
serialize
public org.tribuo.protos.core.FeatureDomainProto serialize()Description copied from interface:ProtoSerializable
Serializes this object to a protobuf.- Returns:
- The protobuf.
-
put
Adds a variable info into the feature map.Returns the old one if there was a name collision, otherwise returns null.
- Parameters:
info
- The info to add.- Returns:
- The old variable info or null.
-
add
Adds an occurrence of a feature with a given name.- Parameters:
name
- the name of the feature.value
- the observed value of that feature.
-
clear
public void clear()Clears all the feature observations. -
equals
- Overrides:
equals
in classFeatureMap
-
hashCode
public int hashCode()- Overrides:
hashCode
in classFeatureMap
-