# Jurafsky and Martin (2018) Do not understand formula in naiye bayes classifier

Currently I am reading Language and Speech Processing by , Chapter 4 Naiye Bayes and Sentiment Classification. At page $$7,$$ when the authors discuss worked example. Data set is as follows:

Training set: just plain boring (-)

entirely predictable and lacks energy (-)

no surprises and very few laughs (-)

very powerful (+)

the most fun film of the summer (+)

Test predictable with no fun (?)

I fail to understand why is $$20$$ added in the denominator, i.e. $$P( \text{'prediction'} | -) = \frac{1+1}{14+20}.$$

## 1 Answer

If you look at equation (4.14) on page 6, you see that 20 is actually $$|V|$$ that is the total number of words in the vocabulary.

So now, if you look at the training set and count the number of unique words, you will find that they are 20.

HTH

• I see. It is the number of unique words, not the total number of words, which include duplicate words? Jul 31, 2019 at 23:27
• yes - it is "the union of all the words types in all classes" Jul 31, 2019 at 23:31