MOA 12.03
Real Time Analytics for Data Streams
moa.classifiers.bayes.NaiveBayesMultinomial Class Reference

Class for building and using a multinomial Naive Bayes classifier. More...

Inheritance diagram for moa.classifiers.bayes.NaiveBayesMultinomial:
Collaboration diagram for moa.classifiers.bayes.NaiveBayesMultinomial:

List of all members.

Public Member Functions

String getPurposeString ()
 Gets the purpose of this object.
void resetLearningImpl ()
 Resets this classifier.
void trainOnInstanceImpl (Instance inst)
 Trains the classifier with the given instance.
double[] getVotesForInstance (Instance instance)
 Calculates the class membership probabilities for the given test instance.
double totalSize (Instance instance)
void getModelDescription (StringBuilder result, int indent)
 Returns a string representation of the model.
boolean isRandomizable ()
 Gets whether this classifier needs a random seed.

Public Attributes

FloatOption laplaceCorrectionOption

Protected Member Functions

Measurement[] getModelMeasurementsImpl ()
 Gets the current measurements of this classifier.

Protected Attributes

double[] m_classTotals
 sum of weight_of_instance * word_count_of_instance for each class
Instances m_headerInfo
 copy of header information for use in toString method
int m_numClasses
 number of class values
double[] m_probOfClass
 the probability of a class (i.e.
double[][] m_wordTotalForClass
 probability that a word (w) exists in a class (H) (i.e.
boolean reset = false

Detailed Description

Class for building and using a multinomial Naive Bayes classifier.

Performs text classic bayesian prediction while making naive assumption that all inputs are independent. For more information see,

Andrew Mccallum, Kamal Nigam: A Comparison of Event Models for Naive Bayes Text Classification. In: AAAI-98 Workshop on 'Learning for Text Categorization', 1998.

The core equation for this classifier:

P[Ci|D] = (P[D|Ci] x P[Ci]) / P[D] (Bayes rule)

where Ci is class i and D is a document.

Incremental version of the algorithm.

* BibTeX:

 @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}
 }
 

Definition at line 54 of file NaiveBayesMultinomial.java.


Member Function Documentation

void moa.classifiers.bayes.NaiveBayesMultinomial.getModelDescription ( StringBuilder  out,
int  indent 
) [virtual]

Returns a string representation of the model.

Parameters:
outthe stringbuilder to add the description
indentthe number of characters to indent

Implements moa.classifiers.AbstractClassifier.

Definition at line 205 of file NaiveBayesMultinomial.java.

Here is the call graph for this function:

Measurement [] moa.classifiers.bayes.NaiveBayesMultinomial.getModelMeasurementsImpl ( ) [protected, virtual]

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. Note that this will produce compiler errors if not overridden.

Returns:
an array of measurements to be used in evaluation tasks

Implements moa.classifiers.AbstractClassifier.

Definition at line 200 of file NaiveBayesMultinomial.java.

String moa.classifiers.bayes.NaiveBayesMultinomial.getPurposeString ( )

Gets the purpose of this object.

Returns:
the string with the purpose of this object

Reimplemented from moa.classifiers.AbstractClassifier.

Definition at line 66 of file NaiveBayesMultinomial.java.

double [] moa.classifiers.bayes.NaiveBayesMultinomial.getVotesForInstance ( Instance  instance)

Calculates the class membership probabilities for the given test instance.

Parameters:
instancethe instance to be classified
Returns:
predicted class probability distribution

Implements moa.classifiers.Classifier.

Definition at line 153 of file NaiveBayesMultinomial.java.

Here is the call graph for this function:

boolean moa.classifiers.bayes.NaiveBayesMultinomial.isRandomizable ( )

Gets whether this classifier needs a random seed.

Examples of methods that needs a random seed are bagging and boosting.

Returns:
true if the classifier needs a random seed.

Implements moa.classifiers.Classifier.

Definition at line 239 of file NaiveBayesMultinomial.java.

void moa.classifiers.bayes.NaiveBayesMultinomial.resetLearningImpl ( ) [virtual]

Resets this classifier.

It must be similar to starting a new classifier from scratch.

The reason for ...Impl methods: ease programmer burden by not requiring them to remember calls to super in overridden methods. Note that this will produce compiler errors if not overridden.

Implements moa.classifiers.AbstractClassifier.

Definition at line 99 of file NaiveBayesMultinomial.java.

double moa.classifiers.bayes.NaiveBayesMultinomial.totalSize ( Instance  instance)
void moa.classifiers.bayes.NaiveBayesMultinomial.trainOnInstanceImpl ( Instance  inst) [virtual]

Trains the classifier with the given instance.

Parameters:
instancethe new training instance to include in the model

Implements moa.classifiers.AbstractClassifier.

Definition at line 109 of file NaiveBayesMultinomial.java.

Here is the call graph for this function:


Member Data Documentation

Initial value:
 new FloatOption("laplaceCorrection",
            'l', "Laplace correction factor.",
            1.0, 0.00, Integer.MAX_VALUE)

Definition at line 56 of file NaiveBayesMultinomial.java.

Referenced by moa.classifiers.bayes.NaiveBayesMultinomial.trainOnInstanceImpl().

copy of header information for use in toString method

Definition at line 78 of file NaiveBayesMultinomial.java.

Referenced by moa.classifiers.bayes.NaiveBayesMultinomial.getModelDescription().

probability that a word (w) exists in a class (H) (i.e.

Pr[w|H]) The matrix is in the this format: m_wordTotalForClass[wordAttribute][class]

Definition at line 94 of file NaiveBayesMultinomial.java.

Referenced by moa.classifiers.bayes.NaiveBayesMultinomial.getModelDescription(), moa.classifiers.bayes.NaiveBayesMultinomial.getVotesForInstance(), and moa.classifiers.bayes.NaiveBayesMultinomial.trainOnInstanceImpl().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Enumerations