Algorithmic Fairness Lab

Eight fairness metrics with definitions, formulas and interactive numeric examples, plus an experiment showing why they cannot all hold at once.

العربية

Module experiments (4)

Concepts and formulas

Demographic parity formula

Gap between the highest and lowest selection rate; 0 means parity.

\mathrm{DPD}=\max_g P(\hat Y=1\mid G=g)-\min_g P(\hat Y=1\mid G=g)

Try it in: The eight fairness metrics calculator

Statistical parity difference formula

u = unprivileged, p = privileged; negative means u is selected less.

\mathrm{SPD}=P(\hat Y=1\mid G=u)-P(\hat Y=1\mid G=p)

Try it in: The eight fairness metrics calculator

Disparate impact ratio formula

Compared with the indicative four-fifths line 0.8.

\mathrm{DIR}=\frac{P(\hat Y=1\mid G=u)}{P(\hat Y=1\mid G=p)}

Try it in: The eight fairness metrics calculator

Equal opportunity difference formula

Difference in true positive rate between groups.

\mathrm{EOD}=\mathrm{TPR}_u-\mathrm{TPR}_p,\quad \mathrm{TPR}=\frac{TP}{TP+FN}

Try it in: The eight fairness metrics calculator

Equalized odds difference formula

The larger of the TPR and FPR gaps (Fairlearn definition).

\mathrm{EOdds}=\max\left(|\mathrm{TPR}_u-\mathrm{TPR}_p|,\;|\mathrm{FPR}_u-\mathrm{FPR}_p|\right)

Try it in: The eight fairness metrics calculator

Sensitive attribute

A characteristic that must not drive unjustified discrimination (gender, origin, religion, disability, age, depending on context and law). It is used in evaluation to measure group gaps even when not used for prediction.

Try it in: The eight fairness metrics calculator

Predictive parity difference formula

Difference in precision between groups.

\mathrm{PPD}=\mathrm{PPV}_u-\mathrm{PPV}_p,\quad \mathrm{PPV}=\frac{TP}{TP+FP}

Try it in: The eight fairness metrics calculator

Algorithmic fairness

Definitions and metrics of what it means for a system to treat groups fairly: independence (equal selection), separation (equal error rates given the true label) and sufficiency (equal predictive value). They cannot all hold when base rates differ, so choosing one is a contextual decision.

Try it in: The eight fairness metrics calculator

FPR and FNR differences formula

The u − p difference of each.

\mathrm{FPR}=\frac{FP}{FP+TN},\quad \mathrm{FNR}=\frac{FN}{FN+TP}

Try it in: The eight fairness metrics calculator

Demographic parity

Holds when the positive decision rate is equal across groups regardless of the true label. Measured by DPD (largest gap in selection rates) or DPR (ratio). Suits equal distribution of opportunities, but can conflict with accuracy when base rates differ.

Try it in: The eight fairness metrics calculator

Disparate impact ratio

Selection rate of the unprivileged group divided by that of the privileged group. The four-fifths (0.8) rule is an indicative guideline from US employment practice; below 0.8 warrants investigation but is not a legal verdict by itself.

Try it in: The eight fairness metrics calculator

Equal opportunity

Holds when the true positive rate (recall) is equal across groups: qualified people in each group get the opportunity at the same rate (Hardt, Price & Srebro, 2016). Suits contexts where denying the deserving is the main harm.

Try it in: The eight fairness metrics calculator

Equalized odds

Requires equal true positive and false positive rates across groups; the gap is usually the larger of the two differences. Stricter than equal opportunity because it covers both error types.

Try it in: The eight fairness metrics calculator

Predictive parity

Holds when the positive predictive value (precision) is equal across groups. Chouldechova showed it conflicts with equal error rates when base rates differ.

Try it in: The eight fairness metrics calculator

Impossibility results

Kleinberg, Mullainathan & Raghavan (2016) and Chouldechova (2017) showed that with different base rates, calibration (or predictive parity) and equal error rates cannot all hold except in special cases. The criterion must be chosen and justified.

Try it in: Why fairness metrics cannot all hold at once

False positive / negative rate

FPR is the share of actual negatives wrongly flagged positive; FNR the share of actual positives missed. Group gaps in FPR or FNR mean the burden of error is unequal; the COMPAS debate centred on an FPR gap.

Try it in: The eight fairness metrics calculator

Questions and guides

Is one fairness metric enough?

No. Each metric answers a different question and some conflict mathematically when base rates differ. Compute several, justify the one that fits the context, and add a qualitative analysis of who is harmed by each error.

Try it in: Why fairness metrics cannot all hold at once

What is the COMPAS story?

COMPAS is a commercial recidivism risk tool. ProPublica (2016) found Black defendants who did not reoffend were labelled high risk more often (FPR gap); the vendor replied the tool was calibrated. Kleinberg and Chouldechova showed both can be true because the criteria cannot coexist with different base rates.

Try it in: Why fairness metrics cannot all hold at once

Module sources

  1. Fairlearn — open-source fairness toolkitFairlearn contributors (2025) — Tool
  2. Fairlearn User Guide — AssessmentFairlearn contributors (2025) — Tool
  3. AI Fairness 360IBM Research (2025) — Tool
  4. Machine BiasJ. Angwin, J. Larson, S. Mattu, L. Kirchner (ProPublica) (2016) — Documented case
  5. Fairness and Machine Learning: Limitations and OpportunitiesS. Barocas, M. Hardt, A. Narayanan (2023) — Book
  6. Equality of Opportunity in Supervised Learning (arXiv:1610.02413)M. Hardt, E. Price, N. Srebro (2016) — Paper
  7. Inherent Trade-Offs in the Fair Determination of Risk Scores (arXiv:1609.05807)J. Kleinberg, S. Mullainathan, M. Raghavan (2016) — Paper
  8. Fair prediction with disparate impact (arXiv:1610.07524)A. Chouldechova (2017) — Paper