News for hackers. Stuff that matters.
Re:Naïve Bayes for Machine Learning by baron_harkonnen on Thursday November 14, 2019 @03:16PM (#21538962)
>Seriously, that's the algorithm. It's that simple.

It's funny because when I saw that line I thought I would be pedantic and double check to see if you got the laplacian smoothing correct (because in practice it's never "that simple" for any numeric algorithm) and then realized that you don't understand how to implement Naive Bayes' at all.

For starters you aren't using probability. If you want to put all of the words in each document together into a two dictionaries of counts, then for each word in the unclassified document you want to look at the product of the probability of those words appearing in the spam corpus vs the non-spam corpus. That probability is n_word/total_words the corpus.

This is where you need to do some smoothing because if a word does not appear in the one of the corpora then you will get a probability of 0 for that class. Smoothing just adds 1 to the numerator and N_classes to the denominator. It is the equivalent of assuming a weakly informative uniform prior.

Re:Naïve Bayes for Machine Learning by jackhack on Thursday November 14, 2019 @03:29PM (#21539077)
>That probability is n_word/total_words the corpus.

Thanks. It's been 15 years since I implemented it. Guess I failed the interview.

Re:Naïve Bayes for Machine Learning by tomrod on Friday November 15, 2019 @12:13AM (#21542363)
> For starters you aren't using probability.

I never met a measure space I didn't like!

Re:Naïve Bayes for Machine Learning by pokernaming on Thursday November 14, 2019 @06:23PM (#21540639)
> That probability is n_word/total_words the corpus.

In this case, wouldn't it actually be better to just drop the denominator, because it will be the same for both (spam & not spam).