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 1


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.


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.