Public Member Functions | Data Fields

MultinomialNaiveBayes Class Reference

Implementation of the Multinomial Naive Bayes classifier similar to the one that is described in Manning, et al. More...

Inheritance diagram for MultinomialNaiveBayes:
Inheritance graph
[legend]
Collaboration diagram for MultinomialNaiveBayes:
Collaboration graph
[legend]

Public Member Functions

 __construct ()
 Default constructor.
 train (array &$dataTrain, array &$dataLabel)
 setDatabase ($name)
 save ()
 classify ($dataTest)
 Bayes decision rule.

Data Fields

const tabPriorName = "prior"
 Name of the table for the prior probabilities.
const tabCondName = "cond"
 Name of the table for the conditional probabilities.

Detailed Description

Implementation of the Multinomial Naive Bayes classifier similar to the one that is described in Manning, et al.

(2008).

Instead of computing counts of documents for the priors, this MultinomialNaiveBayes uses sums of class-wise term frequencies. The rationale behind this decision is that the overall amount of instances should not influence the prior term, in favour of the overall amount of actual terms in the text. By following this criterion, a class with 1 sentence/instance and N instances would be comparable to another class with one single instance composed of N sentences, regarding the amount of information that they may contain.

--
(Manning, et al., 2008) Manning, C. D., Raghavan, P. and Schutze, H., "Introduction to Information Retrieval", Cambridge: Cambridge University Press, 2008, ISBN: 0521865719

Author:
Alexandre Trilla (atrilla)

Definition at line 64 of file MultinomialNaiveBayes.php.


Constructor & Destructor Documentation

MultinomialNaiveBayes::__construct (  ) 

Default constructor.

Postcondition:
Initialises the classifier with a tokeniser.

Definition at line 101 of file MultinomialNaiveBayes.php.


Member Function Documentation

MultinomialNaiveBayes::classify ( dataTest  ) 

Bayes decision rule.

See also:
Classifier::classify(&$dataTest)

Implements Classifier.

Definition at line 231 of file MultinomialNaiveBayes.php.

References getConnection(), Classifier::OOV, tabCondName, and tabPriorName.

MultinomialNaiveBayes::save (  ) 
See also:
Classifier::save()

Implements Classifier.

Definition at line 190 of file MultinomialNaiveBayes.php.

References getConnection(), tabCondName, and tabPriorName.

MultinomialNaiveBayes::setDatabase ( name  ) 
See also:
Classifier::setDatabase($name)

Implements Classifier.

Definition at line 178 of file MultinomialNaiveBayes.php.

References getPrefixID().

MultinomialNaiveBayes::train ( array &$  dataTrain,
array &$  dataLabel 
)
See also:
Classifier::train(array &$dataTrain, array &$dataLabel)

Implements Classifier.

Definition at line 108 of file MultinomialNaiveBayes.php.

References Classifier::OOV.


Field Documentation

Name of the table for the conditional probabilities.

Definition at line 94 of file MultinomialNaiveBayes.php.

Referenced by classify(), and save().

Name of the table for the prior probabilities.

Definition at line 89 of file MultinomialNaiveBayes.php.

Referenced by classify(), and save().


The documentation for this class was generated from the following file: