Module 4 - Confusion Matrix-1
Module 4 - Confusion Matrix-1
CONFUSION MATRIX
Introduction
• In machine Learning, Classification is the process of categorizing a
given set of data into different categories. In Machine Learning, To
measure the performance of the classification model we use the
confusion matrix.
• A confusion matrix is a matrix that summarizes the performance of a
machine learning model on a set of test data.
• It is often used to measure the performance of classification models,
which aim to predict a categorical label for each input instance.
• The matrix displays the number of true positives (TP), true negatives
(TN), false positives (FP), and false negatives (FN) produced by the
model on the test data.
• For binary classification, the matrix will be of a 2X2 table, For multi-
class classification, the matrix shape will be equal to the number of
classes i.e for n classes it will be nXn.
• A 2X2 Confusion matrix is shown below for the image
recognization having a Dog image or Not Dog image.
Actual
Dog Not Dog
True Positive False Positive
Dog (TP) (FP)
Predicted
False Negative True Negative
Not Dog (FN) (TN)
• True Positive (TP): It is the total counts having both predicted and
actual values are Dog.
• True Negative (TN): It is the total counts having both predicted and
actual values are Not Dog.
• False Positive (FP): It is the total counts having prediction is Dog while
actually Not Dog.
• False Negative (FN): It is the total counts having prediction is Not Dog
while actually, it is Dog.
EXAMPLE
Inde
x 1 2 3 4 5 6 7 8 9 10
Res
ult TP FN TP TN TP FP TP TP TN TN
Actual
Dog Not Dog
True Positive False Positive
Dog (TP =5) (FP=1)
Predicted
False Negative True Negative
Not Dog (FN =1) (TN=3)
Performance metrics
• ACCURACY: Accuracy is used to measure the performance of the
model. It is the ratio of Total correct instances to the total instances.