Skip to content
C.W.K.
Stream
Lesson 01 of 05 · published

Error Analysis

~28 min · errors, diagnostics

Level 0Scout
0 XP0/48 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

Errors are the cheapest next dataset

An aggregate score says how often a model fails under one weighting; error analysis shows what the failures are. After each meaningful change, inspect original cases from untouched validation data with stable example ID, model version, score, threshold, label source, and reviewer decision.

Sample more than one kind of error

Include random false positives and false negatives, costly failures, cases near the threshold, and product-critical slices. Do not review only confident mistakes. Inspect some correct predictions too, because leakage, duplicates, or easy majority cases can make the score look healthy for the wrong reason.

Use a reusable failure taxonomy

  • Label problem: the target is wrong, stale, or inconsistent.
  • Coverage gap: a needed feature or population is absent.
  • Distribution shift: the case is poorly represented by the reference set.
  • Pipeline failure: parsing, joins, defaults, or feature computation corrupted the case.
  • Model limitation: input and label are sound, but the fitted boundary is inadequate.

Do not count ambiguity as ordinary model failure

When qualified reviewers reasonably disagree, record an ambiguous category and measure agreement. Forcing a single label hides irreducible uncertainty and may send model tuning after a definition problem.

Each tag should imply a different repair

Label problems return to the annotation contract; pipeline failures get regression tests; coverage gaps become data work; shift changes sampling or monitoring. Only demonstrated model limitations justify new features or algorithms. Rerun the same slice after the intervention.

Count frequency and cost together

Fifty reviewed examples can generate hypotheses, not precise prevalence. Report each tag with its sampling denominator and uncertainty. Ten failures in twenty reviewed cases from a critical slice may matter more than one hundred routine errors among millions of requests.

Version the error taxonomy as an asset

Store tag definitions, reviewer guidance, sampled IDs, and adjudication history with the model release. Have a second reviewer audit a subset when tags drive expensive work. Error analysis pays off when it becomes a repeatable feedback loop, not a gallery of embarrassing predictions.

Code

Sample errors stratified by error type·python
import numpy as np
import pandas as pd

preds = (probs >= 0.5).astype(int)
errors = X_val.assign(y_true=y_val.values, y_pred=preds, prob=probs)
errors = errors[errors["y_true"] != errors["y_pred"]]
fp = errors[errors["y_pred"] == 1].sample(min(25, len(errors)), random_state=7)
fn = errors[errors["y_pred"] == 0].sample(min(25, len(errors)), random_state=7)
review = pd.concat([fp, fn]).sample(frac=1, random_state=7)
review.to_csv("errors_to_review.csv", index=False)
Slice metrics by subgroup to find systemic errors·python
from sklearn.metrics import classification_report

for plan in df_val["plan_tier"].unique():
    mask = df_val["plan_tier"] == plan
    print(f"--- {plan} (n={mask.sum()}) ---")
    print(classification_report(y_val[mask], preds[mask], digits=3))

External links

Exercise

Sample 50 errors from your validation set. Tag each as bad-label, ambiguous, missing-feature, distribution-shift, or genuine-model-error. Report the tag distribution. Decide which fix has the highest expected lift.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.