{"course":{"slug":"ai-and-you","title":"AI, Safety and What Goes Wrong","url":"https://addaly.com/learn/ai-and-you","level":"beginner","track":"start"},"lesson":{"slug":"fixing-it-in-the-data","title":"What you can actually repair, and where","url":"https://addaly.com/learn/ai-and-you/fixing-it-in-the-data","position":15,"of":73,"minutes":8,"answer":"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.","keyIdea":"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."},"body":{"format":"markdown","text":"## Three places to intervene\n\nOnce a gap is measured, there are exactly three points in the pipeline where you can act.\n\n**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.\n\n**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.\n\n**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.\n\nPre-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.\n\n## Match the repair to the door\n\nRecall the four doors bias comes through.\n\n**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.\n\n**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.\n\n**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.\n\n**The threshold.** Adjust it, and understand that you are moving harm between two groups of people rather than eliminating it.\n\n## The accuracy trade, stated plainly\n\nAlmost 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.\n\nThe 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.\n\n## Free tools that do this\n\nAll of the following run on an ordinary laptop with no GPU, and cost nothing.\n\n- **Fairlearn** (Python, MIT licence): group metrics, a dashboard, and both reduction-based in-processing and threshold-optimisation post-processing.\n- **AI Fairness 360** (IBM, Apache-2.0): a wider library of metrics and mitigation algorithms, useful when you want to compare several methods.\n- **Aequitas** (University of Chicago): an audit-oriented toolkit that produces a report rather than a model.\n- **pandas** alone: sufficient for the group rates, and worth doing by hand once before reaching for a library, because it forces you to see the counts.\n\nThe hard part remains getting the group labels and the true outcomes into one table.\n\n## What to do when you cannot fix it\n\nSometimes 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.\n\nThat 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."},"check":{"question":"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?","options":[{"text":"Add a fairness constraint in training that penalises the disparity between groups","correct":false,"tempting":"A technical correction to a model answering the wrong question. The flawed target stays, and you pay accuracy for a partial fix."},{"text":"Change the target from spending to a direct measure of illness, and then re-measure","correct":true},{"text":"Set a different score threshold for each group so that referral rates come out equal","correct":false,"tempting":"Buys equal outcomes at the cost of the score's meaning, and the system still ranks by the wrong quantity underneath."},{"text":"Collect more training data from the disadvantaged group so it is better represented","correct":false,"tempting":"Right when the cause is under-sampling. More data about the wrong target reproduces the same distortion at higher volume."}],"why":"The gap came from the target. Spending stood in for illness, and less had been spent on the group that lost out."},"prev":{"slug":"the-four-fifths-rule","title":"What the law actually tests","url":"https://addaly.com/learn/ai-and-you/the-four-fifths-rule"},"next":{"slug":"measuring-when-you-cannot-ask","title":"Measuring a gap you are not allowed to record","url":"https://addaly.com/learn/ai-and-you/measuring-when-you-cannot-ask"},"authorship":"Founder and series editor: Dr Mustafa Mun. Written by AI models to a written standard. Source and assessment review continues. Academic review invited.","review":{"status":"Draft, open for academic review"},"cite":"Addaly (2026) 'What you can actually repair, and where', in AI, Safety and What Goes Wrong. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/ai-and-you/fixing-it-in-the-data (Accessed: 29 November 2026).","licence":{"name":"CC BY-NC-SA 4.0","url":"https://creativecommons.org/licenses/by-nc-sa/4.0/"},"reader":{"schema":1,"title":"What you can actually repair, and where","courseTitle":"AI, Safety and What Goes Wrong","module":{"index":2,"slug":"bias-and-fairness","title":"Bias, and how to measure it"},"answer":null,"keyIdea":"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.","hero":{"kind":"plate","image":null,"alt":null,"caption":null},"blocks":[{"t":"h2","id":"three-places-to-intervene","runs":[{"text":"Three places to intervene"}]},{"t":"p","runs":[{"text":"Once a gap is measured, there are exactly three points in the pipeline where you can act."}]},{"t":"p","runs":[{"text":"Before the model: pre-processing.","b":true},{"text":" 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."}]},{"t":"p","runs":[{"text":"Inside the model: in-processing.","b":true},{"text":" 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."}]},{"t":"p","runs":[{"text":"After the model: post-processing.","b":true},{"text":" Leave the model alone and change how its score becomes a decision. Different thresholds per group, or a calibrated adjustment of the outputs."}]},{"t":"p","runs":[{"text":"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."}]},{"t":"h2","id":"match-the-repair-to-the-door","runs":[{"text":"Match the repair to the door"}]},{"t":"p","runs":[{"text":"Recall the four doors bias comes through."}]},{"t":"p","runs":[{"text":"Missing people in the data.","b":true},{"text":" 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."}]},{"t":"p","runs":[{"text":"A bad proxy for the target.","b":true},{"text":" 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."}]},{"t":"p","runs":[{"text":"The world was unequal and the data records it faithfully.","b":true},{"text":" 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."}]},{"t":"p","runs":[{"text":"The threshold.","b":true},{"text":" Adjust it, and understand that you are moving harm between two groups of people rather than eliminating it."}]},{"t":"h2","id":"the-accuracy-trade-stated-plainly","runs":[{"text":"The accuracy trade, stated plainly"}]},{"t":"p","runs":[{"text":"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."}]},{"t":"p","runs":[{"text":"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."}]},{"t":"h2","id":"free-tools-that-do-this","runs":[{"text":"Free tools that do this"}]},{"t":"p","runs":[{"text":"All of the following run on an ordinary laptop with no GPU, and cost nothing."}]},{"t":"ul","items":[[{"text":"Fairlearn","b":true},{"text":" (Python, MIT licence): group metrics, a dashboard, and both reduction-based in-processing and threshold-optimisation post-processing."}],[{"text":"AI Fairness 360","b":true},{"text":" (IBM, Apache-2.0): a wider library of metrics and mitigation algorithms, useful when you want to compare several methods."}],[{"text":"Aequitas","b":true},{"text":" (University of Chicago): an audit-oriented toolkit that produces a report rather than a model."}],[{"text":"pandas","b":true},{"text":" alone: sufficient for the group rates, and worth doing by hand once before reaching for a library, because it forces you to see the counts."}]]},{"t":"p","runs":[{"text":"The hard part remains getting the group labels and the true outcomes into one table."}]},{"t":"h2","id":"what-to-do-when-you-cannot-fix-it","runs":[{"text":"What to do when you cannot fix it"}]},{"t":"p","runs":[{"text":"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."}]},{"t":"p","runs":[{"text":"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."}]}],"check":{"question":[{"text":"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?"}],"options":[{"text":[{"text":"Add a fairness constraint in training that penalises the disparity between groups"}],"correct":false,"tempting":[{"text":"A technical correction to a model answering the wrong question. The flawed target stays, and you pay accuracy for a partial fix."}]},{"text":[{"text":"Change the target from spending to a direct measure of illness, and then re-measure"}],"correct":true,"tempting":null},{"text":[{"text":"Set a different score threshold for each group so that referral rates come out equal"}],"correct":false,"tempting":[{"text":"Buys equal outcomes at the cost of the score’s meaning, and the system still ranks by the wrong quantity underneath."}]},{"text":[{"text":"Collect more training data from the disadvantaged group so it is better represented"}],"correct":false,"tempting":[{"text":"Right when the cause is under-sampling. More data about the wrong target reproduces the same distortion at higher volume."}]}],"order":[2,3,1,0],"why":[{"text":"The gap came from the target. Spending stood in for illness, and less had been spent on the group that lost out."}]},"prev":{"slug":"the-four-fifths-rule","title":"What the law actually tests","minutes":7},"next":{"slug":"measuring-when-you-cannot-ask","title":"Measuring a gap you are not allowed to record","minutes":8}}}