Class NaiveBayesTrainer

java.lang.Object
opennlp.tools.ml.AbstractTrainer<opennlp.tools.util.TrainingParameters>
opennlp.tools.ml.AbstractEventTrainer<opennlp.tools.util.TrainingParameters>
opennlp.tools.ml.naivebayes.NaiveBayesTrainer
All Implemented Interfaces:
opennlp.tools.commons.Trainer<opennlp.tools.util.TrainingParameters>, opennlp.tools.ml.EventTrainer<opennlp.tools.util.TrainingParameters>

public class NaiveBayesTrainer extends opennlp.tools.ml.AbstractEventTrainer<opennlp.tools.util.TrainingParameters>
Trains models using the combination of EM algorithm and Naive Bayes classifier which is described in:

Text Classification from Labeled and Unlabeled Documents using EM Nigam, McCallum, et al. paper of 2000

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     

    Fields inherited from class opennlp.tools.ml.AbstractEventTrainer

    DATA_INDEXER_ONE_PASS_REAL_VALUE, DATA_INDEXER_ONE_PASS_VALUE, DATA_INDEXER_PARAM, DATA_INDEXER_TWO_PASS_VALUE

    Fields inherited from interface opennlp.tools.ml.EventTrainer

    EVENT_VALUE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiates a NaiveBayesTrainer with default training parameters.
    NaiveBayesTrainer(opennlp.tools.util.TrainingParameters parameters)
    Instantiates a NaiveBayesTrainer with specific TrainingParameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    opennlp.tools.ml.model.AbstractModel
    doTrain(opennlp.tools.ml.model.DataIndexer<opennlp.tools.util.TrainingParameters> indexer)
     
    boolean
     
    opennlp.tools.ml.model.AbstractModel
    trainModel(opennlp.tools.ml.model.DataIndexer<opennlp.tools.util.TrainingParameters> di)
    Trains a NaiveBayesModel with given parameters.

    Methods inherited from class opennlp.tools.ml.AbstractEventTrainer

    getDataIndexer, train, train, validate

    Methods inherited from class opennlp.tools.ml.AbstractTrainer

    getAlgorithm, getCutoff, getIterations, getTrainingConfiguration, init, init

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface opennlp.tools.commons.Trainer

    init, init
  • Field Details

  • Constructor Details

    • NaiveBayesTrainer

      public NaiveBayesTrainer()
      Instantiates a NaiveBayesTrainer with default training parameters.
    • NaiveBayesTrainer

      public NaiveBayesTrainer(opennlp.tools.util.TrainingParameters parameters)
      Instantiates a NaiveBayesTrainer with specific TrainingParameters.
      Parameters:
      parameters - The parameter to use.
  • Method Details

    • isSortAndMerge

      public boolean isSortAndMerge()
      Specified by:
      isSortAndMerge in class opennlp.tools.ml.AbstractEventTrainer<opennlp.tools.util.TrainingParameters>
    • doTrain

      public opennlp.tools.ml.model.AbstractModel doTrain(opennlp.tools.ml.model.DataIndexer<opennlp.tools.util.TrainingParameters> indexer) throws IOException
      Specified by:
      doTrain in class opennlp.tools.ml.AbstractEventTrainer<opennlp.tools.util.TrainingParameters>
      Throws:
      IOException
    • trainModel

      public opennlp.tools.ml.model.AbstractModel trainModel(opennlp.tools.ml.model.DataIndexer<opennlp.tools.util.TrainingParameters> di)
      Trains a NaiveBayesModel with given parameters.
      Parameters:
      di - The DataIndexer used as data input.
      Returns:
      A valid, trained Naive Bayes model.