What is the probability of an email being spam if it contains the word 'free'?

Instruction: Assume that out of all emails, 5% are spam, and of those, 30% contain the word 'free'.

Context: This question assesses understanding of conditional probabilities in the context of email spam filtering.

Updated

Example Answer

The word “free” alone is not enough to calculate the probability. I need the spam base rate and how often that word appears in both spam and legitimate mail. Bayes’ rule combines those quantities.

Suppose 100 of 1,000 emails are spam. Fifty of those contain “free,” and 45 of the 900 legitimate emails contain it. Among the 95 emails containing “free,” 50 are spam, so the probability is 50/95, or about 52.6%. The word raises suspicion in this example, but it does not make an email certainly spam. I would estimate the rates from representative labeled data and check whether they remain appropriate as email patterns change.

Worked example

If s = P(spam), a = P(free | spam), and b = P(free | legitimate), then P(spam | free) = s*a / (s*a + (1−s)*b), provided the denominator is positive.

Why this works

The example uses a consistent joint distribution and makes the base-rate effect visible. Every count can be checked without trusting unexplained percentages.

Related Questions