Counterfactual Fairness Assessment
Description
Counterfactual Fairness Assessment tests whether a model would have made the same predictions for a person had their protected attribute, such as race or sex, been different, with everything that attribute influences changed accordingly (Kusner et al., 2017). The assessor first draws a causal graph, a diagram of which variables cause which, covering the protected attribute, the model's inputs and unobserved background factors, and fits it to data. For each person, the fitted graph is used to infer their background factors, switch the attribute to another value and recompute every input it influences, which gives a counterfactual version of that person. The model is run on both versions, and the gap between the two predictions, person by person or as a distance between the two sets of predictions, is the evidence for or against counterfactual fairness under the assumed graph. Every causal effect of the attribute counts as unfair, including effects passing through inputs such as test scores, which separates this criterion from versions that allow some pathways.
Example Use Cases
Fairness
A law school's admissions office uses a model to predict first-year grades from entrance-test scores and undergraduate grades. Its analysts build a causal model in which race and sex influence both inputs alongside an unobserved knowledge factor, fit it to past cohorts, and compare each applicant's predicted grade under actual and counterfactual race. A systematic shift shows that leaving race out of the inputs did not make the model counterfactually fair.
A credit risk team, working with economists, specifies a causal graph in which an applicant's ethnicity affects income and neighbourhood but not repayment behaviour directly, fits it to its applicant data, and checks whether the approval model's scores change for the counterfactual applicants. The result goes to the model risk committee together with the graph, because the conclusion holds only under that graph.
A public employment service reviewing a model that predicts job-seekers' risk of long-term unemployment from education and work history specifies, with labour-market researchers, how sex and migration background influence those inputs. It tests whether individual risk scores would change under counterfactual sex or migration background before the scores are used to allocate support.
Limitations
- The causal model can have testable implications, but its counterfactual assumptions are generally not identifiable from observed or experimental data. Plausible alternative models can therefore produce different fairness conclusions.
- A common cause left out of the graph, such as school quality affecting both test scores and later grades, biases the counterfactuals without any warning sign. Kilbertus et al. (2019) show that counterfactual fairness is sensitive to such unmeasured confounding and give tools to bound the effect for additive noise models, which adds a further analysis to do.
- Every effect of the attribute counts as unfair, so a model that uses an input the attribute influences will usually fail the test, unless those effects cancel out. Kusner et al. note that in practice few observed variables are unaffected by the attribute. Where some pathways are acceptable, for example where qualifications differ for reasons a decision may properly reflect, this criterion is stricter than the decision calls for.
- Computing individual counterfactuals requires a fitted probabilistic model of the unobserved background factors; the original study fitted it in Stan, and DoWhy's counterfactual function needs mechanisms with additive noise and supports only continuous variables. With categorical inputs, many variables or unstructured data such as text and images, the assessment becomes hard to run or yields a spread of counterfactuals rather than one.
- The counterfactual people are simulated by the fitted causal model, not observed. If its equations fit the data poorly or miss interactions, the counterfactual inputs are implausible and the measured gap reflects the causal model's errors as much as the predictor's; DoWhy's documentation notes counterfactual estimates are approximate for this reason.
Resources
Research Papers
Counterfactual Fairness
Machine learning can impact people with legal or ethical consequences when it is used to automate decisions in areas such as insurance, lending, hiring, and predictive policing. In many of these scenarios, previous decisions have been made that are unfairly biased against certain subpopulations, for example those of a particular race, gender, or sexual orientation. Since this past data may be biased, machine learning predictors must account for this to avoid perpetuating or creating discriminatory practices. In this paper, we develop a framework for modeling fairness using tools from causal inference. Our definition of counterfactual fairness captures the intuition that a decision is fair towards an individual if it the same in (a) the actual world and (b) a counterfactual world where the individual belonged to a different demographic group. We demonstrate our framework on a real-world problem of fair prediction of success in law school.
Software Packages
DoWhy: a Python library for causal inference (py-why/dowhy)
DoWhy is a Python library for causal inference that supports explicit modeling and testing of causal assumptions. DoWhy is based on a unified language for causal inference, combining causal graphical models and potential outcomes frameworks.