Class MultinomialNaiveBayesModel

java.lang.Object
org.tribuo.Model<Label>
org.tribuo.classification.mnb.MultinomialNaiveBayesModel
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.provenance.Provenancable<org.tribuo.provenance.ModelProvenance>, Serializable, org.tribuo.protos.ProtoSerializable<org.tribuo.protos.core.ModelProto>

public class MultinomialNaiveBayesModel extends org.tribuo.Model<Label>
A Model for multinomial Naive Bayes with Laplace smoothing.

All feature values must be non-negative, otherwise it will throw IllegalArgumentException.

See:

 Wang S, Manning CD.
 "Baselines and Bigrams: Simple, Good Sentiment and Topic Classification"
 Proceedings of the 50th Annual Meeting of the Association for Computational Linguistics, 2012.
 
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Protobuf serialization version.

    Fields inherited from class org.tribuo.Model

    ALL_OUTPUTS, BIAS_FEATURE, featureIDMap, generatesProbabilities, name, outputIDInfo, provenance, provenanceOutput

    Fields inherited from interface org.tribuo.protos.ProtoSerializable

    DESERIALIZATION_METHOD_NAME, PROVENANCE_SERIALIZER
  • Method Summary

    Modifier and Type
    Method
    Description
    copy(String newName, org.tribuo.provenance.ModelProvenance newProvenance)
     
    deserializeFromProto(int version, String className, com.google.protobuf.Any message)
    Deserialization factory.
    Optional<org.tribuo.Excuse<Label>>
    getExcuse(org.tribuo.Example<Label> example)
     
    Map<String, List<com.oracle.labs.mlrg.olcut.util.Pair<String,Double>>>
     
    org.tribuo.Prediction<Label>
    predict(org.tribuo.Example<Label> example)
     
    org.tribuo.protos.core.ModelProto
     

    Methods inherited from class org.tribuo.Model

    castModel, copy, createDataCarrier, deserialize, deserializeFromFile, deserializeFromStream, generatesProbabilities, getExcuses, getFeatureIDMap, getName, getOutputIDInfo, getProvenance, innerPredict, predict, predict, serializeToFile, serializeToStream, setName, toString, validate

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Method Details

    • deserializeFromProto

      public static MultinomialNaiveBayesModel 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.
    • predict

      public org.tribuo.Prediction<Label> predict(org.tribuo.Example<Label> example)
      Specified by:
      predict in class org.tribuo.Model<Label>
    • getTopFeatures

      public Map<String, List<com.oracle.labs.mlrg.olcut.util.Pair<String,Double>>> getTopFeatures(int n)
      Specified by:
      getTopFeatures in class org.tribuo.Model<Label>
    • getExcuse

      public Optional<org.tribuo.Excuse<Label>> getExcuse(org.tribuo.Example<Label> example)
      Specified by:
      getExcuse in class org.tribuo.Model<Label>
    • copy

      protected MultinomialNaiveBayesModel copy(String newName, org.tribuo.provenance.ModelProvenance newProvenance)
      Specified by:
      copy in class org.tribuo.Model<Label>
    • serialize

      public org.tribuo.protos.core.ModelProto serialize()
      Specified by:
      serialize in interface org.tribuo.protos.ProtoSerializable<org.tribuo.protos.core.ModelProto>
      Overrides:
      serialize in class org.tribuo.Model<Label>