What you can actually repair, and where
Three places to intervene
Once a gap is measured, there are exactly three points in the pipeline where you can act. Knowing which one suits your cause of bias saves months of work aimed at the wrong place.
Before the model — pre-processing. Change the data. Collect more examples from under-represented groups, reweight the existing ones, resample, or transform the features to reduce their correlation with group membership.
Inside the model — in-processing. Change the training objective. Add a constraint or a penalty so that the optimiser is penalised for disparity as well as for error. Methods such as exponentiated-gradient reduction and adversarial debiasing sit here.
After the model — post-processing. Leave the model alone and change how its score becomes a decision. Different thresholds per group, or a calibrated adjustment of the outputs.
Each has a characteristic failure. Pre-processing is the most honest when the cause is genuine under-sampling, and useless when the cause is that the world was unequal. In-processing gives the finest control and requires access to training, which most organisations buying a model do not have. Post-processing is the most effective per unit of effort and is legally the most exposed, because explicit per-group thresholds look exactly like the thing anti-discrimination law prohibits.
Match the repair to the door
Recall the four doors bias comes through. The repair follows from which one it came through.
Missing people in the data. Go and collect the data. This is the only cause with a clean fix, and the reason it often does not happen is money, not mathematics. A dermatology model that has seen few dark-skinned patients needs images of dark-skinned patients, not a clever loss function.
A bad proxy for the target. Change what you predict. The single most effective fairness intervention on record — the healthcare algorithm that used spending as a stand-in for illness — was fixed by predicting illness directly. No fairness constraint was needed. When a gap is large and stubborn, look hard at the target variable before touching anything else.
The world was unequal and the data records it faithfully. No data repair is available, because the data is not wrong. Here you are making a policy choice about how to act on an accurate description of an unjust past, and dressing it as a technical fix hides the choice from review.
The threshold. Adjust it, and understand that you are moving harm between two groups of people rather than eliminating it.
The accuracy trade, stated plainly
Almost every fairness intervention costs some overall accuracy. Anyone who tells you otherwise is either measuring accuracy on a metric that hides the loss, or has found a case where the model was badly built to begin with — which is common enough to be worth checking first.
The useful way to hold this is as a curve rather than a point. For a given model you can plot disparity against accuracy and see what a given amount of fairness costs. Frequently the curve is flat near the current operating point: a large reduction in disparity for a fraction of a percent of accuracy. Sometimes it is steep. You cannot know which without plotting it, and the plot takes an afternoon.
Free tools that do this
All of the following run on an ordinary laptop with no GPU, and cost nothing.
- Fairlearn (Python, MIT licence) — group metrics, a dashboard, and both reduction-based in-processing and threshold-optimisation post-processing. The most direct route from the arithmetic in this module to code.
- AI Fairness 360 (IBM, Apache-2.0) — a wider library of metrics and mitigation algorithms, useful when you want to compare several methods.
- Aequitas (University of Chicago) — an audit-oriented toolkit that produces a report rather than a model.
- pandas alone — genuinely sufficient for the group rates, and worth doing by hand once before reaching for a library, because it forces you to see the counts.
The libraries are the easy part. The hard part remains getting the group labels and the true outcomes into one table.
What to do when you cannot fix it
Sometimes the measurement comes back bad and no available repair closes the gap. The professional responses, in order: reduce the system's authority so a human decides in the affected range; narrow the deployment to the population where it performs adequately; publish the limitation to the people affected; or do not ship it.
That last option is real. It is used less often than it should be, and the reason is almost never that someone examined the trade-off and decided the gap was acceptable. It is that nobody measured until it was too expensive to stop.
The one thing to keep
Choose the repair by the cause: collect missing data when people are missing, change the target when the label is a bad proxy, and recognise that when the data faithfully records an unequal world, the fix is a policy decision rather than a technical one.
Before you move on
A model that ranks patients for extra care shows a large gap between groups. Investigation finds it predicts future healthcare spending as a stand-in for future illness. What is the highest-value intervention?
Pick the one you would defend. Nobody sees your answer.