A confusion matrix in machine learning or ML is a method for summing up the presentation of a classification algorithm. Classification precision alone can be deluding on the off chance that you have an inconsistent number of perceptions in each class or if you have multiple classes in your dataset.
Computing a confusion matrix can give you a superior thought of what your classification model is getting right and what sorts of mistakes it is making.
A confusion matrix is a presentation estimation procedure for ML classification. It is a sort of table that causes you to know the exhibition of the classification model on a collection of test data for that the true values are known. The term confusion matrix itself is exceptionally basic, yet its connected wording can be a bit complicated.
The classification matrix is a convenient tool for the assessment of statistical models and is now and again alluded to as a confusion matrix. A classification matrix is a significant tool for surveying the consequences of forecast since it makes it straightforward and represents the impacts of wrong expectations.
Actual Values | |||
Predicted Values |
Positive | Negative | |
Positive | True Positive | False Positive | |
Negative | False Negative | True Negative |
Here are the advantages of utilizing a confusion matrix:
Here, is a step-by-step measure for figuring a confusion matrix:
i.) The sum of the correct expectations for each class.
ii.) The sum of incorrect expectations of each class.
Here, is a step-by-step measure for figuring a 2 Class Confusion Matrix:
We should imagine we have a two-class classification issue of predicting whether a photo contains a cat or a dog.
We have a test dataset of ten records with anticipated results and a set of expectations from our classification algorithm.
Confusion Matrix Table
Expected | Predicted |
Cat | Dog |
Cat | Cat |
Dog | Dog |
Cat | Cat |
Dog | Cat |
Dog | Dog |
Dog | Dog |
Dog | Cat |
Cat | Dog |
Cat | Cat |
The algorithm made 6 of the 10 predictions correct with an exactness of 60%.
Accuracy = Total Correct Predictions divided by Total Predictions made multiplied by 100
Accuracy = 6/ 10 * 100
Be that as it may, what sort of mistakes were made?
We should transform our outcomes into a confusion matrix.
In the first place, we should ascertain the number of correct predictions for each class:
Computation of correct predictions:
Computation of incorrect predictions:
2-class confusion matrix:
Cat | Dog | |
Cat | 3 | 2 |
Dog | 3 | 2 |
Confusion matrix above answer:
The use of a confusion matrix is to depict the exhibition of a classification model on a bunch of test data for which the true values are known. The confusion matrix itself is generally easy to see, yet the connected phrasing can be complex.
Confusion matrix sklearn:
Confusion matrix array:
[[4 2]
[1 3]]
Confusion Matrix is very useful for measuring the AUC-ROC Curve, Accuracy, Specificity, Precision, and Recall. The confusion matrix presents the manners by which your classification model is confused when it executes predictions.
There are no right or wrong ways of learning AI and ML technologies – the more, the better! These valuable resources can be the starting point for your journey on how to learn Artificial Intelligence and Machine Learning. Do pursuing AI and ML interest you? If you want to step into the world of emerging tech, you can accelerate your career with this Machine Learning And AI Courses by Jigsaw Academy.