Confusion Matrix

A confusion matrix is a table that summarizes how well a classification model performs by showing the counts of correct and incorrect predictions broken down by class. For binary classification, it has four cells: true positives (correctly predicted positive), true negatives (correctly predicted negative), false positives (predicted positive but actually negative), and false negatives (predicted negative but actually positive).

From these four numbers, you can calculate most classification metrics. Precision is TP / (TP + FP), telling you what fraction of positive predictions were actually correct. Recall is TP / (TP + FN), telling you what fraction of actual positives were caught. F1 score is the harmonic mean of precision and recall. Accuracy is (TP + TN) / total, but can be misleading when classes are imbalanced (a model that always predicts "no defect" on a dataset with 1% defect rate gets 99% accuracy while being useless).

For multi-class problems, the confusion matrix becomes an N x N grid where rows represent actual classes and columns represent predicted classes. The diagonal shows correct predictions; off-diagonal cells show which classes get confused with each other. This is especially useful for debugging: if the model consistently confuses "cat" with "dog" but never with "car," you know where to focus data collection or augmentation efforts.

Get Started Now

Get Started using Datature’s computer vision platform now for free.