A table of the four outcomes of a classifier against the truth (true and false positives and negatives), from which recall, specificity, and precision are calculated.
Definition
A confusion matrix counts the outcomes of a classifier, such as an AI inspection tool, against the known truth: true positives (defects flagged), false negatives (defects passed, or escapes), false positives (good items flagged, or false alarms), and true negatives (good items passed). Recall is true positives divided by all defects, specificity is true negatives divided by all good items, and precision is true positives divided by all flagged items. Precision depends on how common defects are, so it falls when defects are rare.
History
The method comes from statistics and signal detection, and from medical testing, where sensitivity and specificity are standard. Quality engineers use the same ideas in attribute agreement analysis.
When to Use
Use it to validate any tool or person that classifies items as good or bad, and to compare tools or inspectors.
Step-by-Step
- Agree the standard and build a representative test set.
- Run the tool blind and count the four outcomes.
- Calculate recall, specificity, precision, and kappa with exact intervals.
- Work out the meaning at the real defect rate: escapes, false alarms, and precision.
- Weigh the costs of each kind of error.
Examples
- An AI inspection assist: 54 true positives, 6 false negatives, 17 false positives, and 323 true negatives on 400 parts.
- A document checker that flags missing fields.
Common Pitfalls
- Reporting accuracy alone when defects are rare.
- A test set unlike production.
- Forgetting the intervals.
