Naive Bayesian and Zero Frequency

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:

//Clasify
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

//Training
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".

enter image description here

+5
source share
1 answer

. : P("free" | spam) P("free" | ham) , . Laplace, P("free" | spam), (count("free" | spam) + 1) / count(spam); P("ham" | spam) - .

, , , : "" , "" .

+5

All Articles