Bias Mitigation Techniques
Pre-, in- and post-processing interventions.
An audit finds a disparity. You can change the data, the training objective or the decisions, and each lever has a precise form with a guarantee: reweighing makes the label independent of the group, the reductions approach turns any classifier learner into a fair one with provable error, and group-specific thresholds reach equal error rates at the least cost a given score allows. Counterfactual fairness asks a different, causal question. Every lever also has a price, and this lesson computes it.
What you’ll learn
- Derive reweighing weights, prove that they make the group and the label independent while preserving both marginals, and explain what pre-processing cannot guarantee.
- Formulate fair classification as a saddle-point problem, describe the exponentiated-gradient reduction, and prove the error and violation guarantees of an approximate saddle point.
- Derive equalized-odds post-processing as a linear program over ROC curves, and quantify its cost, including leveling down, in the widget.
- Define counterfactual fairness, prove the non-descendant sufficient condition, and summarize the main critiques.
Where to intervene
| Stage | What changes | Needs when deciding? | What is guaranteed | Examples |
|---|---|---|---|---|
| Pre-processing | the training data or features | no | properties of the data, such as , not of the classifier | reweighing, fair representations, disparate-impact repair |
| In-processing | the learning objective | not necessarily | constraints on the training distribution, with generalization bounds | the reductions approach, adversarial debiasing |
| Post-processing | the decision rule applied to a fixed score | yes | the chosen criterion, exactly, on the data used to fit it | group-specific thresholds (Hardt, Price & Srebro, 2016) |
Law shapes the choice. Post-processing applies different thresholds to different groups, an explicit use of the group attribute at decision time, and in US employment testing the Civil Rights Act of 1991 forbids adjusting scores or using different cutoffs by race, color, religion, sex or national origin. Using only during training avoids that explicit use, but Lipton, McAuley & Chouldechova (2018) show that when other features reveal group membership, such "disparate learning processes" implement group-dependent treatment indirectly, discriminate within groups, and trade accuracy for parity worse than an open, group-aware rule.
Pre-processing: reweighing and representations
Give each training example in the cell the weight , estimated from counts. The reweighted distribution is already normalized:
Its cell probabilities factorize, so under the label is independent of the group, and both marginals are unchanged:
Within a cell nothing changes, so reweighing only rebalances how much each (group, outcome) combination counts in the loss:
In the loan data of Bias & Fairness, the groups are equal in size, and 50% of A and 30% of B would repay, so 40% overall. What weight does reweighing give a repayer in group B?
Show the answer
1.33
. The other weights are 0.8 for repayers in A, 1.2 for defaulters in A and for defaulters in B. Under these weights both groups repay at 40%.
What reweighing does not do: a classifier trained on still sees features whose distribution differs by group, so its predictions need not satisfy parity, and no reweighting repairs a label that is itself biased. Representation methods go further and learn features that predict but carry little information about , either by mapping individuals to prototypes under an objective that balances reconstruction, prediction and parity (learning fair representations; Zemel et al., 2013) or by training against an adversary that tries to recover from (Edwards & Storkey, 2016; Madras et al., 2018). If exactly, every classifier built on satisfies demographic parity, and nothing more. In practice adversarial removal often leaves group information that a fresh classifier can still extract (Elazar & Goldberg, 2018). Feldman et al. (2015) instead "repair" each feature by mapping every group's quantiles onto a common distribution, which removes the feature's marginal information about while preserving ranks within groups.
In-processing: fair classification as a game
Agarwal, Beygelzimer, Dudík, Langford & Wallach (2018) handle any constraint that is linear in conditional moments of the predictions. A randomized classifier is a distribution over a class , and the constraints read , with averaged over . Demographic parity, for instance, is the pair of constraints for each group, and equalized odds conditions on as well. Fair classification becomes
function EXPONENTIATED-GRADIENT(data, BEST, B, η, ν):
θ ← 0 ∈ R^K # log-prices of the K constraints
for t = 1, 2, …:
λ(t) ← B · exp(θ) / (1 + Σ_k exp(θ_k)) # prices in the scaled simplex
h(t) ← BEST(λ(t)) # minimizes err(h) + λ(t)ᵀγ(h): a cost-sensitive
# (reweighted, relabeled) classification problem
Q̂ ← uniform mixture of h(1..t); λ̂ ← average of λ(1..t)
if (Q̂, λ̂) is a ν-approximate saddle point: return Q̂
θ ← θ + η · (γ(h(t)) − c) # raise the price of violated constraintsBecause is linear in the predictions , the learner's best response is a weighted classification problem: each example gets a cost for predicting 0 and a cost for predicting 1, and any classifier that accepts example weights can solve it. That is the reduction. Agarwal et al. show that a -approximate saddle point is reached within iterations, up to a factor for the scale of the constraints, and add finite-sample guarantees. The method is implemented in the open-source Fairlearn library.
Error. Take in the auditor's inequality and in the learner's. Since and , the price term at is at most zero:
Violation. Let and suppose . Put the whole budget on the most violated constraint, , in the auditor's inequality, and again take in the learner's:
Errors lie in , so . A larger price budget tightens the constraints but slows convergence, the trade-off visible in the iteration count.
Adversarial debiasing (Zhang, Lemoine & Mitchell, 2018) is the deep-learning cousin: the predictor minimizes its loss while an adversary tries to predict from the prediction, and from as well when the target is equalized odds. It scales to large networks but comes with no comparable guarantee.
Post-processing: thresholds and ROC geometry
Hardt, Price & Srebro (2016) start from a fixed score and the group attribute, and derive a randomized decision that depends only on . Within group , each threshold gives a point (FPR, TPR) on the group's ROC curve, and randomizing between two thresholds reaches every point of the segment between them, so the achievable points form the convex hull of the curve. Equalized odds asks for one common point in ; equal opportunity only for equal TPRs.
In the loan data of Bias & Fairness, group A's ROC curve lies above B's at every false-positive rate, so and the feasible set is B's hull. With equal group sizes and base rates 0.5 and 0.3, the objective is , whose level lines have slope in ROC space:
That vertex is B's threshold 58, with FPR 14.3% and TPR 56.7%. Group A must land on the same point, which it can do only by randomizing between two of its thresholds, deliberately making its decisions noisier:
Overall accuracy is 74.1%, better than the 67.3% of the best deterministic equalized-odds thresholds. But A's accuracy falls from 86.0% to 71.2% and its repayers' approval rate from 90% to 57%, while B's accuracy moves from 77.5% to 77.0%. Equality is reached by making one group worse off with no gain for the other, which critics call leveling down.
Is the price of equalized odds a base-rate effect? The widget below gives both groups the same base rate, 50%, but keeps group B's noisier scores.
Counterfactual fairness
Proof. Intervening on changes only 's descendants. For a non-descendant , for every , so for every , and the two conditional distributions coincide. In Kusner et al.'s law-school example, undergraduate GPA and the admission-test score both depend on race, sex and an unobserved "knowledge" . A predictor of first-year grades built on the raw scores is not counterfactually fair, because both scores are descendants of race. One built on , inferred from the observed scores through the causal model, is fair by the lemma, and in their experiments it gave up some accuracy.
The approach inherits every assumption of the causal model, which usually cannot be identified from data, and different plausible graphs give different verdicts. Treating race as a variable one can intervene on is itself contested: Kohler-Hausmann (2019) argues that race is a social category constituted by many of the very features a counterfactual would hold fixed or change, so "the same person with a different race" is not well defined. Path-specific variants (Nabi & Shpitser, 2018; Chiappa, 2019) let some causal paths from count as acceptable, for example through a chosen field of study, at the cost of deciding which paths those are.
Key takeaways
- Pre-, in- and post-processing intervene on the data, the objective and the decisions; they differ in when they need , in what they guarantee, and in how they interact with anti-discrimination law.
- Reweighing by makes and independent while preserving both marginals, but guarantees nothing about predictions; invariant representations guarantee parity at most.
- The reductions approach solves with exponentiated gradient and a cost-sensitive oracle; a -approximate saddle point has error within of the best feasible classifier and violations of at most .
- Post-processing picks a point in the intersection of the groups' ROC hulls by linear programming. When one group's score is less informative, equal error rates are reached by leveling the other group down.
- Counterfactual fairness asks whether an individual's prediction would change under a different group attribute; functions of non-descendants of satisfy it, but the verdict depends on a contested causal model.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Reweighing with guarantees which of the following?
- Demographic parity of the trained classifier's predictions
- Independence of and in the reweighted training distribution, with both marginals unchanged
- Equalized odds of the trained classifier
- That biased labels are corrected
Show the answer
B. Independence of and in the reweighted training distribution, with both marginals unchanged
by construction, while , and . That is a property of the training data. The classifier still sees group-dependent features, so properties of its predictions must be checked separately.
Why does the reductions approach return a randomized classifier, a mixture over ?
- Randomness always improves accuracy
- The constrained problem is a game that is linear in distributions over ; mixtures convexify it, and a single deterministic classifier may not reach the same error and constraint values
- The cost-sensitive oracle is itself random
- Randomization is required for privacy
Show the answer
B. The constrained problem is a game that is linear in distributions over ; mixtures convexify it, and a single deterministic classifier may not reach the same error and constraint values
Error and the moment constraints are linear in , so the feasible set of mixtures is convex and the Lagrangian game has a saddle point among them; exponentiated gradient's output is the average of the best responses. Deterministic classifiers form a non-convex set on which the same trade-off may be unattainable.
In the loan data, randomized post-processing for equalized odds raises overall accuracy from 67.3%, with the best deterministic thresholds, to 74.1%. What happens to each group compared with its own most accurate thresholds?
- Both groups become more accurate
- Group A's accuracy falls from 86.0% to 71.2% and its repayers' approval rate from 90% to 57%, while group B stays near its best (77.0% against 77.5%)
- Group B gains about 10 points of accuracy
- Nothing changes for group A
Show the answer
B. Group A's accuracy falls from 86.0% to 71.2% and its repayers' approval rate from 90% to 57%, while group B stays near its best (77.0% against 77.5%)
B's ROC curve lies below A's, so the common operating point must lie on B's hull, at B's threshold 58. A can reach that point only by randomizing, which makes its decisions noisier. Equality is bought by lowering A to B's level: leveling down.
Which predictor is guaranteed to be counterfactually fair?
- One that excludes from its inputs
- One that satisfies demographic parity
- One that is calibrated within groups
- One that is a function only of variables that are not descendants of in the causal graph
Show the answer
D. One that is a function only of variables that are not descendants of in the causal graph
Intervening on changes only its descendants, so a function of non-descendants takes the same value for every in the actual and the counterfactual world. Excluding is not enough: features caused by carry its effect.
Further reading
- F. Kamiran & T. Calders, "Data preprocessing techniques for classification without discrimination," Knowledge and Information Systems (2012).
- A. Agarwal, A. Beygelzimer, M. Dudík, J. Langford & H. Wallach, "A reductions approach to fair classification," ICML (2018).
- M. Hardt, E. Price & N. Srebro, "Equality of opportunity in supervised learning," NeurIPS (2016).
- M. J. Kusner, J. Loftus, C. Russell & R. Silva, "Counterfactual fairness," NeurIPS (2017).
- N. Mehrabi, F. Morstatter, N. Saxena, K. Lerman & A. Galstyan, "A survey on bias and fairness in machine learning," ACM Computing Surveys (2021).