23 — Governance & Trust

Fairness Audits#

EthicsStatistical 1 min read
◆ The PatternTesting for bias across protected groups

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.

Disparate Impact = P(ŷ=1|G=a) / P(ŷ=1|G=b)
A ratio below 0.8 (the "four-fifths rule") suggests adverse impact against group b.
// Interactive — fairness metrics across groups
Pattern bridge: Fairness audits apply confidence intervals per subgroup — the same statistical rigour, applied to equity. In markets, behavioral bias recognition teaches the same lesson: your defaults aren't neutral.
Worked example

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.

Where it misleads
  • 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.
In code
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.8
Python, in your browser — edit the code and run it again

Assumes 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())
Sources
  • 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

Linked from 1
← Previous
Lineage Tracking
Open in the full reader, with the topic sidebar