Sub topic 2
Where Bias Enters the Pipeline
This chapter assumes you know the confusion matrix, precision and recall, train/test splits, and basic Python with NumPy and pandas. It covers where unfairness comes from before any metric is computed. Knowing the source tells you which check to run and which fix could work.
The pipeline as a chain of choices
A model's outcomes reflect a chain of human and technical decisions. Bias can enter at each link, and a later step rarely removes it.
Historical and representation bias
Historical bias means the data accurately records a world that was already unequal. If past hiring favored one group, a model trained to imitate those hires learns the pattern. Clean sampling does not fix this.
Representation bias means some groups are missing or rare in the data. A model fit mostly on one group tends to be less accurate for the others. The cause may be where data was collected, such as one region, one device, or one clinic.
Measurement and label bias
Labels are often proxies for what you care about. Arrests stand in for crime, and past spending stands in for health need. If the proxy is recorded differently across groups, the label is biased even when the data is large. Policing patterns, for example, can make arrest rates differ from underlying offense rates.
Features can be mismeasured too. A sensor or survey question may work better for some groups than for others.
Proxies and the "fairness through unawareness" trap
Dropping a sensitive attribute does not remove its influence. Other features can encode it, such as postcode, school, or purchase history. These are called proxies. The sketch below checks whether the remaining features can predict the group.
import numpy as np
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import cross_val_score
rng = np.random.default_rng(0)
n = 2000
group = rng.integers(0, 2, n) # sensitive attribute
postcode = group * 1.5 + rng.normal(size=n) # proxy feature
noise = rng.normal(size=n) # unrelated feature
X = np.column_stack([postcode, noise])
auc = cross_val_score(LogisticRegression(), X, group,
cv=5, scoring="roc_auc").mean()
print(f"AUC for predicting group from features: {auc:.2f}")An AUC well above 0.5 means the features leak group membership. Here it is about 0.8, so removing group from the model would not remove its effect.
Aggregation, evaluation, and deployment bias
Aggregation bias appears when one model is applied to groups whose relationships between features and outcome differ. A single fit can serve the majority well and others poorly.
Evaluation bias appears when the test set does not reflect the people the model will serve, or when one overall score hides group differences. An accuracy of 90% can coexist with 70% for a small group.
Deployment bias appears when the model is used in a different setting or for a different purpose than it was built for. A risk score built to allocate support may later be used to deny it.
Feedback loops are a special case. If predictions change who gets observed or treated, the next round of data reflects those decisions. A model that sends more patrols to one area will record more incidents there.
Mapping source to check
| Source | Typical symptom | First check |
|---|---|---|
| Historical bias | Gaps mirror past decisions | Compare outcomes in the data by group |
| Representation bias | Worse error for a rare group | Group counts and per-group error |
| Label bias | Labels disagree with ground truth | Audit how labels were produced |
| Proxy features | Group predictable from features | Proxy test like the one above |
| Evaluation bias | Overall score hides gaps | Per-group metrics |
| Deployment bias | Performance drifts after launch | Monitor by group in production |
Common errors
- Treating "we removed the sensitive column" as evidence of fairness.
- Auditing the model but not the labels.
- Checking one overall metric and stopping.
- Assuming a fair result at training time still holds after deployment.
Exercise
A hospital model predicts "high need" using past healthcare spending as the label. Spending is lower for one group with equal illness because of unequal access to care. Which kind of bias is this, and why does adding more training data not fix it?
Show answer
This is label (measurement) bias, because spending is a biased proxy for need. More data reproduces the same biased proxy, so the gap persists. The fix is to change or validate the label, for example by using clinical measures of need.