Classification Metrics Worksheet
Classification Metrics Worksheet
Predicted
Spam Not Spam
Spam 80 40
Actual
Not Spam 10 870
TP 80 80
Precision = TP+ FP = 80+10 = 90 = 0.89
TP 80 80
Recall = TP+ FN = 80+40 = 120 = 0.67
60 20 TP 60
15 105 TN 105
FP 15
FN 20
Predicted
Disease No disease
Disease 60 20
Actual
No disease 15 105
TP 60 60
Precision = TP+ FP = 60+15 = 75 = 0.8
TP 60 60
Recall = TP+ FN = 60+20 = 80 = 0.75
Precision∗Recall 0.8∗0.75 0.6
F1-score = 2 * Precision+ Recall = 2 * 0.8+0.75 = 2 * 1.55 = 2 * 0.388 = 0.774
Predicted
Cat Not cat
Cat 90 30
Actual
Not cat 10 170
TP 90 90
Precision = TP+ FP = 90+10 = 100 = 0.9
TP 90 90
Recall = TP+ FN = 90+30 = 120 = 0.75
100 0 TP 100
50 850 TN 850
FP 50
FN 0
Predicted
Fraud Not fraud
Fraud 100 0
Actual
Not Fraud 50 850
TP 100 100
Recall = TP+ FN = 100+0 = 100 = 1.0
An AI model predicted that of the 250 visitors to a website, 100 would buy, but only 80 actually bought. Of the 150
they predicted would not buy, 30 bought. Draw a confusion matrix & calculate Accuracy, Precision, Recall & F1-
Score.
Predicted
Recommend Don’t recommend
Recommend 80 30
Actual
Don’t recommend 20 120
TP 80 80
Precision = TP+ FP = 80+20 = 100 = 0.8
TP 80 80
Recall = TP+ FN = 80+30 = 110 = 0.72727
80 30 TP 80
20 120 TN 120
FP 20
FN 30
Predicted
Positive Negative
Positive 150 15
Actual
Negative 25 180
TP+TN 150+180 330
Accuracy = TP+ TN + FP+ FN = 150+180+25+15 = 370 = 0.89189
TP 150 150
Precision = TP+ FP = 150+25 = 175 = 0.857
TP 150 150
Recall = TP+ FN = 150+15 = 165 = 0.90909
0.8823
Predicted
Churn No churn
Churn 75 50
Actual
No churn 25 850
TP 75 75
Precision = TP+ FP = 75+25 = 100 = 0.75
TP 75 75
Recall = TP+ FN = 75+50 = 125 = 0.6
120 50 TP 120
30 800 TN 800
FP 30
FN 50
Approve 120 50
Actual
Reject 30 800
TP 120 120
Precision = TP+ FP = 120+30 = 150 = 0.8
TP 120 120
Recall = TP+ FN = 120+50 = 170 = 0.71
Predicted
Attack Normal
Attack 95 5
Actual
Normal 50 850
TP 95 95
Precision = TP+ FP = 95+50 = 145 = 0.66
TP 95 95
Recall = TP+ FN = 95+5 = 100 = 0.95
70 10 TP 70
30 90 TN 90
FP 30
FN 10
Predicted
Fake Real
Fake 70 10
Actual
Real 30 90
TP 70 70
Precision = TP+ FP = 70+30 = 100 = 0.7
TP 70 70
Recall = TP+ FN = 70+10 = 80 = 0.88