In this 2006 paper, it discusses that there are many Naive Bayes algorithms: Spam Filtering with Naive Bayes – Which Naive Bayes?
The paper states that binary Multinomial NB performs best.
I coded up the NB equations listed in the Naive Bayes spam filtering article on Wikipedia Computing the probability that a message containing a given word is spam:
Biased equation
and combine the probabilities using the log form of:
But I cannot tell which NB the Wikipedia article uses... Is it a binary multinomial equation or a Bernoulli form or some other?
Another question:
The article states that many implementations use the non-biased P(S|W) equation. Thinking about the biased equation above compared to the one below, I wonder if the biased equation involves the ratio of spam to non-spam perhaps twice if the training set has the same ratio is the same imbalanced ratio as the live data.
Non-biased equation
The concern is from how is the (spam occurrences for this word)/(total spam occurrences). But thinking more, I suspect the equations do not double count... Mmm...
Is the non-biased equation always better when using a real-word imbalanced training set? On my data, it sure is:
Biased Equation: Overall acc= 85% Specificity (TNR)= 6% Sensitivity (TPR)= 99%
Non-biased equation: Overall acc= 80% Specificity (TNR)= 63% Sensitivity (TPR)= 83%
(Note: I applied the to avoid over fitting and did a hold out as test...)
Thoughts? Much thanks for the help.
P.S. I coded this in Python from scratch to learn Python. But which library is best to use for this in Python for NB?
P.P.S I also do a lot of R coding, which library is best to use for NB in R?