Implementation of the Multinomial Naive Bayes classifier similar to the one that is described in Manning, et al. More...
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. |
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
Definition at line 64 of file MultinomialNaiveBayes.php.
MultinomialNaiveBayes::__construct | ( | ) |
Default constructor.
Definition at line 101 of file MultinomialNaiveBayes.php.
MultinomialNaiveBayes::classify | ( | $ | dataTest | ) |
Bayes decision rule.
Implements Classifier.
Definition at line 231 of file MultinomialNaiveBayes.php.
References getConnection(), Classifier::OOV, tabCondName, and tabPriorName.
MultinomialNaiveBayes::save | ( | ) |
Implements Classifier.
Definition at line 190 of file MultinomialNaiveBayes.php.
References getConnection(), tabCondName, and tabPriorName.
MultinomialNaiveBayes::setDatabase | ( | $ | name | ) |
Implements Classifier.
Definition at line 178 of file MultinomialNaiveBayes.php.
References getPrefixID().
MultinomialNaiveBayes::train | ( | array &$ | dataTrain, | |
array &$ | dataLabel | |||
) |
Implements Classifier.
Definition at line 108 of file MultinomialNaiveBayes.php.
References Classifier::OOV.
const MultinomialNaiveBayes::tabCondName = "cond" |
Name of the table for the conditional probabilities.
Definition at line 94 of file MultinomialNaiveBayes.php.
Referenced by classify(), and save().
const MultinomialNaiveBayes::tabPriorName = "prior" |
Name of the table for the prior probabilities.
Definition at line 89 of file MultinomialNaiveBayes.php.
Referenced by classify(), and save().