Worked examples — Bias, fairness, and discrimination metrics
The scenario matrix
Before working anything, here is the full map of cases this topic can throw at you. Each worked example below is tagged with the cell it covers.
| # | Case class | What is special about it | Example |
|---|---|---|---|
| C1 | Standard audit — both groups, imperfect classifier, unequal base rates | The everyday case | Ex 1 |
| C2 | Group order swapped (protected ↔ privileged) | Disparate Impact is not symmetric | Ex 2 |
| C3 | Equal base rates | The impossibility conflict disappears | Ex 3 |
| C4a | Degenerate: base rate = 0 (nobody qualifies) | TPR undefined — | Ex 4 |
| C4b | Degenerate: base rate = 1 (everybody qualifies) | FPR undefined — no true negatives | Ex 5 |
| C5 | Boundary: DI ratio = exactly 0.80 | The knife-edge of the legal test | Ex 6 |
| C6 | Limiting: perfect classifier | Every error rate matches, parity still fails | Ex 7 |
| C7 | Individual fairness (Lipschitz), pass and fail | Continuous metric, not a table count | Ex 8 |
| C8 | Real-world word problem — hiring, hidden proxy | Translate prose → numbers → verdict | Ex 9 |
| C9 | Exam twist — "make them fair" (threshold shift) | You must change a table, not just read it | Ex 10 |
The four metrics, stated up front

The figure above is your map: the grid, with each rate's cells highlighted. The red arrow runs down the column — that is TPR's territory. The label under each cell tells you which rate reads it: TPR and FN share the column; FPR and TN share the column; PPV reads the top (flagged) row. Keep glancing back — every example is just "point at cells, divide".
Example 1 — Standard audit (C1)
Forecast: Guess now — will the two groups have equal precision, given their base rates differ (0.20 vs 0.30)? Jot your guess.
Step 1 — flag rates (Demographic Parity). Why this step? Demographic parity ignores the truth column entirely — it only asks "what fraction got flagged?" So we sum the whole flagged row () and divide by group size. The rates differ (0.30 vs 0.40): parity fails.
Step 2 — TPR and FPR (Equalized Odds). Why this step? Equalized odds looks within each truth column: TPR uses only the people, FPR only the people. TPRs match (0.90) but FPRs differ — Group B gets more false alarms. Equalized Odds fails on FPR.
Step 3 — precision (Predictive Parity). Why this step? Precision reads down the flagged row: of everyone flagged, how many were truly positive? They differ — Predictive Parity fails too.
Step 4 — Disparate Impact. Flagging is a harm here, so the disadvantaged group is the one flagged more (B). We put B on top: Why this step? DI is the ratio of selection rates. B is flagged more, which is bad for B — but the ratio , so the crude 80% rule (built for benefit selection) does not trip. This is exactly why you never read DI in isolation.
Verify: Base rates 0.20 and 0.30 differ, so by the Chouldechova identity (stated above) equal-ish error rates must force unequal PPV — and indeed . Consistent. ✓ (See Disparate impact theory.)
Example 2 — Swap the group order (C2)
Forecast: Same number as before? Reciprocal? Guess.
Step 1 — compute the flipped ratio. Why this step? DI is a ratio, and while . They are reciprocals (), not the same number — so the direction you divide changes the verdict.
Step 2 — which is "correct"? Why this step? The EEOC convention (from the sign-convention box) puts the disadvantaged group's selection rate on top. Because flagging = harm here, being flagged more disadvantages B, so the numerator should be B's rate. The flipped would falsely "flag" A as the victim, inverting reality.
Verify: and multiply to (reciprocals), confirming the asymmetry. ✓ Lesson: always define which direction is harm before computing DI.
Example 3 — Equal base rates: the conflict vanishes (C3)
Forecast: The parent said the three metrics are "provably incompatible" — but that was when base rates differ. Guess whether equal base rates rescue us.
Step 1 — build each group's counts from the rates. Positives , negatives . Identical for both groups. Why this step? We are handed rates, not raw counts, so we invert the rate formulas (, ) to rebuild the table before we can compute precision — precision needs the actual and counts, not the rates.
Step 2 — precision. Same in both groups. Why this step? With identical base rates AND identical error rates, every derived quantity is identical — the Chouldechova identity's base-rate factor is the same on both sides, so equal error rates permit equal precision. All three metrics hold at once.
Verify: Plug into the identity : RHS . ✓ The impossibility is a statement about unequal base rates, nothing more. (Deep background: Causal fairness.)
Example 4 — Degenerate: base rate zero (C4a)
Forecast: Can you even define TPR when there are no true positives to catch?
Step 1 — lay out counts. people , so , . Of the 500 negatives, 25 flagged: , . Why this step? Before touching any rate, we must place all 500 people into the four boxes; a rate with a zero denominator is only visible once the counts are explicit.
Step 2 — TPR is . Why this step? TPR asks "of the truly positive, what fraction did we catch?" — but there is nobody truly positive, so the question has no answer. Report it as N/A, never as 0.
Step 3 — FPR and PPV survive... mostly. Why this step? FPR's denominator is the negatives, of which there are 500 — well defined. PPV is meaningful: every one of the 25 flags was wrong, so precision is genuinely zero (not undefined).
Verify: group size, and no positives exist, so the negative column is the whole group. ✓ Rule: guard every rate against a zero denominator before comparing groups — a group with silently poisons any TPR comparison.
Example 5 — Degenerate: base rate one (C4b)
Forecast: Last time TPR died. Which rate dies when everybody qualifies?
Step 1 — lay out counts. people , so , . Of the 400 positives, 360 flagged: , . Why this step? Symmetric to Example 4 — with no negatives at all, the two "negative-truth" boxes (, ) are forced to zero before any rate is read.
Step 2 — FPR is . Why this step? FPR asks "of the truly negative, what fraction did we falsely flag?" — but there is nobody truly negative, so the question is empty. Report N/A, never 0. This is the mirror image of the case.
Step 3 — TPR and PPV survive. Why this step? TPR's denominator is the positives (400 of them) — fine. PPV is meaningful: since no negatives exist, every flag must be a true positive, so precision is perfect regardless of the model.
Verify: group size, and no negatives exist, so the positive column is the whole group; PPV because is structurally zero. ✓ Rule: breaks FPR exactly as breaks TPR — always check both degenerate ends before a group comparison.
Example 6 — The exact 0.80 knife-edge (C5)
Forecast: vs — does the 80% rule trip or not?
Step 1 — compute DI (disadvantaged over advantaged). Why this step? Here is a benefit (approval), so the disadvantaged group is the one approved less — that is P. Per the sign convention, P goes on top, and the rate lands exactly on .
Step 2 — interpret the boundary. Why this step? The number alone is useless without knowing the rule's shape. The EEOC "four-fifths rule" flags ratios below ; exactly is the threshold itself — conventionally just passing the screen. A tiny drop (approve rate → DI ) would fail. Because the rule is empirical, treat anything near as "investigate further".
Verify: . ✓ The boundary is passes, fails; is the last passing value. See Algorithmic accountability.
Example 7 — Limiting case: the perfect classifier (C6)
Forecast: Perfect predictions surely means "fair"... right? Guess before computing.
Step 1 — error rates. Perfect means in both groups. So in both groups. Equalized Odds holds (1 and 0 everywhere). Why this step? "Perfect" is a statement about the error boxes: . Once those two boxes vanish, TPR and FPR collapse to their extreme values identically in every group.
Step 2 — precision. Why this step? With , the flagged row contains only true positives, so precision is forced to 1 — again identical across groups.
Step 3 — flag rate = base rate. With , the fraction flagged equals the fraction truly positive: These differ → Demographic Parity fails, and DI fails. Why this step? This is the deep lesson: even a flawless predictor breaks demographic parity whenever the world's base rates differ, because a perfect model must flag exactly the truly-positive fraction. Parity would require the model to flag equal fractions — i.e. to be wrong on purpose. So parity and accuracy genuinely trade off (Fairness-accuracy tradeoffs).
Verify: DI ; error-rate metrics all equal; parity gap . ✓ Perfection ≠ every fairness definition satisfied.
Example 8 — Individual fairness, pass and fail (C7)
Forecast: Guess which pair is the fairness violation.
Step 1 — Pair 1 budget. Allowed gap . Actual gap . Why this step? Two people who are almost identical in features () got wildly different scores. The Lipschitz rule caps the allowed swing at ; exceeding it means a hidden proxy is doing the work.
Step 2 — Pair 2 budget. Allowed . Actual . Why this step? Here the features are further apart (), so a larger prediction gap is permitted; the actual gap is tiny, so the pair sits safely inside the budget.
Verify: (fails); (passes). ✓ The Lipschitz check is a continuous metric — no table needed, just distances. See Counterfactual fairness for the causal cousin of "similar people".

The figure plots feature distance on the horizontal axis against prediction gap on the vertical. The red line is the boundary ; everything below is fair, everything above violates. Pair 1 sits high above the line, Pair 2 comfortably below.
Example 9 — Real-world word problem (C8)
Forecast: Advance rate is roughly a quarter for women, forty percent for men — guess the DI.
Step 1 — reconstruct counts. Here ="advance" (a benefit). Women: . Men: . Why this step? The prose gives row totals and success counts, not the four boxes; we subtract to recover and so every later rate is a clean cell division.
Step 2 — advance rates and DI. Advancing is a benefit, so the disadvantaged group is the one advanced less — women. Women on top: Why this step? The ratio is well under , so the "years of continuous employment" proxy has recreated gender discrimination without the model ever seeing gender (Intersectionality in ML would slice this further by adding race).
Step 3 — precision, to check if the flag is at least equally trustworthy. Why this step? Precision is equal — when the model advances someone, it is right 75% of the time for both. So the harm is not in trust; it is purely in the rate of advancing. Diagnosing which metric fails tells you which lever to pull.
Verify: ; both PPV . ✓ Diagnosis: fix the selection rate, not the calibration.
Example 10 — Exam twist: "make it fair" (C9)
Forecast: We remove 100 of 400 flags — will B's rate land exactly on A's ?
Step 1 — new B counts. Old: . Remove 20 TP and 80 FP: Flagged total . Why this step? Raising a threshold un-flags people: each removed flag moves from the top row to the bottom row of the same truth column. So removed become , removed become — that is why and grow.
Step 2 — new flag rate. Why this step? Threshold shifting is exactly how post-processing enforces a chosen metric — you slide the cutoff until the target rate matches.
Step 3 — what did we sacrifice? New (down from 0.90) and (up from 0.675). Why this step? Fixing parity moved 20 true positives out of the flagged set, so we now miss more real positives — TPR drops. Every fairness fix spends accuracy somewhere (Fairness-accuracy tradeoffs).
Verify: Flag total matches A exactly; . ✓ Parity bought at the cost of TPR — no free lunch.
Recall Self-test (reveal after answering)
Q1: In Example 1, why does Demographic Parity fail but not Disparate Impact's 80% rule? ::: Flag rates 0.30 vs 0.40 are unequal (parity fails), but the ratio so the crude legal screen passes. Q2: In the zero-base-rate case, which single rate becomes undefined and why? ::: TPR , because the group has no truly-positive people to catch. Q3: In the base-rate-one case, which rate dies instead? ::: FPR , because the group has no truly-negative people. Q4: A perfect classifier satisfies which fairness metrics and fails which? ::: Satisfies Equalized Odds and Predictive Parity; fails Demographic Parity / DI whenever base rates differ. Q5: DI computed disadvantaged/advantaged . What does flipping the ratio give? ::: — the reciprocal; direction matters. Q6: Individual fairness with , feature distance : what prediction gap is allowed? ::: .
See also: COMPAS risk assessment — the real system where the Equalized-Odds vs Predictive-Parity conflict (Example 7's logic) played out in court.