Demographic Fairness: Performance Across Populations
Why models must be evaluated across demographic subgroups (age, sex, race, ethnicity), how to measure disparities, and what to do when performance varies across populations.
A model's headline result is an average over everyone in the test set. Averages are dominated by whoever is most numerous, so a model can do well overall and noticeably worse for a group that makes up a small share of the data. The only way to find out is to break the result down.
This article covers which groups to look at, how to measure a difference between them, why "fair" has several definitions that can't all be satisfied together, and what your options are when you find a gap.
Which groups
The usual starting list is age, sex, and race or ethnicity. These are the ones regulators and journals ask about, and they are the ones with the longest record of unequal care.
We'd encourage going beyond that list where your clinical question suggests it. Body habitus changes image quality in ultrasound and radiography. Skin tone is the variable of interest in dermatology and in anything optical, and it is not the same thing as race. Breast density is the obvious one in mammography. Insurance status or neighborhood can stand in for access to care. Language affects anything built on clinical notes. And care setting (inpatient, outpatient, emergency) is often a bigger source of difference than any demographic.
Groups also intersect. In 2018 Joy Buolamwini and Timnit Gebru tested commercial face analysis software that guessed gender from a photograph. Error rates for lighter-skinned men were under 1%. For darker-skinned women they were as high as about 35%. Neither the breakdown by sex alone nor by skin tone alone showed how bad the worst cell was. The same can happen in a clinical model, so where the numbers allow, look at combinations.
Decide the list before you see the results, and write it into the analysis plan. Subgroups chosen afterwards invite the suspicion that you went looking, in either direction.
Getting the demographic data
There's an obstacle here: you can only analyse subgroups you have recorded. De-identification often strips or coarsens demographics, and race and ethnicity fields in hospital systems are frequently missing, entered by a clerk's guess, or lumped into "other." Plan to keep age, sex and whatever race or ethnicity data exists when the dataset is extracted (see 2.7 De-Identification, Privacy, and Regulatory Compliance for Research Data), and report how each was recorded. Self-reported is the standard to aim for.
If a variable is missing for a third of patients, say so, and report the "unknown" group as a group. It is sometimes the one with the worst performance.
Measuring a gap
Start with the same metrics you report overall, computed within each group: sensitivity, specificity, AUC, and for segmentation the Dice score (see 4.1 Classification Metrics). Use the same decision threshold for every group, since that is how the model will run.
Report sensitivity and specificity separately. A gap in sensitivity means one group's disease is being missed more often. A gap in specificity means one group is getting more false alarms, more callbacks and more unnecessary workups. Those are different harms, and a combined figure such as accuracy can hide one behind the other. Laleh Seyyed-Kalantari and colleagues, in the chest X-ray study described in 7.1, looked specifically at the rate of false "no finding" results, because for a triage tool the cost of being wrongly called healthy is that nobody looks at your film.
Check calibration by group too. A risk score of 20% should mean about a 20% event rate in every group, and it often doesn't (see 4.4 Calibration).
Then put confidence intervals on everything. This is where a lot of subgroup analyses fall apart. If a group contributes 25 positive cases to the test set, a sensitivity of 80% has an interval running from roughly 60% to 93%, which is compatible with the model being fine and with it being pretty bad. A difference between two groups that both have wide intervals may well be noise. An absence of a detectable difference in a tiny subgroup is not evidence of equal performance either. If your claim depends on subgroup performance, size the test set for it (see 4.5 Statistical Significance, Confidence Intervals, and Sample Size for AI Studies).
The definitions of "fair" disagree with each other
The machine learning literature has formal definitions of fairness, and it helps to know the three main ones.
Demographic parity says the model should flag the same proportion of each group. This rarely makes sense in medicine, where disease rates really do differ between groups. A prostate cancer model that flagged women as often as men would not be an improvement.
Equalized odds, proposed by Moritz Hardt and colleagues in 2016, says sensitivity and specificity should be the same in each group. This is the closest to what a clinician means by "works equally well."
Calibration within groups says a given score should mean the same risk in every group.
It would be nice to have the last two together. In general we can't. In 2016 and 2017 Jon Kleinberg and colleagues, and separately Alexandra Chouldechova, proved that when the underlying rate of the condition differs between two groups, a score cannot be calibrated in both and also have equal false positive and false negative rates in both, unless it is a perfect predictor. The result came out of the argument over COMPAS, a recidivism risk score used in US courts, where a ProPublica investigation and the score's developer each showed that the tool was fair by one definition and unfair by the other. Both were right.
For us this means there is no single fairness test to pass. You have to decide which property to hold the model to, and that is a clinical judgment. For a screening or triage tool, where a miss is the main harm, equal sensitivity is usually the priority. For a risk score that a clinician reads as a probability and uses to make a treatment decision, calibration in each group is probably the one to protect. Say which you chose and why.
What to do when you find a gap
First find out why. The remedies are different depending on the cause, and 7.1 Sources of Bias in Medical AI lists the candidates.
If the group was scarce in training, the fix that works best is more data from that group. It is also the slowest and most expensive, which is why people look for alternatives. Oversampling or up-weighting the group during training is the cheap version and sometimes helps (see 2.4 Class Imbalance).
If the labels are worse for that group, no training method will fix it. Relabel a sample with a better reference standard and see whether the gap is in the model or in the labels. A model can look worse on a group simply because the "truth" it is scored against is less reliable there.
If the inputs are worse, because of equipment or image quality, that is a measurement problem, and the answer may be an image quality check or an honest limit on the intended use.
There is also a family of training methods that add a fairness constraint or penalty, pushing the model toward equal error rates. These should be used with some caution. Several evaluations on medical imaging, including work on chest X-ray classifiers by Haoran Zhang and colleagues in 2022, found that the methods which achieved group fairness did so by making performance worse for all groups. This is known as leveling down. A model with 85% sensitivity in both groups is "fairer" than one with 92% and 86%, and every patient is worse off. We'd judge an intervention by whether the worst-off group improved.
Using different thresholds for different groups can equalize sensitivity. It also means treating patients differently by group on purpose, which raises legal and ethical questions, and it only works if group membership is reliably known at the time of use. Take advice before going down that road.
Finally, a perfectly respectable outcome is to narrow the claim. If the model hasn't been shown to work in children, or on a particular skin tone range, the intended use and the paper should say that plainly.
Should race be an input?
This comes up mostly for models built on tabular clinical data. Clinical medicine spent decades with race built into its formulas, in kidney function, lung function, obstetric risk and others. In 2020 Darshali Vyas, Leo Eisenstein and David Jones catalogued these in a New England Journal of Medicine article and argued that many of them direct care away from Black patients on thin evidence. Several have since been revised, including the kidney function equations in 2021.
Race is a social category that correlates with ancestry, environment, access to care and the experience of discrimination. When it improves a prediction, it is usually standing in for one of those, and the model can't tell which. Our suggestion is to leave it out as an input unless you can say what it is a proxy for and why the proxy is acceptable, and to keep it as a variable for auditing. Those are separate jobs. You need race data to check for a disparity even if the model never sees it.
For image models the question is partly moot, since the model can often infer demographics from the pixels whether you supply them or not, as described in 7.1.
What regulators and journals expect
The Good Machine Learning Practice principles ask that datasets represent the intended patient population and that performance be assessed in the important subgroups (see 6.7 Good Machine Learning Practice). In practice an FDA reviewer will expect a table of performance by age, sex, and race or ethnicity, with intervals, and an explanation for any group that is thinly represented. The reporting guidelines for AI studies ask for much the same (see 9.1 Reporting Standards).
A subgroup table with a visible gap and an honest discussion is a better paper than one with no table. Reviewers have learned to be suspicious of the second kind.
The work doesn't end at publication. The mix of patients at a deployment site differs from the test set, and subgroup performance should be part of what gets monitored once a model is in use (see 8.6 Monitoring AI Performance in Production).
Key takeaways
- Overall performance is an average weighted toward the largest groups. Break results down by age, sex, race or ethnicity, and whatever else the clinical task suggests, including combinations where numbers allow.
- Keep demographic data through de-identification. You can't audit what you didn't record.
- Report sensitivity and specificity separately for each group at one common threshold, with confidence intervals, and check calibration by group.
- Small subgroups give wide intervals. Neither a gap nor the lack of one means much without enough cases.
- Formal fairness definitions conflict. When disease rates differ between groups, equal error rates and equal calibration can't both hold, so choose the one that fits the clinical use and say so.
- Find the cause of a gap before fixing it. More data and better labels for the affected group help most. Methods that equalize by making another group worse are not an improvement.
- Keep race for auditing even if you exclude it as an input.
What to read next
- 7.1 Sources of Bias in Medical AI: where a gap is likely to have come from
- 7.3 Generalization Across Devices, Sites, and Geographies: the same analysis for places and equipment
- 4.4 Calibration: Does a 90% Confidence Score Really Mean 90%?: checking that scores mean the same thing in each group
- 4.5 Statistical Significance, Confidence Intervals, and Sample Size for AI Studies: sizing a test set for subgroups
- 7.6 Ethical Frameworks for AI in Healthcare: the justice principle behind all this
This article is part of the AI in Clinical Research Knowledge Base.