Member-only story

How to calculate accuracy of a classification model using a confusion matrix

Crystal X
3 min readSep 25, 2022

--

In the field of machine learning and specifically the problem with statistical classification, a confusion matrix (or error matrix), is a specific table layout that allows visualisation of the performance of an algorithm, typically in supervised learning (in unsupervised learning a confusion matrix is called a matching matrix) A depiction of a confusion matrix can be seen in the screenshot below:-.

In Python’s sklearn library, the confusion_matrix() function evaluates classification accuracy by computing the confusion matrix with each row corresponding to the true class.

When working on a classification problem, it is always a good idea to produce a confusion matrix when making predictions because it tells which predictions are true and which ones are false.

The below illustration is a confusion matrix visualisation from Python’s sklearn machine learning library:-

--

--

Crystal X
Crystal X

Written by Crystal X

I have over five decades experience in the world of work, being in fast food, the military, business, non-profits, and the healthcare sector.

No responses yet