Sub topic 1
Why fairness assessment matters: harms and context
Prerequisites
This chapter assumes you know the following:
- Binary classification and the confusion matrix (TP, FP, TN, FN).
- Precision, recall, and false positive rate.
- Train/test splits and model evaluation.
- Basic Python with NumPy, pandas, and scikit-learn.
No fairness background is needed. This chapter sets up the vocabulary and the questions that the later metric chapters answer.
What fairness assessment is
Fairness assessment is the practice of measuring whether a model's outcomes or errors differ across groups of people, and deciding whether those differences are acceptable. It is a measurement task. It does not tell you what is just. It tells you where a model treats groups differently so that people can decide what to do.
A single accuracy number hides these differences. A model with 92% overall accuracy can be 96% accurate for a large group and 80% accurate for a small one. The overall figure is an average, and averages follow the majority.
Two kinds of harm
Researchers commonly separate harms into two kinds.
| Harm | What happens | Example |
|---|---|---|
| Allocation | A resource or opportunity is given or withheld unequally | A loan model rejects qualified applicants from one group more often |
| Quality of service | The system works worse for some people | A speech recognizer has higher error rates for some accents |
Other harms exist, such as stereotyping and demeaning outputs, but allocation and quality-of-service harms are the ones that group metrics measure most directly. Those two are the focus of this tutorial.
The same error costs different things
Whether a false positive or a false negative is the worse mistake depends on the deployment. The metric you care about follows from that.
- In screening for a benefit such as a loan or a job interview, a false negative withholds something the person deserved. Gaps in the true positive rate matter most.
- In a system that triggers a penalty, such as fraud flags or risk scores used in detention decisions, a false positive punishes someone who did nothing wrong. Gaps in the false positive rate matter most.
- When a person acts on the prediction, such as a doctor reading a risk score, the reliability of a positive prediction matters. Gaps in precision matter most.
Context decides what "fair" means
Two models with identical confusion matrices can be fair in one setting and unfair in another. Four questions help you frame the context:
- What decision does the model support, and is a human reviewing it?
- Who bears the cost of each error type?
- Are the labels a trustworthy record of the outcome you care about?
- Is there a legal or policy requirement, such as anti-discrimination law, that applies to this decision?
Question 3 matters more than it looks. If labels come from past human decisions, such as who was hired or arrested, then a model that matches them perfectly can reproduce past bias. The next chapter covers this under sources of bias.
Where assessment fits
Context comes first because every later choice depends on it: which groups to compare, which metric to use, and how large a gap you will tolerate.
A first look at the problem
The following code shows how overall accuracy can hide a gap. It builds a small dataset in which group B has more errors than group A.
import numpy as np
y_true = np.array([1, 0, 1, 0, 1, 0, 1, 0, 1, 0])
y_pred = np.array([1, 0, 1, 0, 1, 0, 0, 0, 0, 1])
group = np.array(["A"] * 5 + ["B"] * 5)
print("overall accuracy:", (y_true == y_pred).mean())
for g in np.unique(group):
m = group == g
print(g, "accuracy:", (y_true[m] == y_pred[m]).mean())Overall accuracy is 0.7. Group A scores 1.0 and group B scores 0.4. The overall number gives no sign of this gap. Later chapters replace accuracy with rates that map to specific harms. This dataset has only five people per group, so a real analysis would also need to check whether such a gap is statistically meaningful.
Exercise
A hospital uses a model to flag patients for an extra follow-up program. Patients who are not flagged get no follow-up. Which harm type is most at stake, and which per-group rate would you check first?
Show answer
Allocation harm, because the follow-up is a resource that is withheld. Check the true positive rate by group first, since a false negative means a patient who needed the program did not get it.