public class NaiveBayesMultinomial extends AbstractClassifier implements MultiClassClassifier
@inproceedings{Mccallum1998, author = {Andrew Mccallum and Kamal Nigam}, booktitle = {AAAI-98 Workshop on 'Learning for Text Categorization'}, title = {A Comparison of Event Models for Naive Bayes Text Classification}, year = {1998} }
Modifier and Type | Field and Description |
---|---|
FloatOption |
laplaceCorrectionOption |
protected double[] |
m_classTotals
sum of weight_of_instance * word_count_of_instance for each class
|
protected Instances |
m_headerInfo
copy of header information for use in toString method
|
protected int |
m_numClasses
number of class values
|
protected double[] |
m_probOfClass
the probability of a class (i.e.
|
protected DoubleVector[] |
m_wordTotalForClass
probability that a word (w) exists in a class (H) (i.e.
|
protected boolean |
reset |
classifierRandom, downSampleRatio, modelContext, randomSeed, randomSeedOption, trainingWeightSeenByModel
config
Constructor and Description |
---|
NaiveBayesMultinomial() |
Modifier and Type | Method and Description |
---|---|
void |
getModelDescription(StringBuilder result,
int indent)
Returns a string representation of the model.
|
protected Measurement[] |
getModelMeasurementsImpl()
Gets the current measurements of this classifier.
The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. |
String |
getPurposeString()
Dictionary with option texts and objects
|
double[] |
getVotesForInstance(Instance instance)
Calculates the class membership probabilities for the given test
instance.
|
boolean |
isRandomizable()
Gets whether this learner needs a random seed.
|
void |
resetLearningImpl()
Resets this classifier.
|
double |
totalSize(Instance instance) |
void |
trainOnInstanceImpl(Instance inst)
Trains the classifier with the given instance.
|
contextIsCompatible, copy, correctlyClassifies, getAttributeNameString, getAWTRenderer, getClassLabelString, getClassNameString, getDescription, getDownSampleRatio, getModel, getModelContext, getModelMeasurements, getNominalValueString, getPredictionForInstance, getPredictionForInstance, getSubClassifiers, getSublearners, getVotesForInstance, modelAttIndexToInstanceAttIndex, modelAttIndexToInstanceAttIndex, prepareForUseImpl, resetLearning, setModelContext, setRandomSeed, trainingHasStarted, trainingWeightSeenByModel, trainOnInstance, trainOnInstance, updateDownSampleRatio
getCLICreationString, getOptions, getPreparedClassOption, prepareClassOptions, prepareForUse, prepareForUse
copy, measureByteSize, measureByteSize, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCLICreationString, getOptions, prepareForUse, prepareForUse
measureByteSize
public FloatOption laplaceCorrectionOption
protected double[] m_classTotals
protected Instances m_headerInfo
protected int m_numClasses
protected double[] m_probOfClass
protected DoubleVector[] m_wordTotalForClass
protected boolean reset
public String getPurposeString()
AbstractOptionHandler
getPurposeString
in interface OptionHandler
getPurposeString
in class AbstractClassifier
public void resetLearningImpl()
AbstractClassifier
resetLearningImpl
in class AbstractClassifier
public void trainOnInstanceImpl(Instance inst)
trainOnInstanceImpl
in class AbstractClassifier
instance
- the new training instance to include in the modelpublic double[] getVotesForInstance(Instance instance)
getVotesForInstance
in interface Classifier
getVotesForInstance
in class AbstractClassifier
instance
- the instance to be classifiedpublic double totalSize(Instance instance)
protected Measurement[] getModelMeasurementsImpl()
AbstractClassifier
getModelMeasurementsImpl
in class AbstractClassifier
public void getModelDescription(StringBuilder result, int indent)
AbstractClassifier
getModelDescription
in class AbstractClassifier
result
- the stringbuilder to add the descriptionindent
- the number of characters to indentpublic boolean isRandomizable()
Learner
isRandomizable
in interface Learner<Example<Instance>>
Copyright © 2019 University of Waikato, Hamilton, NZ. All Rights Reserved.