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?

Fraud, flagged: 19 Fraud, missed: 1 Honest, flagged by mistake: 29 Honest, cleared: 951

Flagged payments

48

…that are fraud

19

P(fraud | flagged)

39.3%

Accuracy

97%

Show the working
  1. Out of 1,000 payments, 20 are fraud and 980 are honest.
  2. Flagged fraud = 20 × 95% ≈ 19; flagged honest = 980 × 3% ≈ 29.
  3. P(fraud | flagged) = 19 ÷ (19 + 29) ≈ 39.6% (exact Bayes: 39.3%)
Even a very accurate test produces mostly false alarms when the thing it looks for is rare. The prior (base rate) matters as much as the test's accuracy: this is the base-rate fallacy.

Whiteboard · watch and try

Bayes with 1,000 payments

5 steps
Press Play and the tutor will talk you through it while writing on the board. Pause any time to write on the board yourself.

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

Question 1

1.A 99%-accurate test for a 1-in-10,000 condition comes back positive. The chance of having it is…

Question 2

2.In Bayes' rule, the prior is…

Question 3

3.How do fraud teams reduce false alarms from a rare-event detector?

Quiz score: 0 of 3

Exercises solved: 0 of 1

Tip: answer every quiz question correctly first.

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.