4 ms·
>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 th
by baron_harkonnen 7y ago
>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.
- jackhack 7y ago>That probability is n_word/total_words the corpus. Thanks. It's been 15 years since I implemented it. Guess I failed the interview.
- pokernaming 7y ago> 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).
- deleted 7y ago[deleted]
- tomrod 7y ago> For starters you aren't using probability. I never met a measure space I didn't like!