Sub topic 14
Ranking Error Categories and Choosing Fixes
Prerequisites and the prioritization problem
Assume you have trained an NLP classifier or sequence tagger, can use Python with pandas, and understand accuracy, precision, recall, and F1. You also have a fixed test set that was not used during training.
An error taxonomy is a set of labels for recurring failure patterns, such as negation, label_noise, short_text, or distribution_shift. Error analysis becomes useful when you connect each category to a possible action. A long list of mistakes is not yet a plan.
Rank categories using four questions:
- How often does the category occur?
- How much does it affect the product or important users?
- How likely is a proposed fix to work?
- How much effort and risk will the fix require?
A frequent category is not always the best first target. A rare error may affect a safety-critical class. A large slice gap may come from only a few examples. Always include the number of examples beside each percentage.
A practical ranking table
Create one row for each error category. Record the evidence separately from your proposed intervention.
| Category | Errors | Share of errors | User impact | Fixability | First action |
|---|---|---|---|---|---|
| Negation missed | 42 | 21% | High | Medium | Add targeted examples |
| Ambiguous labels | 31 | 16% | Medium | Low | Review annotation rules |
| Long documents | 18 | 9% | Medium | High | Test chunking |
| Rare entity type | 7 | 4% | High | Medium | Collect more examples |
Use a simple score to make the ranking explicit. For example:
priority = frequency × impact × fixability
Use small, consistent values such as 1 through 5 for impact and fixability. This score is a planning aid, not a statistical result. Keep high-impact categories visible even when their frequency is low.
import pandas as pd
categories = pd.DataFrame({
"category": ["negation", "label_noise", "long_text", "rare_entity"],
"errors": [42, 31, 18, 7],
"impact": [5, 3, 3, 5],
"fixability": [3, 1, 5, 3],
})
categories["frequency"] = categories["errors"] / categories["errors"].sum()
categories["priority"] = (
categories["frequency"]
* categories["impact"]
* categories["fixability"]
)
print(categories.sort_values("priority", ascending=False).to_string(index=False))Check whether a fix is worth trying
For the highest-ranked category, write a narrow hypothesis:
- Finding: negation errors make up 21% of reviewed errors.
- Hypothesis: examples containing “not” are underrepresented in training data.
- Change: add reviewed negation examples and retrain.
- Success condition: improve negation recall without reducing overall precision.
- Guardrail: compare the new model with the old model on the unchanged test set.
Do not change several causes at once. If you add data, alter labels, and replace the model together, you cannot tell which change helped. Keep a regression set containing previously fixed examples. Re-run it after every iteration.
From findings to the next iteration
Use the error category to choose the intervention:
- Label noise: clarify guidelines and re-annotate a sample.
- Missing coverage: collect or generate representative examples.
- Distribution shift: evaluate on recent or out-of-domain data.
- Calibration problems: adjust thresholds or calibrate probabilities.
- Behavioral failures: add automated invariance or perturbation tests.
- Model limitations: compare a different representation or architecture.
Exercise
A category has 5% of errors, impact 5, and fixability 5. Another has 30% of errors, impact 2, and fixability 2. Which should you inspect first?
Show answer
Compute the planning scores: 1.25 for the first category and 1.2 for the second. Inspect the first slightly earlier, then verify that its small sample is reliable and that the impact rating is justified.