Suppose you want to know whether it will rain. Before checking your surroundings, you have a rough estimate; after learning that you are in the Amazon rain forest, you can update it. That updated estimate is the posterior probability: the probability assigned to an event or hypothesis after incorporating observed evidence. The prior is the initial probability, the event supplies information, and the posterior is the resulting estimate. section 8.1
Bayes’ theorem makes the update concrete:
- Start with a prior: among 100 emails, 20 are spam, so the initial spam probability is 0.2. section 8.2
- Treat observed information as the event: the email contains the word “lottery.” section 8.2
- Restrict attention to emails containing that word: 15 are spam and 5 are ham, producing a posterior of 15/20 = 0.75. section 8.2
From words to a spam prediction
A real email dataset estimates spam and ham priors, counts each word in both classes, and combines the resulting evidence with the naive Bayes algorithm. The model returns 0.99997 for “buy cheap lottery easy money now,” 0.0000696 for “meet me at the lobby of the hotel at nine am,” and the spam prior, 0.2388, for an unknown word such as “asdfgh.” section 8.3







