I think I implemented most of them correctly. One part confused me:
Zero-frequency task: Add 1 to the counter for each combination of attribute value values (Laplace score) when the attribute value does not occur with each class value.
Here are some of my client codes:
string text = "Claim your free Macbook now!";
double posteriorProbSpam = classifier.Classify(text, "spam");
Console.WriteLine("-------------------------");
double posteriorProbHam = classifier.Classify(text, "ham");
Now say the word “free” is present in the training data somewhere
classifier.Train("ham", "Attention: Collect your Macbook from store.");
*Lot more here*
classifier.Train("spam", "Free macbook offer expiring.");
But the word is present in my training data for the spam category, but not in the ham. Therefore, when I turn to calculating posteriorProbHam, what should I do when I come across the word "free".

source
share