Sub topic 8
Spotting label noise and ambiguous annotations
Some of the errors you collected in earlier chapters are not model errors. The gold label is wrong, or two reasonable annotators could disagree about it. If you retrain on these examples, you teach the model the wrong thing. If you count them as model failures, you spend effort on problems that don't exist. This chapter shows how to find these cases, tell the two kinds apart, and decide what to do with them.
This chapter assumes you can build a table of misclassified examples with predictions and confidence, as in the chapter on collecting errors. It also assumes you know pandas basics and the idea of an error taxonomy.
Three things that look like one problem
"Label noise" covers several distinct situations. They need different fixes, so keep them apart when you read errors.
| Situation | What it means | Typical fix |
|---|---|---|
| Label error | The annotator made a mistake. A review saying "battery died in a day" is labeled positive. | Correct the label. |
| Ambiguous example | The text supports more than one label under the guidelines. "Fine I guess" could be neutral or mildly positive. | Clarify the guidelines, or drop or multi-label the example. |
| Guideline gap | The guidelines never covered this case (sarcasm, mixed sentiment, questions). | Extend the guidelines, then relabel the affected group. |
| Model error | The label is correct and the model is wrong. | Treat as a real error category. |
The last row matters. Many people assume every high-confidence disagreement is a bad label. Often it is a real model mistake, such as a model that ignores negation. You decide by reading the example against the annotation guidelines, not by looking at the confidence score.
Where to look first
You can't read the whole dataset, so use signals that concentrate suspected noise.
- Confident disagreements. The model predicts a different label with high probability. Sort the error table by confidence, as you did when collecting errors, and read from the top.
- Conflicting duplicates. The same text, or the same text after normalization, appears with different labels.
- Low annotator agreement. If you have multiple annotations per item, the items where annotators split are the ambiguous ones.
- Consistent confusion pairs. A confusion matrix cell that stays high (for example neutral predicted as positive) often points to a fuzzy boundary between two classes, not a weak model.
Conflicting duplicates
This check needs no model. Normalize the text, group, and look for groups with more than one label.
import pandas as pd
df = pd.DataFrame({
"text": ["love it", "Love it ", "love it", "fine I guess", "fine I guess", "broke after a week"],
"label": ["pos", "pos", "neg", "neu", "neu", "neg"],
})
df["norm"] = df["text"].str.lower().str.strip()
groups = df.groupby("norm")["label"].agg(
n_rows="count",
n_labels="nunique",
labels=lambda s: sorted(set(s)),
)
conflicts = groups[groups["n_labels"] > 1]
print(conflicts)The output lists "love it" with labels ['neg', 'pos']. Either one annotator slipped, or the text appears in different contexts that the dataset lost. Both are worth a look. Near-duplicates (differing by punctuation or a product name) also matter. Exact matching after lowercasing is a cheap first pass, and fuzzy matching can come later.
Confident disagreements
Use out-of-fold predictions here. If the model trained on an example, it may have memorized the wrong label, and the disagreement disappears. Cross-validation gives each example a prediction from a model that never saw it. The table below stands in for that output.
import pandas as pd
df = pd.DataFrame({
"text": [
"great phone",
"not bad at all",
"battery died in a day",
"fine I guess",
"works, but I returned it",
"love it",
],
"label": ["pos", "pos", "pos", "neu", "pos", "pos"], # gold
"oof_pred": ["pos", "pos", "neg", "pos", "neg", "pos"], # out-of-fold prediction
"oof_conf": [0.97, 0.78, 0.96, 0.62, 0.91, 0.99], # probability of oof_pred
})
suspects = df[(df["label"] != df["oof_pred"]) & (df["oof_conf"] >= 0.9)]
print(suspects.sort_values("oof_conf", ascending=False).to_string(index=False))This prints two rows. "Battery died in a day" labeled positive is very likely a label error. "Works, but I returned it" is harder. The model says negative, but the review has a positive clause, so it could be ambiguous. The filter only nominates candidates. You still read each one.
The threshold of 0.9 is a choice. A lower threshold finds more noise and also more real model errors. Pick it so that the list is short enough to read fully, then check what fraction you judge to be label problems. That fraction tells you how much to trust the signal on this dataset.
Measuring ambiguity with annotator agreement
If you have two or more annotations per item, you can measure how often annotators agree. Raw agreement overstates quality, because annotators agree by chance sometimes, especially when one class dominates. Cohen's kappa corrects for chance agreement. It is 1 for perfect agreement and 0 for chance-level agreement.
from sklearn.metrics import cohen_kappa_score
a = ["pos", "pos", "neg", "neu", "neu", "pos", "neg", "neu", "pos", "neg"]
b = ["pos", "neu", "neg", "neu", "pos", "pos", "neg", "neg", "pos", "neg"]
raw = sum(x == y for x, y in zip(a, b)) / len(a)
kappa = cohen_kappa_score(a, b)
print(f"raw agreement={raw:.2f}, kappa={kappa:.2f}")
disagree = [i for i, (x, y) in enumerate(zip(a, b)) if x != y]
print("items to review:", disagree)Raw agreement is 0.70 and kappa is about 0.55. The kappa is lower because with three classes some agreement would happen by luck.
Use agreement as a ceiling for the model. If human annotators reach 0.70 raw agreement on a task, a model scoring 0.72 accuracy against one annotator's labels is not necessarily weak or strong. The labels themselves limit what any score can show. Check which classes the annotators split on, using the same confusion-matrix reading from earlier chapters, with one annotator as "true" and the other as "predicted".
A few cautions about kappa:
- It depends on class balance. Two datasets with the same raw agreement can have very different kappa values.
- It works for two annotators. For more, use Fleiss' kappa or Krippendorff's alpha.
- There is no universal "good" threshold. Compare against agreement on similar tasks, and look at the disagreeing items rather than the number alone.
Reading the examples
Once you have a candidate list, tag each row with one of the four situations in the first table. Add a column to your error table and fill it in by hand. Use the written guideline as the referee. If you don't have one, write down the rule you applied, so the next reader can check your judgment.
Some patterns recur:
- Sarcasm and mixed sentiment. "Great, it broke on day one." Guidelines often don't say which wins.
- Label drift. Early annotators followed one interpretation and later ones another. Check whether disagreements cluster by annotation date or annotator ID, if you have those fields.
- Boundary classes. Neutral versus mildly positive, or "other" versus a specific class, produce most of the ambiguity in many datasets.
- Annotation shortcuts. Annotators may label by a keyword and ignore context, which creates noise that looks consistent and is hard to detect with a confidence filter.
For sequence labeling, noise shows up differently. The same phrase may be tagged as an entity in one sentence and untagged in another, or span boundaries vary (with or without a title like "Dr."). Compare how identical strings are tagged across the dataset.
Estimating how much it matters
Take a random sample of your errors, not just the top of the confidence list, and tag them. If 12 of 50 sampled errors are label errors or ambiguous, roughly a quarter of your errors may not be model failures. That sample is small, so report it with an uncertainty range, using the bootstrap approach from the chapter on slice uncertainty.
This estimate changes how you read your test score. If the test set contains noise, your measured accuracy is lower than the true accuracy against correct labels. Cleaning the test set changes the score without changing the model. Keep the original and cleaned versions of the test set, and record which one each reported number used. Otherwise a later improvement can be an artifact of relabeling.
What to do with what you find
- Label errors: correct them, log the change (old label, new label, reason, reviewer), and keep the change reproducible.
- Ambiguous examples: decide a policy. Options are removing them from evaluation, adding a multi-label or "uncertain" option, or keeping them and accepting a lower ceiling.
- Guideline gaps: update the guidelines first, then relabel the examples in that category. Relabeling before the guideline is clear repeats the problem.
- Training noise: for large datasets where hand cleaning is not possible, consider dropping the highest-confidence disagreements. Check on a clean validation set that this helps.
Feed the proportions into your ranking of error categories. A category that is mostly label noise has low fixability from the modeling side, and its fix is an annotation task.
Exercise
A model trained on a sentiment dataset has 0.84 accuracy. You review the 30 highest-confidence errors (confidence at least 0.9) and judge 18 to be label errors, 6 ambiguous, and 6 model errors. A teammate concludes that 60% of all the model's errors are label errors and that the true accuracy is about 0.94. What is wrong with this reasoning, and what would you do instead?
Show answer
The 30 examples are the most confident errors, not a random sample, so the 60% figure applies only to that slice. Confident errors are where label noise concentrates, so it will overstate the share among all errors. The 0.94 figure also assumes the model would be right on every noisy example once relabeled, which is not guaranteed (ambiguous examples may stay uncertain). Instead, draw a random sample of all errors (for example 50), tag each one, report the label-noise share with a bootstrap interval, and re-score a cleaned copy of the test set to get a corrected accuracy. Keep the original test set so earlier scores stay comparable.