Confusion Matrix in Machine Learning

Confusion Matrix:

Evaluation of the performance of a classification model is based on the counts of test records correctly and incorrectly predicted by the model. These counts are tabulated in a table known as a confusion matrix.

Each entry fij in this table denotes the number of records from class i, predicted of class j. For instance, f01 is the number of records from class 0 incorrectly predicted as class 1. Based on the entries in the confusion matrix, the total number of correct predictions made by the model is (f11 + f00) and the total number of incorrect predictions is (f10 + f01).

Although a confusion matrix provides the information needed to determine how well a classification model performs, summarizing this information with a single number would make it more convenient to compare the performance of different models. This can be done using a performance metric such as accuracy, which is defined below:

Accuracy = Number of correct predictions/ Total number of predictions

Equivalently, the performance of a model can be expressed in terms of its error rate, which is given by the following equation:

Error rate = Number of wrong predictions / Total number of predictions