| Dog | 23 | 12 | 7 |
| Cat | 11 | 29 | 13 |
| Rabbit | 4 | 10 | 24 |
| Actual | Predicted | ||
|---|---|---|---|
| Dog | Cat | Rabbit | |
| Dog | 23 | 12 | 7 |
| Cat | 11 | 29 | 13 |
| Rabbit | 4 | 10 | 24 |
Calculate the value of Accuracy Rate, Sensitivity and Specificity.
| TP | TN | FP | FN | |
|---|---|---|---|---|
| Dog | 23 | 29 + 13 + 10 + 24 = 76 | 11 + 4 = 15 | 12 + 7 = 19 |
| Cat | 29 | 23 + 7 + 4 + 24 = 58 | 12 + 10 = 22 | 11 + 13 = 24 |
| Rabbit | 24 | 23 + 12 + 11 + 29 = 75 | 7 + 13 = 20 | 4 + 10 = 14 |
Accuracy for Dog
Accuracy = (TP + TN) / (TP + TN + FP + FN)
= (23 + 76) / (23 + 76 + 15 + 19)
= 99 / 133 = 0.744 = 74.4%
Sensitivity for Cat
Sensitivity = TP / (TP + FN)
= 29 / (29 + 24) = 0.54 = 54%
Specificity for Rabbit
Specificity = TN / (TN + FP)
= 75 / (75 + 20) = 0.78 = 78%
Consider the following 3-class confusion matrix. Calculate precision and recall per class.
Also calculate weighted average precision and recall for classifier.
| 15 | 2 | 3 | |
| 7 | 15 | 8 | |
| 2 | 3 | 45 |
| A | B | C | Total | |
|---|---|---|---|---|
| A | 15 | 2 | 3 | 20 |
| B | 7 | 15 | 8 | 30 |
| C | 2 | 3 | 45 | 50 |
| Total | 24 | 20 | 56 | 100 |
Precision = Correctly Predicted / Total Predicted
Precision of Class A = 15 / 24 = 0.625
Precision of Class B = 15 / 20 = 0.75
Precision of Class C = 45 / 56 = 0.80
Recall = Correctly Classified / Actual
Recall of Class A = 15 / 20 = 0.75
Recall of Class B = 15 / 30 = 0.50
Recall of Class C = 45 / 50 = 0.90
Accuracy = Total Correctly Classified / Total Actual
Accuracy of Classifier = (15 + 15 + 45) / 100 = 0.75
Actual Class A instances = 20 / 100 = 0.2
Actual Class B instances = 30 / 100 = 0.3
Actual Class C instances = 50 / 100 = 0.5
Weighted average precision =
(0.2 × 0.625) + (0.3 × 0.75) + (0.5 × 0.80) = 0.75
Weighted average recall =
(0.2 × 0.75) + (0.3 × 0.5) + (0.5 × 0.90) = 0.75