What is Confusion Matrix

Abdul Baasith
2 min readSep 24, 2021

What is a Confusion Matrix

A confusion matrix is a method of describing a classification algorithm’s performance.Classification accuracy alone can be misleading if you have an unequal number of observations which means that the dataset is bias for one outcome E.g if we have to classify male and female but we have unequal amount of data which means female or male will have more or if you have more than two classes in your dataset so that the confusion matrix has to compare more.

what is accuracy

accuracy = correct predictions / total predictions

accuracy can also easily be turned into an error rate

error_rate = (1 - (correct_predictions / total_predictions)) * 100

but these are not enough to find the whether our model works fine we need some extra details this is where the confusion matrix comes to play.The number of accurate and wrong predictions is totaled and split down by class using count values.The confusion matrix’s use is this.

We frequently want to distinguish between observations having a certain result and regular observations.that means we are comparing actual vs predicted

This gives us:

  • true positive” for correctly predicted correct values.
  • false positive” for incorrectly predicted correct values.
  • true negative” for correctly predicted false values.
  • false negative” for incorrectly predicted false values.

Code Example

Done

Hope the tutorial was helpful. If there is anything we missed out, do let us know through comments.😇

❤️❤️❤️❤️❤️❤️❤️Thanks for reading❤️❤️❤️❤️❤️❤️❤️❤️

--

--

Abdul Baasith

Hi there iam Abdul Baasith Software Engineer .I'am Typically a person who thinks out of the box . If your tool is a hammer then every problem look like a nail