Fairness audits measure whether your model treats different groups equitably. Demographic parity checks if positive rates are equal across groups. Equalized odds checks if error rates are equal. No single metric captures all fairness — you must choose which definition matches your context.
A credit model selects 36% of group a and 16% of group b: a disparate-impact ratio of 0.44, far under the four-fifths rule. Among people who would repay, it approves 75% of a and 60% of b. When groups differ in base rates, no model can equalize all of these at once (Kleinberg, Mullainathan & Raghavan 2017); an audit makes the choice explicit.
- The four-fifths rule is a screening heuristic from U.S. employment guidance, not a definition of fairness.
- Removing the protected attribute does not remove its effect; proxies such as postcode carry it.
- Small groups give noisy rates; report confidence intervals.
g = pd.DataFrame({'group': ['a', 'b'],
'tp': [300, 120], 'fn': [100, 80], # among people who would repay
'fp': [60, 40], 'tn': [540, 760]}) # among people who would not
g['selection'] = (g.tp + g.fp) / (g.tp + g.fn + g.fp + g.tn)
g['tpr'] = g.tp / (g.tp + g.fn)
g['fpr'] = g.fp / (g.fp + g.tn)
disparate_impact = g.selection[1] / g.selection[0] # four-fifths rule: worry below 0.8Assumes import numpy as np and import pandas as pd. Each snippet carries its own example numbers; the comments say which are made up or simulated.
The same idea with a library
# Python — Fairlearn fairness assessment from fairlearn.metrics import MetricFrame from sklearn.metrics import accuracy_score mf = MetricFrame( metrics=accuracy_score, y_true=y_test, y_pred=y_pred, sensitive_features=demographics ) print(mf.by_group) print("Ratio:", mf.ratio())
- M. Hardt, E. Price & N. Srebro, “Equality of Opportunity in Supervised Learning”, NeurIPS, 2016
- J. Kleinberg, S. Mullainathan & M. Raghavan, “Inherent Trade-Offs in the Fair Determination of Risk Scores”, ITCS, 2017
- Uniform Guidelines on Employee Selection Procedures, 29 CFR § 1607.4(D), 1978 — the four-fifths rule
Last reviewed October 2026 · How this site checks its content · Report a mistake