Bias & Fairness
Where bias comes from and how fairness is defined.
A lender sets the most accurate thresholds it can find and ends up approving 54% of one group and 19.5% of the other. Equalizing the approval rates fixes that gap and leaves the error rates far apart. This lesson makes "fair" precise: where bias enters a pipeline, the three families of group criteria and a proof that two of them clash, what each criterion costs in accuracy, and fairness for individuals rather than groups.
What you’ll learn
- Trace bias to its sources in the machine-learning pipeline, including biased labels and feedback loops, and explain why dropping the sensitive attribute fails.
- State independence, separation and sufficiency as conditional-independence conditions, with demographic parity, equalized odds, equal opportunity, calibration and predictive parity as instances.
- Prove that demographic parity and equalized odds cannot both hold when base rates differ, unless the classifier is uninformative.
- Derive accuracy-optimal group thresholds, and measure what each fairness criterion costs in the widget.
- State Dwork et al.'s individual fairness, and prove that it bounds group disparities by an earthmover distance.
Where bias enters
Algorithmic bias is rarely a single bug. Suresh & Guttag (2021) trace harms to seven stages of the machine-learning life cycle:
- Historical bias: the world the data record was itself unequal, as with past hiring decisions.
- Representation bias: some groups are scarce in the data, as in the face datasets behind the Gender Shades audit.
- Measurement bias: a label or feature is a proxy that works differently across groups, such as arrests standing in for crime.
- Aggregation bias: one model is fit to groups whose features relate to the outcome differently.
- Learning bias: the objective trades a small group's accuracy for a large group's, as minimizing average loss does.
- Evaluation bias: the benchmark does not represent the population the model will serve.
- Deployment bias: the system is used differently from its design, for instance as a decision rather than a decision aid.
Two more mechanisms defeat naive fixes. Proxies: deleting the sensitive attribute from the inputs, fairness through unawareness, leaves every feature correlated with it. The best predictor from the remaining features is , which still depends on group membership through whenever predicts , as ZIP codes and names often do. Feedback loops: predictions shape the next round of data. Ensign et al. (2018) modeled predictive policing as an urn process in which patrols go where incidents were recorded and incidents are recorded only where patrols go, and showed that patrols can be sent back to the same neighborhoods again and again regardless of the true crime rates.
In Obermeyer et al.'s study, which source of bias produced the disparity?
- Representation bias: too few Black patients in the training data
- Measurement bias: the label, cost, reflected health need differently across groups
- Aggregation bias: one model for groups whose features relate to the outcome differently
- Evaluation bias: an unrepresentative benchmark
Show the answer
B. Measurement bias: the label, cost, reflected health need differently across groups
The algorithm predicted cost accurately, but cost encodes unequal access to care: equal need produced lower spending for Black patients. Changing the label to a measure of health changed who was selected. More data or a bigger model trained on the same label would not have.
Three families of group criteria
Fix notation: features , a group attribute , a binary outcome , a score , which may or may not use , and a decision . Group 's base rate is . Most group criteria are conditional-independence statements about these variables (Barocas, Hardt & Narayanan, 2023):
| Family | Condition | For a binary decision | Names |
|---|---|---|---|
| Independence | equal across groups | demographic parity, statistical parity | |
| Separation | equal TPR and equal FPR | equalized odds; equal TPR alone is equal opportunity (Hardt, Price & Srebro, 2016) | |
| Sufficiency | equal PPV and equal NPV | calibration within groups when ; equal PPV alone is predictive parity |
Can a decision satisfy two families at once? Independence and sufficiency together force equal base rates: , the same for every group. The clash between independence and separation is just as short.
Suppose the decision satisfies equalized odds, with the same TPR and FPR in every group. By the law of total probability, group 's approval rate is
Demographic parity between groups and then requires
If , then : the decision approves positives and negatives at the same rate, so it is independent of , and its ROC point lies on the diagonal. Apart from such uninformative rules, demographic parity and equalized odds are incompatible whenever base rates differ.
In the loan scenario below, 50% of group A and 30% of group B would repay. A rule with TPR 80% and FPR 20% in both groups approves 50% of group A. What fraction of group B does it approve, in percent?
Show the answer
38 %
. Equal error rates, unequal approval rates: parity fails by 12 points, exactly . The third pairing, separation against sufficiency, is the subject of the impossibility theorems.
Thresholds, accuracy and the price of a criterion
Which threshold should each group get? Start from the unconstrained optimum. If approving a case with costs and rejecting one with costs , approving has expected cost and rejecting it , where . So approve exactly when , which is for accuracy. Under a constraint such as parity or equal error rates the optimal rule is still a threshold on , but the thresholds become group-specific (Corbett-Davies et al., 2017): the constraint acts like a price that shifts each group's cutoff.
In the widget below, scores are normal within each outcome and group. In group A, applicants who would repay average 66 and those who would default 40, both with SD 12; in group B the averages are 60 and 43 with SD 14, so B's scores separate the outcomes less well. By Bayes' rule, means
With the normal density of mean and common SD (dropping the group index), take logarithms. The quadratic terms cancel, so the condition is linear in :
Group A (): the log term vanishes and ; the widget's integer thresholds 51 to 54 tie for A's best accuracy, 86.0%. Group B (): the cutoff rises for two reasons, the lower base rate and the noisier score, which multiplies the log-odds by instead of A's :
| Constraint (gap at most 2 points) | Best thresholds A / B | Overall accuracy | Approval rates A / B |
|---|---|---|---|
| none, per-group thresholds | 51 / 62 | 81.8% | 54.0% / 19.5% |
| one shared threshold | 56 / 56 | 80.8% | 44.5% / 31.0% |
| demographic parity | 56 / 51 | 79.0% | 44.5% / 42.5% |
| equal opportunity | 59 / 53 | 78.8% | 39.0% / 37.5% |
| equalized odds | 76 / 73 | 67.3% | 10.0% / 6.5% |
Individual fairness
Let be any coupling of and : a joint distribution of pairs with marginals and . The difference in approval rates is then an average of differences over pairs:
The infimum over couplings is, by definition, the earthmover distance; repeat with and swapped:
An individually fair classifier can therefore treat two groups very differently on average only if they are far apart under , for instance because their qualifications for the task differ. Dwork et al. compute the loss-minimizing Lipschitz classifier with a linear program. The difficulty is itself: it must encode which differences between people are relevant to the decision, which is the contested question to begin with. Dwork et al. imagined it supplied by a regulator or by society; later work tries to learn it from human judgments about which pairs of people should be treated alike.
Think first Is a classifier that approves everyone individually fair? Does it satisfy demographic parity?
Yes to both: a constant is 0-Lipschitz, and it approves every group at the same rate. Like the group criteria, individual fairness constrains a decision rule without requiring it to be useful. It has to be combined with accuracy or utility, and the real question is what the constraint costs.
Auditing in practice
An audit starts with disaggregated evaluation: the confusion matrix, error rates and calibration per group, and per intersection of groups, since harms concentrate there. Gender Shades found the largest error rates at an intersection, darker-skinned women, higher than for women or for darker-skinned people taken as a whole. Intersections are small, so report uncertainty: a true-positive rate estimated from positive cases has a standard error of about .
A subgroup has 60 positive cases, and the model's TPR on them is 0.75. What is the half-width of a 95% confidence interval for the TPR, in percentage points?
Show the answer
11 pts
, so about points. A 5-point TPR gap between two subgroups of this size is well within the noise, so audits of small groups need more data, pooled evidence or explicit tolerances, and should say so.
Context decides which criterion matters. The 1978 Uniform Guidelines on Employee Selection Procedures treat a selection rate below four-fifths of the highest group's rate as evidence of adverse impact, a parity-style test; by that yardstick the accuracy-maximizing thresholds above, approving 19.5% and 54%, have a ratio of 0.36. In lending, equal opportunity focuses on applicants who would repay. When a score informs a human decision maker, calibration within groups matters, because the same score should mean the same risk. Documentation makes these choices visible: model cards report intended uses and disaggregated performance (Mitchell et al., 2019), and datasheets record how a dataset was collected and labeled (Gebru et al., 2021).
Key takeaways
- Bias enters at every stage: historical, representation, measurement, aggregation, learning, evaluation and deployment. A biased label or a feedback loop survives any amount of model tuning, and dropping leaves its proxies in place.
- Group criteria are conditional independences: independence (: parity), separation (: equalized odds and equal opportunity) and sufficiency (: calibration and predictive parity).
- With unequal base rates, parity plus equalized odds forces an uninformative classifier, and independence plus sufficiency is impossible; separation against sufficiency is the impossibility theorem of the Deep Layer.
- The accuracy-optimal rule thresholds , and constraints give group-specific thresholds. In the widget: 81.8% unconstrained, 79.0% with parity, 78.8% with equal opportunity, 67.3% with deterministic equalized odds.
- Individual fairness is a Lipschitz condition that bounds group disparities by an earthmover distance; its hard part is the similarity metric.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Equal opportunity (Hardt, Price & Srebro, 2016) requires equality across groups of which quantity?
- The approval rate
- The true-positive rate
- The positive predictive value
- The false-positive rate
Show the answer
B. The true-positive rate
Equal opportunity is the positive-outcome half of equalized odds: qualified applicants are approved at the same rate in every group. Equalizing approval rates is demographic parity, equalizing PPV is predictive parity, and equalized odds adds equal FPR.
Base rates differ between two groups. Which pair of criteria can an informative binary classifier never satisfy together?
- Equal opportunity and high accuracy
- Demographic parity and equalized odds
- Individual fairness and demographic parity
- Calibration and high accuracy
Show the answer
B. Demographic parity and equalized odds
Equalized odds makes each group's approval rate , and parity then forces , so : the classifier is independent of the outcome.
In the widget, why is group B's accuracy-maximizing threshold (62) higher than group A's (about 53)?
- B's base rate is lower and its scores separate repayers from defaulters less well, both of which raise the score at which reaches
- Smaller groups always need higher thresholds
- B's scores are on a different scale
- Higher thresholds always increase accuracy
Show the answer
A. B's base rate is lower and its scores separate repayers from defaulters less well, both of which raise the score at which reaches
The Bayes cutoff is . For B the log term is positive, and the noisier score multiplies it by , giving about 61.3.
A classifier is Lipschitz with respect to a similarity metric . When can it approve two groups at very different average rates?
- Never
- Only if the groups are far apart in earthmover distance under
- Only if it uses the group attribute
- Whenever the base rates differ
Show the answer
B. Only if the groups are far apart in earthmover distance under
Coupling the groups gives for every coupling , hence at most . Groups that are close under must be treated alike on average; groups far apart need not be.
A model never sees the group attribute. Which criterion does that guarantee?
- Demographic parity
- Equalized odds
- Calibration within groups
- None of them
Show the answer
D. None of them
Fairness through unawareness constrains the inputs, not the outcomes. Proxies such as ZIP code carry group information, and a predictor trained on biased labels reproduces them. Every group criterion is a property of the joint distribution of , and , and has to be checked on that distribution.
Go deeper
- Fairness Impossibility Theorems · Why calibration and equal error rates conflict.
- Bias Mitigation Techniques · Pre-, in- and post-processing interventions.
- Explainability Methods · LIME, SHAP, saliency and their pitfalls.
Further reading
- S. Barocas, M. Hardt & A. Narayanan, Fairness and Machine Learning: Limitations and Opportunities (MIT Press, 2023), free at fairmlbook.org.
- C. Dwork, M. Hardt, T. Pitassi, O. Reingold & R. Zemel, "Fairness through awareness," ITCS (2012).
- M. Hardt, E. Price & N. Srebro, "Equality of opportunity in supervised learning," NeurIPS (2016).
- Z. Obermeyer, B. Powers, C. Vogeli & S. Mullainathan, "Dissecting racial bias in an algorithm used to manage the health of populations," Science (2019).