liveBook · Manning

Complement rule

As explained in Grokking Machine Learning, Second Edition

The complement rule states that the probability of an event's opposite is one minus the probability of the event.

The complement of an event is its opposite. If an email has a 0.2 probability of being spam, it has a 0.8 probability of being ham: P(ham) = 1 − P(spam). section 8.6

The same subtraction works inside a condition. If P('lottery' | spam) = 0.75, then P(no 'lottery' | spam) = 0.25. Complements fill in the probability of what did not happen. section 8.6

Email probabilities

Suppose 1/5 of emails are spam and 3/4 of spam emails contain “lottery.” The probability that spam emails do not contain the word is 1 − 3/4 = 1/4, or 0.25. section 8.6

Figure 8.6 The tree of possibilities. The root splits into two branches: spam and ham. Then each of these splits into two branches: when the email contains the word lottery, and when it doesn’t.

Follow the tree from spam or ham to emails containing “lottery” or not; complementary branches make the missing probabilities visible. section 8.6

How Grokking Machine Learning, Second Edition covers it

How deep it goes
Defines the rule and works through unconditional and conditional email probabilities, then applies them within a larger calculation.
Examples
Uses spam and ham emails, the word “lottery,” probability fractions, and a tree of possible outcomes.
What it assumes
Assumes basic probability notation and introduces complements and conditional-probability notation through email examples.
What you can do after
Evaluate missing event probabilities by subtracting the known probability from one.
How it connects
Connects complementary probabilities with conditional probability and naive Bayes classification.

Also explained in

Compare how 3 books explain complement rule →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning, Second Edition. The section links point to the parts of the book it draws on.