A confusion matrix is a table used to evaluate the performance of a classification algorithm. It shows the counts of true positive, true negative, false positive, and false negative predictions.
Structure
| Predicted Positive | Predicted Negative | |
|---|---|---|
| Actual Positive | True Positive (TP) | False Negative (FN) |
| Actual Negative | False Positive (FP) | True Negative (TN) |
Key Metrics Derived
From the four cells you can derive the standard classification metrics:
- Accuracy = (TP + TN) / (TP + TN + FP + FN)
- Precision = TP / (TP + FP)
- Recall (Sensitivity) = TP / (TP + FN)
- Specificity = TN / (TN + FP)
- F1 Score = 2 × (Precision × Recall) / (Precision + Recall)
Use Cases
- Evaluating binary and multi-class classification models
- Understanding model errors and bias
- Comparing different models