You are on page 1of 6

19SW117

ABDUL WAJID MOROOJO


Problem Statement: Imagine solving a binary Classification task. For example, you are
trying to determine whether a cat or a dog is on an image. You have a model and want to
evaluate its performance using the Confusion matrix. You pass 15 pictures with a cat
and 20 images with a dog to the model. From the given 15 cat images, the algorithm
predicts 9 pictures as the dog ones, and from the 20 dog images - 6 pictures as the cat ones. It
is time to build a Confusion matrix.

Solution:  Let’s say that the cat images are a Positive class, whereas the dog pictures are
a Negative one, i.e., is a cat and is not a cat of the 15 cat images (P), 9 were predicted as the
dog ones. So, only 15 - 9 = 6 predictions were correct. TP = 6. Of the 20 dog images
(N), 6 were predicted as the cat ones. So, 20 - 6 = 14 predictions were correct. TN = 14.
9 pictures were predicted as the dog ones, but they actually have a cat on them. So, FN = 9;
6 images were predicted as the cat ones, but they actually have a dog on them. So, FP = 6.

Confusion Matrix:

Observed Positive observed Negative

Predicted Positive TP=6 FP=6

Predicted Negative FN=9 TN=14

Calculating metrics on the above confusion matrix:

1) Accuracy:

OR
So, by the above formula, we have:

6+ 14
Accuracy=
6+6+ 9+14

20
Accuracy=
35

Acuracy=0.571428571

2) Precision:

6
precision=
6+6

6
precision=
12

precision=0.5

3) Recall (TRUE POSITIVE RATE):


6
Recall=
6+ 9

6
Recall=
15

Recall=0.4

4) Specificity (TRUE NEGATIVE RATE):

14
Specificity=
20

Specificity=0.7
5) False Positive Rate:

6
FPR=
6+14

6
FPR=
20

FPR=0.3

OR
FPR=1−SPECIFICITY

FPR=1−0.7

FPR=0.3
6) Error Rate:

6+9
ERR=
35

15
ERR=
35

ERR=0.428571429

You might also like