Week 10 · Debugging by slice
Find errors hidden in an aggregate and separate model errors from label errors.
← Week 9 · Subject contents · Week 11 →
Find errors hidden in an aggregate and separate model errors from label errors.
Work through the problem
A model with 18/20 correct on one slice and 2/10 on another has overall accuracy 20/30 ≈ 0.667. An average of slice accuracies is (0.9+0.2)/2=0.55. The metrics answer different questions. A small or underserved group can account for little of the weighted overall score.
Start with slice counts and rates. Inspect examples from both successful and failed predictions, then check whether a label or feature is suspect. Fixing labels or pipeline errors changes the data. Reserve new evaluation data for judging changes discovered while inspecting the current test set.
Run the Python lab
from collections import Counter
samples = [("day",1,1)]*18+[("day",1,0)]*2+[("night",1,1)]*2+[("night",1,0)]*8
total, right = Counter(), Counter()
for group, actual, pred in samples:
total[group] += 1
right[group] += actual==pred
for group in total:
print(group, right[group], "/", total[group], "accuracy", right[group]/total[group])
print("Overall:", sum(right.values())/sum(total.values()))
assert right["night"]==2
Output from the lab
day 18 / 20 accuracy 0.9
night 2 / 10 accuracy 0.2
Overall: 0.6666666666666666
Practice
- Is the night score itself proof that lighting caused the errors?
Check your reasoning
- No. Inspect exposure, labels, camera, and other factors that differ between slices.