Back to questions
JuniorTheoryCommon
What does this program print?
p_spam = 0.1
p_word_spam = 0.8
p_word_ham = 0.2
spam = p_word_spam * p_spam
ham = p_word_ham * (1 - p_spam)
print(round(spam / (spam + ham), 2))0.31
- Expecting
0.8: that isP(word | spam); the code computesP(spam | word), and since spam is only 10% of mail, most emails with the word are normal. - Expecting
0.08: that numerator isP(word | spam) · P(spam); dividing byspam + ham, which isP(word) = 0.26, turns it into a probability.
- How would the answer change if spam made up half of all mail?
- Why can a classifier skip the division by
P(word)when it only picks the class?