Exercises — Bias, fairness, and discrimination metrics
Before we start, one shared vocabulary reminder, so no symbol is used before it is named:
Level 1 — Recognition
Exercise 1.1
A model approves loans. It approves 45% of Group A applicants and 45% of Group B applicants. Which single fairness metric is exactly satisfied by this fact alone, and why can we say nothing yet about the others?
Recall Solution
Demographic Parity. It only asks that the positive-prediction rate be equal across groups: It uses only the prediction and group — it never looks at the truth label . So it says nothing about TPR, FPR, or PPV, all of which depend on . Equal approval rates can still hide wildly different error rates.
Exercise 1.2
Match each phrase to its metric: (a) "of those we flagged, how many were correct?" (b) "of the real positives, how many did we catch?" (c) "of the real negatives, how many did we wrongly flag?"
Recall Solution
(a) ::: PPV (precision) (b) ::: TPR (recall / true positive rate) (c) ::: FPR (false positive rate) Memory hook: PPV reads across a prediction row; TPR and FPR read down a truth column.
Level 2 — Application
Use this labelled table (predicted-flag = "denied loan"; = actually defaulted).
Group A (500 people, 100 real defaulters): . Group B (500 people, 200 real defaulters): .
Exercise 2.1
Compute TPR, FPR and PPV for each group.
Recall Solution
Group A: Group B: What we did: for each rate we picked the correct denominator — TPR divides by the truth-positive column (), FPR by the truth-negative column (), PPV by the prediction-positive row ().
Exercise 2.2
Is Equalized Odds satisfied?
Recall Solution
Equalized Odds needs both TPR and FPR equal across groups. Violated on both counts — Group B is missed less often but falsely flagged twice as often. Errors concentrate against Group B.
Level 3 — Analysis
Exercise 3.1 (Disparate Impact)
Using the Level-2 table, treat "predicted default" as denial. Group A's flag rate is , Group B's is . Compute the Disparate Impact ratio with the lower-flagged group as reference for privilege, and decide against the 80% rule. (Careful: here being flagged is bad.)
Recall Solution
Flag (denial) rates: (A), (B). Because flagging is the adverse outcome, the favourable outcome is "not flagged": (A) and (B). The disadvantaged (protected) group is the one with fewer favourable outcomes — Group B. Fails the four-fifths rule — the ratio is below the screening threshold. See Disparate impact theory.
Exercise 3.2 (Chouldechova identity)
Verify the identity for Group B, where is the base rate.
Recall Solution
Base rate , so . With : . With : This matches the directly-computed . The identity is not a fairness law — it is an algebraic fact that ties base rate, precision and error rates together, and that is exactly what makes some metrics incompatible.
Level 4 — Synthesis
Exercise 4.1 (Why the metrics collide)
Two groups have base rates and . An engineer forces Equalized Odds so that both groups share and . Using the Chouldechova identity, solve for each group's PPV and show Predictive Parity must fail.
Recall Solution
Rearrange the identity for PPV. From let . Then , giving .
Group A: , so , Group B: , so , Equal error rates + unequal base rates force unequal precision. This is the COMPAS risk assessment controversy in miniature: matching FPR and TPR (ProPublica's demand) automatically breaks calibration/PPV (Northpointe's defence). Both were correct; the metrics are just incompatible. See also Fairness-accuracy tradeoffs.
Level 5 — Mastery
Exercise 5.1 (Individual fairness audit)
A model outputs risk scores. Two applicants differ only in ZIP code: feature distance ; their scores are . The audit uses a Lipschitz bound with constant : it requires . Does the model pass? What is the smallest that would let it pass, and why is a large required a red flag?
Recall Solution
Required bound: . Actual output gap: . Smallest passing : solve . Why a big is bad: is the model's sensitivity — how many units of output swing per unit of input change. Needing means a nearly-irrelevant ZIP-code nudge moves the score by 18.5× its size. That is the fingerprint of a hidden proxy (ZIP → neighbourhood → protected attribute). Contrast with Counterfactual fairness: individual fairness bounds observed similarity; counterfactual fairness asks what the score would be in a world where the protected attribute were changed. See Causal fairness and Intersectionality in ML for why a single ZIP proxy can compound across overlapping groups.
Exercise 5.2 (Design decision)
A hospital deploys a triage model. Missing a truly-sick patient () can be fatal; a false alarm () only wastes a checkup. Base rates of illness differ across two communities. Which fairness metric should the audit prioritise, and which must be sacrificed — argue in two sentences using the impossibility result.
Recall Solution
Prioritise equal TPR across groups (a slice of Equalized Odds): since missing a sick patient is the catastrophic error, every community must have the same chance of being caught when truly ill. Sacrifice Predictive Parity (equal PPV): by the Chouldechova identity, equalising TPR/FPR under different base rates mathematically forces PPV to differ — so we accept that the meaning of a "positive flag" varies slightly by group in exchange for equal life-saving recall. This is an explicit, documented value choice, the essence of Fairness-accuracy tradeoffs.
Recall Self-test checklist
I can name which counts sit in each cell of the confusion grid ::: TP top-left, FP top-right, FN bottom-left, TN bottom-right (rows = prediction, columns = truth) I can pick the right denominator for TPR / FPR / PPV without looking ::: TPR ÷ (TP+FN), FPR ÷ (FP+TN), PPV ÷ (TP+FP) I can state why Equalized Odds and Predictive Parity clash ::: the Chouldechova identity fixes PPV once base rate, TPR, FPR are set; unequal base rates force unequal PPV I can flip Disparate Impact correctly when the flag is the bad outcome ::: use the favourable (not-flagged) rate, disadvantaged group over advantaged group