Simple Algorithm
Machine Learning · Convergence · 28 min

Fair Classification

Criteria, impossibility theorems and interventions.

Group fairness criteria are conditional independence statements, and conditional independence has a logic of its own. This lesson proves which criteria exclude each other, proves the Kleinberg–Mullainathan–Raghavan impossibility theorem, and then turns to what can be done: optimal post-processing, reweighing and reductions with guarantees, fairness for individuals and counterfactuals, and the finding that static constraints can harm the very groups they aim to protect.

What you’ll learn

  • State independence, separation and sufficiency, and prove their pairwise incompatibilities together with the conditions under which they hold.
  • Prove the Kleinberg–Mullainathan–Raghavan theorem and describe its approximate version.
  • Derive optimal post-processing for equalized odds as the minimization of a linear loss over the intersection of the groups' ROC convex hulls, and explain reweighing, learned representations and the reductions approach.
  • Contrast group criteria with individual fairness, counterfactual fairness and multicalibration, and explain the delayed-impact results.

Three criteria as independence statements

DerivationProofs
  1. P(r,y∣a)=P(y∣r,a) P(r∣a)=P(y∣r) P(r)=P(r,y)⟹A⊥ ⁣ ⁣ ⁣⊥YP(r,y\mid a)=P(y\mid r,a)\,P(r\mid a)=P(y\mid r)\,P(r)=P(r,y)\quad\Longrightarrow\quad A\indep Y

    (1) Independence and sufficiency together make AA independent of the pair (R,Y)(R,Y), hence of YY:

  2. P(R=r∣A=a)=(1−pa) P(R=r∣Y=0)+pa P(R=r∣Y=1)  is the same for all aP(R=r\mid A=a)=(1-p_a)\,P(R=r\mid Y=0)+p_a\,P(R=r\mid Y=1)\ \ \text{is the same for all }a

    (2) Write pa=P(Y=1∣A=a)p_a=P(Y=1\mid A=a). Separation lets the class-conditional score laws drop the group; independence says the mixture does not depend on aa:

  3. (pa−pb)[P(R=r∣Y=1)−P(R=r∣Y=0)]=0⟹R⊥ ⁣ ⁣ ⁣⊥Y(p_a-p_b)\big[P(R=r\mid Y=1)-P(R=r\mid Y=0)\big]=0\quad\Longrightarrow\quad R\indep Y

    Two groups with pa≠pbp_a\ne p_b then force P(R=r∣Y=1)=P(R=r∣Y=0)P(R=r\mid Y=1)=P(R=r\mid Y=0) for every rr: the score carries no information about YY, contradicting R⊥̸ ⁣ ⁣ ⁣⊥YR\not\indep Y.

  4. A⊥ ⁣ ⁣ ⁣⊥R∣Y  ∧  A⊥ ⁣ ⁣ ⁣⊥Y∣R  ⇒ P>0   A⊥ ⁣ ⁣ ⁣⊥(R,Y)A\indep R\mid Y\ \ \wedge\ \ A\indep Y\mid R\ \ \xRightarrow{\ P>0\ }\ \ A\indep(R,Y)

    (3) For strictly positive distributions, conditional independence has the intersection property: A⊥ ⁣ ⁣ ⁣⊥R∣YA\indep R\mid Y and A⊥ ⁣ ⁣ ⁣⊥Y∣RA\indep Y\mid R together imply A⊥ ⁣ ⁣ ⁣⊥(R,Y)A\indep(R,Y), and so A⊥ ⁣ ⁣ ⁣⊥YA\indep Y, a contradiction. Without positivity the property can fail; the canonical exception is perfect prediction, R=YR=Y, which satisfies both criteria.

Check your understanding

A risk score is calibrated within each group, and the groups' base rates differ. Can its distribution also be the same in both groups?

  1. Yes, if the score is accurate enough
  2. Yes, by adding noise to the scores of one group
  3. Only if the score is a constant
  4. No: calibration gives sufficiency, and sufficiency with independence would force equal base rates
Show the answer

D. No: calibration gives sufficiency, and sufficiency with independence would force equal base rates

Part (1) of the theorem: Y⊥ ⁣ ⁣ ⁣⊥A∣RY\indep A\mid R and R⊥ ⁣ ⁣ ⁣⊥AR\indep A imply A⊥ ⁣ ⁣ ⁣⊥YA\indep Y, so the base rates would be equal. Even a constant score cannot escape: calibrated within groups, it would have to equal each group's base rate, which then differ.

The Kleinberg–Mullainathan–Raghavan theorem

DerivationProof: two lines through one point
  1. ∑i∈group tE[scorei]=μt\sum_{i\in\text{group }t}\E[\text{score}_i]=\mu_t

    In group tt, with NtN_t people of whom μt\mu_t are expected to be positive, calibration says that in every bin the expected number of positives equals the total score in that bin. Summing over bins:

  2. (Nt−μt) x+μt y=μt⟺(1−pt) x+pt y=pt,pt=μt/Nt(N_t-\mu_t)\,x+\mu_t\,y=\mu_t\qquad\Longleftrightarrow\qquad(1-p_t)\,x+p_t\,y=p_t,\quad p_t=\mu_t/N_t

    Let xx be the average score of negatives and yy that of positives. By balance, xx and yy are the same in both groups. Splitting the total score into negatives and positives gives one linear equation per group:

  3. p1≠p2 ⟹ (x,y)=(0,1)p_1\ne p_2\ \Longrightarrow\ (x,y)=(0,1)

    Each equation is a line in the (x,y)(x,y) plane passing through (0,1)(0,1), since (1−pt)⋅0+pt⋅1=pt(1-p_t)\cdot0+p_t\cdot1=p_t. Equal base rates give the same line, so the equations do not conflict (a single bin with score pp for everyone satisfies all three conditions). Different base rates give two distinct lines, which meet only at (0,1)(0,1): negatives score 0 and positives score 1 on average, which with scores in [0,1][0,1] means perfect prediction.

The theorem is about scores, but the same tension holds for binary decisions (Chouldechova's identity in Fairness, Interpretability & Causality). Pleiss, Raghavan, Wu, Kleinberg & Weinberger (2017) asked what survives if one relaxes to calibration plus a single error-rate constraint, such as equal false-negative rates: it is achievable, but any algorithm achieving it is no better than taking an existing calibrated classifier and randomizing a fraction of its predictions for one group. Calibration and error-rate balance are, in this precise sense, at odds.

Optimal post-processing

Hardt, Price & Srebro (2016) asked for the best predictor Y~\tilde Y that satisfies equalized odds and is derived from an existing score RR and the group AA alone. For group aa, every threshold on RR gives a point (FPR,TPR)(\mathrm{FPR},\mathrm{TPR}) on that group's ROC curve, and flipping a biased coin between two thresholds gives any point on the segment between them. So the achievable rates for group aa form DaD_a, the convex hull of its ROC curve. Equalized odds requires one common point γ=(γ0,γ1)\boldsymbol\gamma=(\gamma_0,\gamma_1) in every DaD_a, and the expected loss is linear in it:

min⁡γ∈⋂aDa ∑aP(A=a)[cFP P(Y=0∣A=a) γ0+cFN P(Y=1∣A=a) (1−γ1)].\min_{\boldsymbol\gamma\in\bigcap_aD_a}\ \sum_aP(A=a)\Big[c_{\mathrm{FP}}\,P(Y=0\mid A=a)\,\gamma_0+c_{\mathrm{FN}}\,P(Y=1\mid A=a)\,(1-\gamma_1)\Big].

For a binary predictor Y^\hat Y each hull is a quadrilateral and the problem is a linear program in four variables. For a score the problem stays convex (a linear program when there are finitely many thresholds), and each group uses a threshold or a randomized mixture of two. Equal opportunity constrains only γ1\gamma_1: with continuous scores whose ROC curves are concave, as for a score calibrated within each group, each group just needs its own deterministic threshold.

The widget's data show what randomization buys (our computation on its applicants, with its whole-number thresholds). Group B's ROC hull lies inside A's, so the intersection of the hulls is B's hull, and the best common operating point is B's own vertex at threshold 58, with false-positive rate 14.3% and true-positive rate 56.7%. Group B reaches it with a plain threshold; group A, whose curve passes far above that point, must mix two thresholds to land on it. Overall accuracy is 74.1% with exactly equal rates, against 67.3% for the best deterministic pair within 2 points. The price is paid by A: its accuracy falls from 86.0% to 71.2% while B's stays at 77.0%, close to B's best of 77.5%. Post-processing cannot lift the poorly measured group above its own ROC curve, so equalizing error rates degrades predictions for the well-measured group instead, a form of "leveling down". Hardt, Price & Srebro present this as shifting the cost of poor classification from the disadvantaged group to the decision-maker, who can respond by improving the classification accuracy.

Corbett-Davies, Pierson, Feller, Goel & Huq (2017) made the decision-theoretic version precise: the unconstrained utility-maximizing rule is a single threshold on calibrated risk for everyone, while the optimal rules under several fairness constraints use group-specific thresholds. A constraint that binds lowers the objective it overrides, and their study of pretrial decisions found that this trade-off can be large in practice.

Predict before you look

Reweighing (Kamiran & Calders, 2012) gives each training example the weight w(a,y)=P(A=a) P(Y=y)/P(A=a,Y=y)w(a,y)=P(A=a)\,P(Y=y)/P(A=a,Y=y). Group aa is half the data, 30% of its members are positive, and 40% of all examples are positive. What weight does a positive example from group aa receive?

Show the answer

1.33

P(A=a,Y=1)=0.5⋅0.3=0.15P(A=a,Y=1)=0.5\cdot0.3=0.15, so w=0.5⋅0.4/0.15=4/3w=0.5\cdot0.4/0.15=4/3. Under the weights, the joint law becomes P(a)P(y)P(a)P(y): group and label are independent in the reweighted data, so a learner fitted to it is pushed toward demographic parity, while each example keeps its features and label.

Pre-processing and in-processing

Pre-processing changes the data. Besides reweighing, Zemel, Wu, Swersky, Pitassi & Dwork (2013) learned a representation, a soft assignment of each example to a set of prototypes, by minimizing a weighted sum of three losses: one making the two groups' distributions over prototypes equal, one preserving information about the inputs, and one keeping the representation predictive of the label. A downstream classifier that sees only the prototype inherits parity, but only to the extent that the penalty achieved it: parity is one term in a trade-off, not a hard constraint, and a model that also uses other features gets no guarantee.

In-processing changes the learning problem. The reductions approach of Agarwal, Beygelzimer, Dudík, Langford & Wallach (2018) writes many criteria, including demographic parity and equalized odds, as linear constraints Mμ(Q)≤cM\boldsymbol\mu(Q)\le\mathbf c on conditional moments of a randomized classifier QQ, and solves the saddle-point problem of the Lagrangian:

min⁡Q max⁡λ≥0, ∥λ∥1≤B  err(Q)+λ⊤(Mμ(Q)−c).\min_Q\ \max_{\boldsymbol\lambda\ge0,\ \norm{\boldsymbol\lambda}_1\le B}\ \ \mathrm{err}(Q)+\boldsymbol\lambda^\top\big(M\boldsymbol\mu(Q)-\mathbf c\big).

For fixed λ\boldsymbol\lambda the inner minimization is a cost-sensitive classification problem, which any standard learner can solve, while λ\boldsymbol\lambda is updated by exponentiated gradient. If the classifier family has Rademacher complexity of order n−αn^{-\alpha} (with α=1/2\alpha=1/2 for most families, including those of finite VC dimension), the returned randomized classifier has error within O~(n−α)\tilde O(n^{-\alpha}) of the best fair randomized classifier and violates each constraint by at most O~(nj−α)\tilde O(n_j^{-\alpha}), where njn_j counts the training examples in the subgroup the constraint concerns (a group, or a group and label), with high probability.

StageMethodNeeds at prediction timeGuarantee
Pre-processingreweighing; learned fair representationsnothing extragroup and label independent in the reweighted data, or approximate parity of the representation; nothing about a downstream model's predictions or errors
In-processingreductions (exponentiated gradient over a cost-sensitive learner); constrained lossesa randomized classifiernear-optimal error among fair randomized classifiers, up to O~(n−α)\tilde O(n^{-\alpha})
Post-processinggroup-specific (randomized) thresholds on a scorethe group attributeoptimal among predictors derived from the score; optimal overall if the score is Bayes-optimal
Using the group attribute at prediction time, as post-processing does, can be legally restricted in some domains, a practical constraint that often decides between the three.

Beyond group averages

Group criteria constrain averages and can be satisfied while individuals are treated arbitrarily: a classifier can meet parity by approving the most qualified members of one group and random members of the other. Several notions aim deeper.

  • Individual fairness (Dwork, Hardt, Pitassi, Reingold & Zemel, 2012): similar individuals should be treated similarly. Map each individual xx to a distribution M(x)M(x) over outcomes and require the Lipschitz condition D(M(x),M(x′))≤d(x,x′)D\big(M(x),M(x')\big)\le d(x,x') for a task-specific similarity metric dd. Maximizing utility under the constraint is a linear program. Everything rests on the metric, which someone must specify and defend.
  • Counterfactual fairness (Kusner, Loftus, Russell & Silva, 2017): given a causal model with background variables UU, a predictor is counterfactually fair if, for every individual, its distribution would be the same had the individual's group been different: P(Y^A←a(U)=y∣X=x,A=a)=P(Y^A←a′(U)=y∣X=x,A=a)P\big(\hat Y_{A\leftarrow a}(U)=y\mid\mathbf X=\mathbf x,A=a\big)=P\big(\hat Y_{A\leftarrow a'}(U)=y\mid\mathbf X=\mathbf x,A=a\big). It requires committing to a causal model of how the group affects the features.
  • Many groups at once. Fairness on two groups can hide unfairness on their intersections ("fairness gerrymandering"). Kearns, Neel, Roth & Wu (2018) demanded statistical parity, or equal false-positive rates, for every subgroup in a rich class defined by functions of the protected attributes, and showed that auditing this is equivalent to weak agnostic learning, hard in the worst case but tractable with learning oracles. Multicalibration (Hébert-Johnson, Kim, Reingold & Rothblum, 2018) asks for calibration on every subgroup identifiable by a class of computations; the authors show that in many settings it is attainable and aligned with the goal of accurate prediction.

Key takeaways

  • Independence (R⊥ ⁣ ⁣ ⁣⊥AR\indep A), separation (R⊥ ⁣ ⁣ ⁣⊥A∣YR\indep A\mid Y) and sufficiency (Y⊥ ⁣ ⁣ ⁣⊥A∣RY\indep A\mid R) are pairwise incompatible when base rates differ, outside degenerate cases; the proofs are two lines of probability and the intersection property.
  • Kleinberg–Mullainathan–Raghavan: calibration within groups plus balance for both classes forces equal base rates or perfect prediction, because each group's constraint is a line through (0,1)(0,1); approximate versions hold too.
  • Optimal post-processing for equalized odds minimizes a linear loss over the intersection of the groups' ROC hulls (a linear program for a binary predictor), with randomized thresholds; it loses nothing if the score is Bayes-optimal, and on unequally informative scores it equalizes by degrading the better-measured group.
  • Reweighing makes group and label independent in the training data; reductions solve fair classification with cost-sensitive learners and exponentiated gradient, to within O~(n−α)\tilde O(n^{-\alpha}).
  • Individual fairness needs a similarity metric, counterfactual fairness a causal model, and subgroup fairness rich classes; static constraints can cause long-term harm.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

Base rates differ between two groups, and every combination of group, score and outcome has positive probability. Can a score satisfy separation and sufficiency at the same time?

  1. Yes, if it is calibrated within groups
  2. Yes, if it is accurate enough
  3. No: by the intersection property the two together would make the group independent of the outcome
  4. Only if the groups have the same size
Show the answer

C. No: by the intersection property the two together would make the group independent of the outcome

For strictly positive distributions, A⊥ ⁣ ⁣ ⁣⊥R∣YA\indep R\mid Y and A⊥ ⁣ ⁣ ⁣⊥Y∣RA\indep Y\mid R imply A⊥ ⁣ ⁣ ⁣⊥(R,Y)A\indep(R,Y), hence equal base rates. Perfect prediction escapes only because it violates positivity.

Question 2

Suppose a risk assignment is calibrated within groups and balanced for both classes, in groups with base rates 0.6 and 0.2. What must the average scores (x,y)(x,y) of negatives and positives be?

  1. (0.2, 0.6)(0.2,\ 0.6)
  2. (0.4, 0.4)(0.4,\ 0.4)
  3. (0, 1)(0,\ 1)
  4. No such assignment exists
Show the answer

C. (0, 1)(0,\ 1)

Each group gives a line (1−pt)x+pty=pt(1-p_t)x+p_ty=p_t through (0,1)(0,1); with p1=0.6≠p2=0.2p_1=0.6\ne p_2=0.2 the lines are distinct and meet only at (0,1)(0,1). An assignment exists only in the perfect-prediction case, where it is forced to this point.

Question 3

In Hardt, Price & Srebro's post-processing for equalized odds, why may one group's predictor be randomized?

  1. To hide the group attribute from the decision-maker
  2. To reach a common (FPR, TPR) point that lies strictly below that group's ROC curve, which no single threshold attains
  3. Because randomization always increases accuracy
  4. To satisfy demographic parity as well
Show the answer

B. To reach a common (FPR, TPR) point that lies strictly below that group's ROC curve, which no single threshold attains

The common operating point must lie in every group's ROC hull. For the group with the better ROC curve it is typically an interior point, reachable only as a mixture of two thresholds.

Question 4

In the one-step lending model of Liu et al. (2018), how can a demographic parity constraint harm the disadvantaged group?

  1. By approving too few of its members
  2. It cannot: fairness constraints only help the protected group
  3. By lowering the lender's profit
  4. By approving so many of its members that the resulting defaults lower the group's average credit score
Show the answer

D. By approving so many of its members that the resulting defaults lower the group's average credit score

Approvals change scores: repayment raises them, default lowers them. Forcing equal approval rates can push the threshold for the disadvantaged group so low that the expected change in its average score turns negative, an "active harm" the unconstrained policy would not cause.

Further reading

  • J. Kleinberg, S. Mullainathan & M. Raghavan, "Inherent trade-offs in the fair determination of risk scores," Innovations in Theoretical Computer Science (ITCS) (2017).
  • M. Hardt, E. Price & N. Srebro, "Equality of opportunity in supervised learning," Advances in Neural Information Processing Systems 29 (2016).
  • A. Agarwal, A. Beygelzimer, M. Dudík, J. Langford & H. Wallach, "A reductions approach to fair classification," ICML (2018).
  • C. Dwork, M. Hardt, T. Pitassi, O. Reingold & R. Zemel, "Fairness through awareness," Proceedings of the 3rd Innovations in Theoretical Computer Science Conference, 214–226 (2012).
  • S. Barocas, M. Hardt & A. Narayanan, Fairness and Machine Learning: Limitations and Opportunities (MIT Press, 2023).