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>

public class MutableFeatureMap extends FeatureMap
A feature map that can record new feature value observations.
See Also:
  • Field Details

    • CURRENT_VERSION

      public static final int CURRENT_VERSION
      Protobuf 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 the message.
    • serialize

      public org.tribuo.protos.core.FeatureDomainProto serialize()
      Description copied from interface: ProtoSerializable
      Serializes this object to a protobuf.
      Returns:
      The protobuf.
    • put

      public VariableInfo put(VariableInfo info)
      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

      public void add(String name, double value)
      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

      public boolean equals(Object o)
      Overrides:
      equals in class FeatureMap
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class FeatureMap