Class DefaultFeatureExtractor
java.lang.Object
org.tribuo.classification.sequence.viterbi.DefaultFeatureExtractor
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable,com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>,Serializable,LabelFeatureExtractor,ProtoSerializable<org.tribuo.classification.protos.LabelFeatureExtractorProto>
A label feature extractor that produces several kinds of label-based features.
The options are: the most recent output, the least recent output, recent bigrams, recent trigrams, recent 4-grams.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intProtobuf serialization version.Fields inherited from interface org.tribuo.protos.ProtoSerializable
DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a default feature extractor for bigrams and trigrams using the past 3 outcomes.DefaultFeatureExtractor(int mostRecentOutcome, int leastRecentOutcome, boolean useBigram, boolean useTrigram, boolean use4gram) Constructs a default feature extractor using the supplied parameters. -
Method Summary
Modifier and TypeMethodDescriptionstatic DefaultFeatureExtractordeserializeFromProto(int version, String className, com.google.protobuf.Any message) Deserialization factory.extractFeatures(List<Label> previousOutcomes, double value) Generates features based on the previously produced labels.com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenanceorg.tribuo.classification.protos.LabelFeatureExtractorProtoSerializes this object to a protobuf.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.oracle.labs.mlrg.olcut.config.Configurable
postConfig
-
Field Details
-
CURRENT_VERSION
public static final int CURRENT_VERSIONProtobuf serialization version.- See Also:
-
-
Constructor Details
-
DefaultFeatureExtractor
public DefaultFeatureExtractor()Constructs a default feature extractor for bigrams and trigrams using the past 3 outcomes. -
DefaultFeatureExtractor
public DefaultFeatureExtractor(int mostRecentOutcome, int leastRecentOutcome, boolean useBigram, boolean useTrigram, boolean use4gram) Constructs a default feature extractor using the supplied parameters.- Parameters:
mostRecentOutcome- The most recent outcome to include as a feature.leastRecentOutcome- The least recent outcome to include as a feature.useBigram- Use bigrams of the outcomes.useTrigram- Use trigrams of the outcomes.use4gram- Use 4-grams of the outcomes.
-
-
Method Details
-
deserializeFromProto
public static DefaultFeatureExtractor 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.
-
toString
-
extractFeatures
Description copied from interface:LabelFeatureExtractorGenerates features based on the previously produced labels.- Specified by:
extractFeaturesin interfaceLabelFeatureExtractor- Parameters:
previousOutcomes- The previous step's labels.value- The value to give to the features.- Returns:
- Features.
-
getProvenance
public com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance getProvenance()- Specified by:
getProvenancein interfacecom.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>
-
serialize
public org.tribuo.classification.protos.LabelFeatureExtractorProto serialize()Description copied from interface:ProtoSerializableSerializes this object to a protobuf.- Specified by:
serializein interfaceProtoSerializable<org.tribuo.classification.protos.LabelFeatureExtractorProto>- Returns:
- The protobuf.
-