How machines learn
Data Quality, Class Imbalance, and Label Noise
Diagnose missingness, corruption, imbalance, label noise, and slice coverage as separate data problems with different remedies.
By the end you can
- Classify common data-quality failures by validity, completeness, consistency, uniqueness, and timeliness
- Explain why class imbalance affects learning, metrics, and batch composition
- Distinguish random label noise from systematic annotation or policy error
- Select data interventions based on the mechanism rather than a generic cleaning recipe
Key idea
“The data is dirty” is not a diagnosis
A missing value, duplicated transaction, delayed label, impossible timestamp, rare class, and disputed annotation are different problems, and applying one cleaning script to all of them can erase valid information or preserve hidden bias.
Data quality should be described in relation to the task, prediction time, and affected slice. England's COVID-19 case counts show what that looks like when the mechanism is named. On 4 October 2020 Public Health England disclosed that 15,841 positive cases recorded between 25 September and 2 October had been left out of the reported daily counts and delayed in reaching contact tracers. Not one value in those rows was wrong. The rows had been silently truncated when an Excel file hit its maximum size. Michael Brodie, then interim chief executive of Public Health England, described the cause: “A technical issue was identified overnight on Friday 2 October in the data load process that transfers COVID-19 positive lab results into reporting dashboards.”
The delay had a measured cost. Fetzer and Graeber used the incident as a natural experiment and estimated, in PNAS in 2021, that each case referred late was associated with 18.6 additional infections and about 0.24 additional COVID-19 deaths over the following six weeks. That is the whole argument for naming the mechanism. A validity check would have passed every surviving row. Only a completeness check, against the number of rows the process should have produced, could have caught it. The difference between those two checks was measured in infections.
Name the mechanism before choosing the fix.
Case
CIFAR relabelled: four noise rates from the same images
The label side of that has numbers on it, and they come from the most-used image benchmarks in the field. For a 2022 ICLR paper, Wei and colleagues had Amazon Mechanical Turk workers relabel the CIFAR-10 and CIFAR-100 training sets. CIFAR-10N used three independent workers per image. CIFAR-100N used one. The appendix records that “There are 747 independent workers contribute to the construction of CIFAR-10N”; no worker count is given for CIFAR-100N.
The photographs never changed. The noise rate did. The paper reports that “60.27% of the training images have received unanimous label from three independent labelers” — on the rest, qualified people looking at the same picture disagreed. It also reports that “the noise rates of prepared five noisy label sets are 9.03% (Aggregate), 17.23% (Random 1), 18.12% (Random 2), 17.64% (Random 3) and 40.21% (Worst)”. Each individual annotator was wrong about eighteen per cent of the time. Aggregating three of them cut that to 9.03 %. Taking the worst of the three instead gives 40.21 %. On the CIFAR-100 images, “the overall noise level of coarse and fine labels are 25.60% and 40.20%, respectively”.
One set of photographs, four defensible noise rates between 9.03 % and 40.21 %. What changed was the annotation design: how many answers were combined, and how finely the label space was cut. A dataset does not have a noise rate. A dataset plus an annotation protocol does.
Figure
Visual
Six questions for every critical field
Quality dimensions overlap, but they turn vague concern into measurable checks — and they are not a teaching device invented for this lesson. They are standardised. ISO/IEC 5259-2:2024, published on 5 November 2024, says so in its scope: “This document specifies a data quality model, data quality measures and guidance on reporting data quality in the context of analytics and machine learning (ML).” Clause 6.2 names five inherent characteristics: accuracy, completeness, consistency, credibility and currentness. Clause 6.5 adds nine more as additional data quality characteristics: auditability, balance, diversity, effectiveness, identifiability, relevance, representativeness, similarity and timeliness. Balance and representativeness are published, measurable characteristics of a dataset in an international standard. They are not informal advice you may take or leave.
Representativeness is the one with the largest measured price. In 2018 Buolamwini and Gebru audited the face benchmarks the field was training and testing on. Their abstract reports: “We find that these datasets are overwhelmingly composed of lighter-skinned subjects (79.6% for IJB-A and 86.2% for Adience) and introduce a new facial analysis dataset which is balanced by gender and skin type.” Their replacement benchmark held 1,270 parliamentarians, balanced by gender and skin type. Measured on it, commercial gender classifiers erred on darker-skinned females at rates between 20.8 % and 34.7 %. For lighter-skinned males the worst rate was 0.8 %.
That was not an artefact of one audit. NIST tested 189 algorithms against four US government photo datasets and found false positive rates varying by factors of 10 to beyond 100 across demographic groups. Its report, NISTIR 8280, came out in December 2019. A coverage failure in the training and evaluation data does not average out. It shows up as a slice error rate one or two orders of magnitude away from the headline number.
Validity
Does the value follow allowed type, range, and domain rules?
Completeness
Is the value present when the process should produce it?
Consistency
Do sources and transformations agree on meaning and units?
Uniqueness
Are duplicate records legitimate repeated events or accidental copies?
Timeliness
Was the value available and fresh enough at prediction time?
Coverage
Do important populations and conditions appear with sufficient evidence?
Missing values may carry process information
A lab result may be missing because a clinician judged the test unnecessary, because the patient lacked access, because the device failed, or because ingestion broke. Imputing all missing values with a mean hides those distinctions, and each of them would call for a different remedy.
Inspect missingness by time, source, group, and outcome. A missingness indicator can be useful. But it may encode policy or access patterns that change after deployment, which makes it a feature whose meaning has an expiry date.
Case
When a test was ordered beat what the test found, in 118 of 174
When a test was ordered can predict survival better than what the test found. Agniel and colleagues measured that and published it in The BMJ in 2018. Their cohort was “all 669 452 patients treated at the two hospitals over one year between 2005 and 2006”, covering 272 types of laboratory test.
It is not a comfortable finding. “Data about the timing of when laboratory tests were ordered were more accurate than the test results in predicting survival in 118 of 174 tests (68%)”. The mere fact that a test existed carried signal: “the presence of a laboratory test order, regardless of any other information about the test result, has a significant association (P<0.001) with the odds of survival in 233 of 272 (86%) tests”. And when the authors ranked variables against each other, the clock beat the chemistry: “the time interval between consecutive tests is the single most predictive variable for 76 of 210 (36%) tests, followed by the value of the test result in 56 (27%) tests, and the hour of the day in 47 (22%) tests”.
A model fed that table learns the clinician's judgement about who needed testing, and the hospital's routine about when. It learns the patient's blood only incidentally. Nothing in the data is missing at random. Nothing about the columns announces which process wrote them.
Comparison
Rare classes create three separate challenges
Class imbalance affects more than the final metric. The third column — operations — is the one usually left as a hypothetical. It has been measured.
The Epic Sepsis Model went through that arithmetic in public. Wong and colleagues validated it externally in JAMA Internal Medicine on 21 June 2021, across 27,697 patients and 38,455 hospitalisations at Michigan Medicine between 6 December 2018 and 20 October 2019. The area under the curve was 0.63 (95% CI 0.62–0.64). At the recommended alert threshold of 6, sensitivity was 33 %, specificity 83 %, and positive predictive value 12 %. Read that as a queue rather than as a table. Alerts fired on 18 % of all hospitalisations, 6,971 of 38,455, and roughly seven in eight of them were not sepsis. Meanwhile the model failed to identify 1,709 patients with sepsis (67 %). The authors' verdict: “This external validation cohort study suggests that the ESM has poor discrimination and calibration in predicting the onset of sepsis.”
A second validation moved the same model to a different operating point. It covered two Houston county emergency departments in 2023 and 145,885 encounters, and reported sensitivity 14.7 %, specificity 95.3 % and positive predictive value 7.6 % in JAMIA Open in 2024. Same model, different base rate and threshold, and a completely different burden on the people who have to answer the alerts. That is why the three effects must be separated. Specificity of 83 % sounds benign until the prevalence tells you how many nurses it summons.
Learning signal
Minority examples contribute fewer updates under ordinary sampling.
- Can be missed in batches
- Decision boundaries favor majority fit
- Hard cases may be sparse
- Reweighting or sampling may help
Evaluation
Overall averages can be dominated by the majority class.
- Accuracy may look excellent
- Precision depends on prevalence
- Slice counts may be tiny
- Uncertainty should be reported
Operations
Even a small false-positive rate can create a huge review queue.
- Threshold depends on capacity
- Base rate affects alert quality
- Investigation changes labels
- Top-of-queue metrics may matter
Example
Not all label noise is random
The pattern of mistakes determines whether more labeling, better guidance, or a target redesign is needed. It also determines whether the noise is confined to your own annotation queue. It usually is not. Northcutt and colleagues had people check the test sets of 10 of the most-used ML benchmarks, and published the count at NeurIPS in 2021. Their abstract states: “we estimate an average of at least 3.3% errors across the 10 datasets, where for example label errors comprise at least 6% of the ImageNet validation set”.
In counts, that is 2,916 errors in the ImageNet validation set and over 5 million (10 %) in QuickDraw, with 51 % of the algorithmically flagged candidates confirmed by people as genuinely mislabelled. The consequence is not cosmetic. On corrected ImageNet labels, ResNet-18 outperforms ResNet-50 once the prevalence of originally mislabelled test examples rises by just 6 %. The leaderboard order inverts, and the only thing that changed was whose labels the score was computed against. An independent re-annotation of the same ImageNet validation set found the original labels “to no longer be the best predictors of this independently-collected set”. Before deciding what to do about noise, decide which of these patterns produced it.
- Random slip: occasional accidental key presses or transcription mistakes.
- Ambiguous boundary: qualified reviewers reasonably interpret the same case differently.
- Systematic reviewer bias: one team applies a policy more strictly than another.
- Policy drift: the definition changes over time while old and new labels remain mixed.
- Missing context: reviewers label from partial information unavailable to them.
- Selection noise: only model-flagged or escalated cases receive a verified outcome.
Key idea
Data cleaning belongs inside the experimental design
Imputation values, outlier thresholds, category consolidation, and feature selection can use information from the full dataset if applied before splitting. That contamination can make evaluation optimistic.
Fit learned cleaning decisions on training data and apply them unchanged. Rule-based validity checks may be global when they do not depend on held-out distributions or targets.
An entire literature has already run the counter-experiment. A systematic review of machine-learning models for COVID-19 detection and prognosis from chest radiographs and CT identified 2,212 studies and kept 415 through initial screening. After quality screening it arrived at a final set in which not one model was judged usable. Among the recurring causes were duplicated and recombined public datasets that put the same images on both sides of a train/test split. Roberts and colleagues, writing for the AIX-COVNET collaboration in Nature Machine Intelligence in 2021, put it in one line: “Our review finds that none of the models identified are of potential clinical use due to methodological flaws and/or underlying biases.”
A second review reached the same verdict independently. Wynants and colleagues' living systematic review in The BMJ in 2020 rated every COVID-19 prediction model it included at high or unclear risk of bias, citing non-representative controls, overfitting, and reported performance that is “probably optimistic”. Two reviews, two teams, one conclusion. What disqualified those models was how the data was assembled and prepared, not which architecture was fitted to it.
A preprocessing choice can be both sensible and leaky if fitted on the wrong evidence.
Analogy
An analogy: surveying common and rare birds
Bird populations get estimated from short walks near a city park. Common pigeons dominate observations, while a rare nocturnal species may never appear even if ecologically important.
Class imbalance creates a similar evidence problem. Rarity in a dataset need not be natural prevalence at all; sampling policy, label definitions, or an intervention can produce it.
The standard remedy carries a cost that the usual metrics do not show. Van den Goorbergh and colleagues compared no correction against random undersampling, random oversampling and SMOTE. Their data was 3,369 premenopausal women from the IOTA ovarian-tumour study, where the prevalence of malignancy was 20 % — 658 of 3,369. They also ran simulations at event fractions of 30 %, 10 % and 1 %. Reporting in 2022 in the Journal of the American Medical Informatics Association, they found that all three corrections “yielded poorly calibrated models: the probability to belong to the minority class was strongly overestimated”. Sensitivity and specificity did improve. Moving the decision threshold achieved the same improvement without damaging the probabilities. Their conclusion: “Outcome imbalance is not a problem in itself, imbalance correction may even worsen model performance.”
Position
Imbalance is a property of the problem, not a defect in the data
Almost every introductory tutorial treats a rare positive class as damage to be repaired before modelling begins. It offers one repair: resample, or synthesise minority examples until the classes match. It may be the most confidently taught reflex in applied machine learning. It has also been measured.
The measurement came out against it. Van den Goorbergh and colleagues compared no correction against random undersampling, random oversampling and SMOTE. Their data was 3,369 premenopausal women from the IOTA ovarian-tumour study, where 20 % of the cases were malignant — 658 of 3,369. They also ran simulations down to an event fraction of 1 %. All three corrections produced models whose probability of belonging to the minority class was strongly overestimated. Sensitivity and specificity did improve. Moving the decision threshold produced the same improvement and left the probabilities alone. Their conclusion is the sentence to leave this lesson holding: “Outcome imbalance is not a problem in itself, imbalance correction may even worsen model performance.”
The reason the reflex misfires is structural rather than statistical. This lesson separates three different things imbalance does. It thins the learning signal. It makes the aggregate metric uninformative. It strains the review queue. Resampling addresses the first. It is routinely deployed against the second and third. There the real instruments are a metric that respects prevalence and a threshold chosen from capacity. The Epic Sepsis Model's 12 % positive predictive value and alerts on 18 % of hospitalisations were a threshold-and-capacity problem, and no amount of oversampling would have shortened that queue. Naming which of the three you actually have is most of the work. The menu that follows is only useful once you have.
Correcting the imbalance bought what a threshold would have bought, and cost the probabilities.
Example
What to monitor before and after training
A compact data-quality dashboard should connect pipeline health with model relevance. ISO/IEC 5259-2:2024 supplies the vocabulary for the columns — accuracy, completeness, consistency, credibility and currentness from clause 6.2, and balance, diversity, representativeness and timeliness among the additional characteristics in clause 6.5. The cases above supply the reason each row exists.
- Row and distinct-entity counts by source and time.
- Missingness, range, category, and freshness distributions for critical fields.
- Label prevalence, maturity, disagreement, and policy version.
- Duplicate and near-duplicate rates within and across partitions.
- Coverage of important groups, conditions, and rare outcomes.
- Training-serving differences for feature values and availability.
Key takeaways
- Data quality is task-specific, and the vocabulary for it is standardised: ISO/IEC 5259-2:2024 names accuracy, completeness, consistency, credibility and currentness in clause 6.2, and adds balance, diversity, representativeness and timeliness among the additional characteristics in clause 6.5.
- Missingness can reflect clinical, social, operational or technical processes rather than random absence. The timing of a laboratory order beat the result value at predicting survival in 118 of 174 tests (68%), and Public Health England's silently truncated Excel rows left 15,841 cases out of the reported counts with no invalid value anywhere.
- Class imbalance affects training feedback, evaluation interpretation and operational review volume separately: the Epic Sepsis Model alerted on 18% of hospitalisations (6,971 of 38,455) at 12% positive predictive value, a queue problem that a threshold, not a resampler, addresses.
- Label noise is measured, not hypothetical, and its rate depends on the annotation design: the same CIFAR images yielded 9.03% noise aggregated over three annotators and 40.21% at the worst single annotator, while a hand-check of 10 leading benchmark test sets found at least 3.3% errors on average and 6% in ImageNet's validation set.
- Learned cleaning and preprocessing can leak held-out information if fitted before partitioning; the AIX-COVNET review of 2,212 COVID-19 imaging studies found not one usable model, with recombined public datasets putting the same images on both sides of a split.
- Data interventions should be traced to a mechanism, preserve provenance, and be re-evaluated for aggregate, slice, calibration and workflow effects — imbalance corrections yielded poorly calibrated models in a study where moving the threshold cost nothing.