Tag Info

A confusion matrix is a contingency table used to evaluate the predictive accuracy of a classifier. Confusion matrix is the 2x2 frequency table with counts "True positive", "True negative", "False positive", "False negative", relating classifying to a class of interest vs. else class. But in a broader sense, any frequency kxk crosstabulation "Predicted" x "Actual" classes can be called a confusion matrix, in the context of evaluation of a classifier.

A confusion matrix is a special contingency table used to evaluate the predictive accuracy of a classifier. Predicted classes are listed in rows (or columns) & actual classes in columns (or rows), with counts of the cases in each combination listed in each cell. All cases represented along the main diagonal are accurately classified, while the off-diagonal elements are misclassified. Inspection of the confusion matrix can identify which classes tend to be 'confused' for each other. The confusion matrix also allows the calculation of model performance metrics such as sensitivity and specificity, precision and recall, positive and negative predictive value, etc.

Here is an example confusion matrix from a model of Fisher's iris data with good accuracy. The model occasionally confuses versicolor and virginica, but never misclassified either as setosa.

                      Actual:
setosa versicolor virginica
Predicted:
setosa         50          0         0
versicolor      0         47         3
virginica       0          4        46