# Label-error detection

Label-error detection finds the examples in a labeled dataset whose label is
probably wrong, so that a person can review them before the dataset trains or
evaluates a model. A model is trained on the data, and each example's label is
compared with the model's prediction for that example made while it was held out
of training. An example the model confidently places in a different class is a
candidate error. The labels are the expected values a learned model is held to:
a wrong label in training data teaches the error, and a wrong label in a test
set scores a correct prediction as a mistake.

The predictions have to be out-of-sample. A model scoring the examples it was
trained on has fitted their labels, the wrong ones included, so it tends to agree
with them. Tools obtain out-of-sample predictions by cross-validation: train on
all folds but one, and predict the held-out fold.

## How a disagreement becomes a flag

- **Confident learning** compares each example's predicted probability for each
  class with a per-class threshold, counts the examples that confidently belong
  to a class other than their label, and from those counts estimates the joint
  distribution of given and true labels (Northcutt, Jiang, et al. 2021)[^northcutt2021a].
- **Ensemble filters** train several different classifiers and flag an example
  that all of them, or a majority, misclassify.
- **Training dynamics** use how a model's margin on each example evolves during
  training: the area under the margin statistic separates mislabeled examples
  from clean ones by the difference in those dynamics (Pleiss et al. 2020)[^pleiss2020].

Confident learning assumes that whether a label is wrong depends only on the
example's true class, not on the example itself, so that a leopard is more
likely to be mislabeled a jaguar than a bathtub (Northcutt, Jiang, et al. 2021)[^northcutt2021a]. Every method
shares a deeper limit: the model learns from the same labels it audits, so an
error annotators made consistently can become what the model predicts, and is
then not flagged.

## What it catches

- **Wrong labels.** An example annotated with a class it does not belong to,
  through a slip, a misread instruction, or an annotator guessing.
- **Ambiguous examples and overlapping classes.** An example that fits two
  classes, or two class names that cover the same things, shows up as a cluster
  of disagreements between the same pair of classes.
- **Mislabeled mined data.** Categories taken from tools rather than assigned by
  annotators, such as the type field of an issue report, carry the errors of
  whoever filled them in.
- **Missing and misplaced annotations** in object detection, where a label is a
  box: an object nobody boxed, or a box with the wrong class or position.

What it does **not** catch:

- an error the model reproduces because annotators made it consistently;
- whether a flagged example is really wrong, which takes a person or a second
  annotation;
- a flawed labeling scheme, where the classes themselves are the wrong ones for
  the task.

## Tools

- **[cleanlab](https://github.com/cleanlab/cleanlab)** — Python library that finds label issues from a
  model's predicted probabilities, for classification, multi-label, token
  classification, regression, image segmentation, object detection, and data
  labeled by several annotators.
- **[doubtlab](https://github.com/koaning/doubtlab)** — combines "reasons" for doubt, such as low
  confidence, a wrong prediction or disagreement between models, into a ranked
  list of examples to recheck.
- **[nessie](https://github.com/UKPLab/nessie)** — research implementation of 18 annotation-error
  detection methods for text classification and sequence labeling.

## When to use, when not

**Use:**

- On a test set before models are compared on it, since its errors decide part
  of the ranking.
- On crowdsourced labels and on categories mined from tools, where nobody
  checked each label.
- To order a relabeling budget: reviewers start with the examples the detector
  ranks most suspect.

**Don't:**

- To delete or relabel flagged examples without review. A correct but unusual
  example is flagged as well, and removing it narrows the data the model learns.
- With in-sample predictions, which agree with the labels the model memorized.
- On data so noisy that the model cannot learn the classes. A filter built from
  that model cannot be accurate (Brodley and Friedl 1999)[^brodley1999].

## Evidence

- **Benchmark test sets carry errors that change model rankings.** Across the
  test sets of 10 commonly used vision, text and audio datasets, at least 3.3% of
  labels were wrong on average, and at least 6% of the ImageNet validation set.
  Crowdsourced review confirmed 51% of the candidates confident learning flagged,
  on average across the datasets.
  On ImageNet with corrected labels, ResNet-18 outperforms ResNet-50 once the
  share of originally mislabeled test examples rises by 6% (Northcutt, Athalye, et al. 2021)[^northcutt2021b].
- **Mined software-engineering data is mislabeled too.** In a manual examination
  of more than 7,000 issue reports from five open-source projects, 33.8% of
  reports filed as bugs did not refer to a code fix, and on average 39% of files
  marked as defective had never had a bug (Herzig et al. 2013)[^herzig2013].
- **Ensembles and aggregated scores detect best across tasks.**
  Reimplementing 18 detection methods on 9 English datasets, Klie and colleagues
  found ensemble and aggregation methods (Borda count, diverse ensemble, label
  aggregation, retag) worked best overall, and that skipping cross-validation
  substantially reduced the recall of model-based methods (Klie et al. 2023)[^klie2023].
- **A simple loss ranking beats elaborate detectors on real errors.** Ranking
  out-of-sample examples by the loss of a fine-tuned pre-trained language model
  outperformed more complex detectors by 9–36 points of area under the
  precision-recall curve on real errors in three datasets. Realistic,
  human-originated label noise was harder to detect than synthetic noise
  (Chong et al. 2022)[^chong2022].
- **Filters trade discarded good data against retained bad data.** In ensemble
  filtering on five datasets, consensus filters rarely discarded good data but
  kept mislabeled data: at 40% noise they retained a mislabeled example with a
  probability of 50% to 76%. Majority filters balanced the two errors more evenly
  (Brodley and Friedl 1999)[^brodley1999].
- **Removing flagged training data lowers test error.** On WebVision50, removing
  the 17.8% of training data flagged by the area under the margin reduced test
  error from 21.4% to 19.8% (Pleiss et al. 2020)[^pleiss2020].
- **Detection carries over to object detection.** Among the 200 highest-loss
  proposals per dataset, a loss-based detector found real label errors with a
  precision of up to 71.5% on commonly used public test sets and 97% on a
  proprietary production dataset (Schubert et al. 2024)[^schubert2024].

## Classification

- **Data-quality characteristics:** Accuracy (a wrong label teaches a model the wrong answer, and in a test set marks a correct prediction as an error).
- **Area:** Labeled datasets that train or evaluate a model — annotated images, text and audio, crowdsourced labels, and categories mined from tools such as issue trackers.
- **Guarantee:** Empirical — a flag is a candidate for a person to review, not a verdict; an unflagged label may still be wrong, especially where the model learned the same mistake the annotators made.

## Referenced by

- [Annotation agreement](https://quality.stereobooster.com/annotation-agreement.md) · Data quality
- [Data quality](https://quality.stereobooster.com/data-quality.md) · Data quality
- [Testing machine-learning systems](https://quality.stereobooster.com/testing-ml-systems.md) · Methods

## References

[^northcutt2021a]: Northcutt, Curtis G., Lu Jiang, and Isaac L. Chuang. 2021. "[Confident Learning: Estimating Uncertainty in Dataset Labels](https://jair.org/index.php/jair/article/download/12125/26676)." *Journal of Artificial Intelligence Research* 70. <https://doi.org/10.1613/jair.1.12125>.
[^pleiss2020]: Pleiss, Geoff, Tianyi Zhang, Ethan R. Elenberg, and Kilian Q. Weinberger. 2020. "[Identifying Mislabeled Data using the Area Under the Margin Ranking](https://arxiv.org/pdf/2001.10528)." *Advances in Neural Information Processing Systems 33 (NeurIPS 2020)*. <https://arxiv.org/pdf/2001.10528>.
[^brodley1999]: Brodley, Carla E., and Mark A. Friedl. 1999. "[Identifying Mislabeled Training Data](https://jair.org/index.php/jair/article/download/10238/24366)." *Journal of Artificial Intelligence Research* 11. <https://doi.org/10.1613/jair.606>.
[^northcutt2021b]: Northcutt, Curtis G., Anish Athalye, and Jonas Mueller. 2021. "[Pervasive Label Errors in Test Sets Destabilize Machine Learning Benchmarks](https://arxiv.org/pdf/2103.14749)." *Proceedings of the Neural Information Processing Systems Track on Datasets and Benchmarks*. <https://arxiv.org/pdf/2103.14749>.
[^herzig2013]: Herzig, Kim, Sascha Just, and Andreas Zeller. 2013. "[It's not a bug, it's a feature: How misclassification impacts bug prediction](https://www.microsoft.com/en-us/research/wp-content/uploads/2013/05/icse2013-bugclassify.pdf)." *Proceedings of the 35th International Conference on Software Engineering (ICSE 2013)*. <https://doi.org/10.1109/icse.2013.6606585>.
[^klie2023]: Klie, Jan-Christoph, Bonnie Webber, and Iryna Gurevych. 2023. "[Annotation Error Detection: Analyzing the Past and Present for a More Coherent Future](https://arxiv.org/pdf/2206.02280)." *Computational Linguistics* 49 (1). [https://doi.org/10.1162/coli\\\_a\\\_00464](https://doi.org/10.1162/coli\_a\_00464).
[^chong2022]: Chong, Derek, Jenny Hong, and Christopher D. Manning. 2022. "[Detecting Label Errors by using Pre-Trained Language Models](https://arxiv.org/pdf/2205.12702)." *Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing (EMNLP 2022)*. <https://doi.org/10.18653/v1/2022.emnlp-main.618>.
[^schubert2024]: Schubert, Marius, Tobias Riedlinger, Karsten Kahl, et al. 2024. "[Identifying Label Errors in Object Detection Datasets by Loss Inspection](https://openaccess.thecvf.com/content/WACV2024/papers/Schubert_Identifying_Label_Errors_in_Object_Detection_Datasets_by_Loss_Inspection_WACV_2024_paper.pdf)." *Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision (WACV 2024)*. [https://openaccess.thecvf.com/content/WACV2024/papers/Schubert\\\_Identifying\\\_Label\\\_Errors\\\_in\\\_Object\\\_Detection\\\_Datasets\\\_by\\\_Loss\\\_Inspection\\\_WACV\\\_2024\\\_paper.pdf](https://openaccess.thecvf.com/content/WACV2024/papers/Schubert\_Identifying\_Label\_Errors\_in\_Object\_Detection\_Datasets\_by\_Loss\_Inspection\_WACV\_2024\_paper.pdf).
