Machine Learning Basics
20% of all emails are spam. A certain word appears in 50% of spam emails and in 5% of non-spam emails. Which is closest to the probability that an email containing this word is spam?
- A0.10
- B0.50
- C0.71
Show answer and explanation
Answer: C. 0.71
By Bayes' theorem, P(spam | word) = P(word | spam) × P(spam) ÷ P(word). The numerator is 0.5 × 0.2 = 0.10, and the probability of containing the word is P(word) = 0.5 × 0.2 + 0.05 × 0.8 = 0.14, so the answer is 0.10 ÷ 0.14 ≈ 0.71. Naive Bayes classification performs this calculation by assuming that several words (features) are mutually independent within each class and multiplying their probabilities, and it has long been used for spam detection.
- A. This is 0.5 × 0.2 = 0.10, the probability that an email is spam and contains the word, not divided by the probability of containing the word, 0.14.
- B. This is P(word | spam), the probability that a spam email contains the word; the condition is the reverse of the required P(spam | word).
- C. Correct. 0.10 ÷ 0.14 ≈ 0.71.