Read a Confusion Matrix and calculate the accuracy score
Reading a Confusion Matrix
Reading a confusion matrix properly and interpreting it is an essential step in order to evaluate the quality and performance of a predictive model (Mainly classification algorithms).
This example is about a predictive algorithm that predicts whether or not a bank client having received a bank loan will be forced to make a default of payment.
The image below represents a confusion matrix for the results of this algorithm.
TP: True Positive. FN: False Negative. FP: False Positive. TN: True Negative.
The confusion matrix gives information not only about whether it contains errors or not. But it additionally, gives information about the type of error.
In this example, the true positive section represents the clients that are predicted to make a default of payment and actually made a default of payment. Similarly, False Negative represents the clients that were predicted to not make a default but actually did make a default of payment. Then, False Positive represents clients that were predicted to make a default of payment but actually did not default. Finally, True Negative is about clients that were predicted to not default and did not make a default of payment.
Calculate the accuracy score from the confusion matrix
Accuracy score = [ ( TP + TN ) / ( TP + TN + FN + FP ) ]
The results must be multiplied by 100 to get the accuracy score in percentage.
A numerical example:
Accuracy score = [ ( 40 + 34 ) / ( 40 + 34 + 4+ 7) ]
Accuracy score = [ 74 / 85 ]
Accuracy score = 0.8705
Meaning that in this example we have an accuracy score of 87.05 %.