loading...
How to use
Each dot is a test candidate, placed by the model's score (left = low, right = high) in group A's lane (blue) or group B's lane (pink). Teal dots are truly qualified, orange are not. Everything right of the vertical threshold is selected (solid); the rest is faint. Drag a threshold line, hover a dot for its card, click a dot to see which inputs pushed its score up or down.
Try this: (1) Fair world: both lanes look alike and every gap is near zero. (2) Opportunity gap: B's dots slide left, the impact ratio fails, yet the model is calibrated and accurate. (3) Proxy leak: the postcode bar turns red; switch off "Model may use the postcode index" and the gap shrinks. (4) Biased history: even with fair inputs the model under-selects qualified B candidates. (5) Fix: equal selection then Fix: equal opportunity: watch accuracy, FPR and PPV move when you close each gap, and see that you cannot close them all. (6) Press Sweep threshold and watch the trade-off graph.
Keys: [ and ] nudge the threshold. Everything is synthetic; the group labels carry no real-world meaning.
The science
Synthetic data, not real people. Every candidate is generated by the page. Three job-relevant inputs (skills test, experience, interview score) share a weak common factor, so they are mildly correlated; a fourth input, a postcode index, has no causal link to success. Whether a candidate would actually succeed in the role is the hidden truth y:
P(y = 1) = σ(b0 + 1.0 xskills + 0.7 xexp + 0.6 xinterview), σ(z) = 1 / (1 + e-z)
The intercept b0 is found by bisection so that the average success probability equals the chosen qualified share. Group A and Group B are arbitrary labels. The opportunity gap slider lowers group B's measured inputs by a multiple of one standard deviation (unequal access to the experiences that are measured); the postcode proxy slider makes the postcode index differ between groups. Neither changes how y depends on the inputs, so the true relationship is identical for both groups.
The model. A regularised logistic regression is trained on 70 % of the candidates by Newton's method (IRLS) and audited on the other 30 %:
L(w) = -(1/n) Σ [ y ln p + (1-y) ln(1-p) ] + (λ/2) ‖w‖², w ← w - H-1∇L, H = (1/n) XT diag(p(1-p)) X + λI
Historical label bias models a realistic failure: the training labels come from past decisions that wrongly marked a fraction of qualified B candidates as "not hired". The model then learns to under-score B even if every input is fair, while the audit scores it against the true outcome y.
Group fairness metrics. With selection S (score ≥ threshold), outcome y and group g:
Demographic parity: P(S=1 | A) = P(S=1 | B) impact ratio = min(selB/selA, selA/selB)
Equal opportunity: TPRA = TPRB, TPR = P(S=1 | y=1) Equalised odds: also FPRA = FPRB
Predictive parity: PPVA = PPVB, PPV = P(y=1 | S=1)
The "four-fifths" screen (impact ratio below 0.8) is a rule of thumb used in US employment-selection guidance as a flag for further review; it is not a legal conclusion and not a universal fairness test.
Why you cannot have everything. For any group, Bayes' rule links the three rates through the group's base rate π:
PPV = TPR · π / (TPR · π + FPR · (1 - π)) ⇒ FPR = (π / (1 - π)) · ((1 - PPV) / PPV) · TPR
If the two groups have different base rates π and the classifier is not perfect, then equal TPR and FPR force unequal PPV, and equal PPV with equal TPR forces unequal FPR (Kleinberg, Mullainathan and Raghavan 2016; Chouldechova 2017). Which metric to protect is therefore a value judgement, not a computation. Check 5 verifies the identity on the counted confusion matrix.
Threshold policies. Equal selection keeps group A's threshold and lowers or raises B's until the selection rates match (a quantile of B's scores). Equal opportunity picks B's threshold so that the share of qualified B candidates selected equals A's. Best accuracy per group maximises accuracy separately in each group. Group-specific thresholds can be unlawful in some jurisdictions and contexts; the simulator shows the arithmetic, not a recommendation.
Explainability. A linear model is transparent: the log-odds of a candidate is the sum of exact contributions wj zj plus the intercept, which the "Why this candidate?" bars show. Global importance is the mean absolute contribution; permutation importance is the drop in test AUC when one input is shuffled; the group correlation shows which inputs carry information about group (proxy detection). A feature can be harmless in isolation yet still be a proxy.
Checks run in the page. (1) trapezoid ROC area equals the rank-sum AUC; (2) the demographic-parity gap equals an independent loop over raw candidates; (3) the analytic log-loss gradient matches a central finite difference; (4) the fitted weights have zero gradient; (5) counted PPV equals the Bayes identity above; (6) equal-opportunity thresholds close the TPR gap to within one candidate; (7) equal-selection thresholds close the selection gap to within one candidate; (8) with no gap, no proxy and no label bias, 30 000 fresh candidates recover the true weights (1.0, 0.7, 0.6).
Simplifications. Two groups, four invented inputs, a linear-logistic truth, one decision round with no feedback loop, perfectly known true outcomes for everyone (real hiring never observes the outcome of rejected people), no intersectional groups, no confidence intervals on the audit numbers beyond the sampling noise you can see by pressing New sample. Nothing here describes a real organisation, person or product, and it is educational material, not legal or compliance advice.