Fairness and Bias in ML
Where bias enters ML systems, how to measure group fairness, and what mitigation can and cannot fix.
Intermediate · about 5 hours · difficulty 3/5
Learn first: Evaluation Metrics, Imbalanced Data
Models learn from historical data, and history contains unequal treatment. A hiring, lending or healthcare model can quietly reproduce or amplify that. Measuring and addressing it is part of doing the job well, and increasingly a legal requirement.
Where bias comes from
- Historical bias: the labels themselves reflect past unfair decisions.
- Representation bias: some groups are under-sampled.
- Measurement bias: proxies (arrests for crime, clicks for interest) mean different things for different groups.
- Proxy features: removing a protected attribute does not help if postcode or name encodes it.
- Deployment bias: using a model in a context it was not built for.
Measuring it
Always slice metrics by group. Common definitions:
- Demographic parity: similar positive prediction rates across groups.
- Equal opportunity / equalized odds: similar true positive (and false positive) rates.
- Calibration within groups: a score of 0.7 means the same thing for everyone.
These definitions generally cannot all hold at once, so choosing one is a value judgement to make with domain experts and affected people, not a purely technical call.
Mitigation
- Pre-processing: better data collection, reweighting.
- In-processing: fairness constraints during training.
- Post-processing: group-specific thresholds.
- Sometimes the right answer is not to automate the decision at all.
Fairlearn and AIF360 provide metrics and mitigation algorithms.
Good enough to move on when you can audit a model's metrics across groups, explain why fairness definitions conflict, and document the trade-off you chose.
Key concepts
- Sources of bias
- Proxy features
- Sliced evaluation by group
- Demographic parity and equalized odds
- Fairness trade-offs
- Mitigation strategies
- Fairlearn toolkit
Mini project
Train a classifier on the Adult income or a similar public dataset, report metrics by sex and race with Fairlearn, apply one mitigation method, and write up how accuracy and each fairness metric changed.
Check yourself
Why does deleting the protected attribute column usually fail to make a model fair, and why can demographic parity and calibration conflict?
Free resources
- Fairlearn documentation (Fairlearn)
- Google Machine Learning Crash Course (Google)
- Fairness and Machine Learning (Barocas, Hardt, Narayanan)