Class MultinomialNaiveBayesTrainer

java.lang.Object
org.tribuo.classification.mnb.MultinomialNaiveBayesTrainer
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<org.tribuo.provenance.TrainerProvenance>, org.tribuo.Trainer<Label>, org.tribuo.WeightedExamples

public class MultinomialNaiveBayesTrainer extends Object implements org.tribuo.Trainer<Label>, org.tribuo.WeightedExamples
A Trainer which trains a multinomial Naive Bayes model with Laplace smoothing.

All feature values must be non-negative.

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.
 
  • Field Summary

    Fields inherited from interface org.tribuo.Trainer

    DEFAULT_SEED, INCREMENT_INVOCATION_COUNT
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a multinomial naive bayes trainer using a smoothing value of 1.0.
    Constructs a multinomial naive bayes trainer with the specified smoothing value.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    org.tribuo.provenance.TrainerProvenance
     
    void
    setInvocationCount(int invocationCount)
     
     
    org.tribuo.Model<Label>
    train(org.tribuo.Dataset<Label> examples, Map<String, com.oracle.labs.mlrg.olcut.provenance.Provenance> runProvenance)
     
    org.tribuo.Model<Label>
    train(org.tribuo.Dataset<Label> examples, Map<String, com.oracle.labs.mlrg.olcut.provenance.Provenance> runProvenance, int invocationCount)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.oracle.labs.mlrg.olcut.config.Configurable

    postConfig

    Methods inherited from interface org.tribuo.Trainer

    train
  • Constructor Details

    • MultinomialNaiveBayesTrainer

      Constructs a multinomial naive bayes trainer using a smoothing value of 1.0.
    • MultinomialNaiveBayesTrainer

      public MultinomialNaiveBayesTrainer(double alpha)
      Constructs a multinomial naive bayes trainer with the specified smoothing value.
      Parameters:
      alpha - The smoothing value.
  • Method Details

    • train

      public org.tribuo.Model<Label> train(org.tribuo.Dataset<Label> examples, Map<String, com.oracle.labs.mlrg.olcut.provenance.Provenance> runProvenance)
      Specified by:
      train in interface org.tribuo.Trainer<Label>
    • train

      public org.tribuo.Model<Label> train(org.tribuo.Dataset<Label> examples, Map<String, com.oracle.labs.mlrg.olcut.provenance.Provenance> runProvenance, int invocationCount)
      Specified by:
      train in interface org.tribuo.Trainer<Label>
    • getInvocationCount

      public int getInvocationCount()
      Specified by:
      getInvocationCount in interface org.tribuo.Trainer<Label>
    • setInvocationCount

      public void setInvocationCount(int invocationCount)
      Specified by:
      setInvocationCount in interface org.tribuo.Trainer<Label>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getProvenance

      public org.tribuo.provenance.TrainerProvenance getProvenance()
      Specified by:
      getProvenance in interface com.oracle.labs.mlrg.olcut.provenance.Provenancable<org.tribuo.provenance.TrainerProvenance>