Reading an example
A toy classifier sorts 100 vehicle images into three classes. Rows are the true class, columns the prediction:
| Actual \ Predicted | Car | Truck | Bus |
|---|---|---|---|
| Car (50) | 45 | 4 | 1 |
| Truck (30) | 6 | 22 | 2 |
| Bus (20) | 0 | 3 | 17 |
Accuracy is the diagonal over the total: (45 + 22 + 17) ÷ 100 = 0.84. The off-diagonal cells tell more: trucks are called cars six times, while buses are almost never called cars. Recall for a class is its diagonal cell over its row; precision is the diagonal cell over its column.
The two-class case
With one positive class the matrix shrinks to four cells: true positives (TP), false positives (FP), false negatives (FN) and true negatives (TN). Precision and recall and the F1 score are all built from these counts.
Object detection needs a background class
A detector can also find nothing, or find something where there is nothing. Detection matrices add a background row and column: a missed object lands in the background column of its class row, and a false detection lands in the background row. Which cell a prediction falls into depends on the IoU threshold used for matching and on the confidence threshold, so a matrix is only comparable to another built with the same two settings.
Mistakes when reading one
- Swapped axes: libraries differ on whether rows are actual or predicted. Check the labels before drawing conclusions.
- Raw counts on imbalanced data: a common class dominates the colors. Normalize each row to see per-class recall.
- Blaming the model for a cell that is really a labeling error in the ground truth.
In Supervisely
Every evaluation report includes a confusion matrix and a list of frequently confused classes. A cell opens the images behind it, with ground truth and predictions side by side, and one more click opens an image in the labeling tool to correct a label that was wrong.