Module 8 · Probability: Reasoning About Uncertainty · Lesson 27 of 51
Bayes' rule and base rates
Updating beliefs with evidence: priors, likelihoods and posteriors, natural frequencies, false alarms in fraud and medical tests, and where Bayes shows up in data science.
In this lesson · about 35 minutes
- Apply Bayes' rule with natural frequencies and with the formula
- Explain why rare events produce many false alarms
- Name everyday uses: spam filters, fraud scores, A/B testing
Try it · data lab
Bayes' rule: 1,000 payments
Each square is one card payment. Change how rare fraud is and how accurate the detector is, then see what a flag really means.
The café's card system flags suspicious payments. A payment is flagged. How likely is it to be fraud really?
Flagged payments
48
…that are fraud
19
P(fraud | flagged)
39.3%
Accuracy
97%
Show the working
- Out of 1,000 payments, 20 are fraud and 980 are honest.
- Flagged fraud = 20 × 95% ≈ 19; flagged honest = 980 × 3% ≈ 29.
- P(fraud | flagged) = 19 ÷ (19 + 29) ≈ 39.6% (exact Bayes: 39.3%)
Whiteboard · watch and try
Bayes with 1,000 payments
Tip: press Pause, then use the pen to work along on the board. Space plays and pauses; Ctrl+Z undoes your last mark.
The formula
P(A | B) = P(B | A) × P(A) ÷ P(B), where P(B) = P(B | A)P(A) + P(B | not A)P(not A).
Where Bayes shows up
- Spam filters: naive Bayes classifiers combine word probabilities into P(spam | words).
- Fraud and medical screening: base rates decide how many alerts are real, so teams tune thresholds and add a second check.
- Bayesian A/B testing: reports "a 94% probability that B is better", which managers often find easier than p-values.
- Updating forecasts: start from last year's pattern (prior), update with this month's data.
Exercise
A Bayes function
Write posterior(prior, sensitivity, false_positive_rate) that returns P(condition | positive), rounded to 4 decimals. Use it to set churn_flag: a model flags 80% of members who will churn and 10% of those who won't, and 25% of members churn.
Check your understanding0 of 3 correct
Quiz score: 0 of 3
Exercises solved: 0 of 1
Written by Noviq Academy in its own words. Kettle & Crumb and all its data are made up for teaching; any resemblance to a real business is a coincidence. Python runs in your browser with Pyodide, so results can differ slightly from your own computer. Power BI, Tableau and other product names belong to their owners. Read-aloud uses your device's built-in voices.