Consider the below confusion matrix generated by a classification model. The…

2025

Consider the below confusion matrix generated by a classification model. The model classifies given input in ‘Benign’ or ‘Malignant’ class. Evaluate the Accuracy, Precision, Recall, and F1 Score of the said model for both cases i.e. when ‘Benign’ is the positive class and when ‘Malignant’ is the positive class.

N = 170

Predicted: Benign

Predicted: Malignant

Actual: Benign

50

15

Actual: Malignant

5

100

Attempted by 54 students.

Show answer & explanation
  1. The confusion matrix shows the classification results of a model that predicts whether a tumor is Benign or Malignant. Total observations N = 170.

Actual Benign predicted as Benign = 50
Actual Benign predicted as Malignant = 15
Actual Malignant predicted as Benign = 5
Actual Malignant predicted as Malignant = 100

  1. Case 1: When Benign is considered as the positive class

True Positive (TP) = 50
False Negative (FN) = 15
False Positive (FP) = 5
True Negative (TN) = 100

Accuracy = (TP + TN) / Total
Accuracy = (50 + 100) / 170 = 150 / 170 = 0.882

Precision = TP / (TP + FP)
Precision = 50 / (50 + 5) = 50 / 55 = 0.909

Recall = TP / (TP + FN)
Recall = 50 / (50 + 15) = 50 / 65 = 0.769

F1 Score = 2 × (Precision × Recall) / (Precision + Recall)
F1 = 2 × (0.909 × 0.769) / (0.909 + 0.769) = 0.833

  1. Case 2: When Malignant is considered as the positive class

True Positive (TP) = 100
False Negative (FN) = 5
False Positive (FP) = 15
True Negative (TN) = 50

Accuracy = (TP + TN) / Total
Accuracy = (100 + 50) / 170 = 150 / 170 = 0.882

Precision = TP / (TP + FP)
Precision = 100 / (100 + 15) = 100 / 115 = 0.870

Recall = TP / (TP + FN)
Recall = 100 / (100 + 5) = 100 / 105 = 0.952

F1 Score = 2 × (Precision × Recall) / (Precision + Recall)
F1 = 2 × (0.870 × 0.952) / (0.870 + 0.952) = 0.909

  1. Final result

When Benign is positive
Accuracy = 0.882
Precision = 0.909
Recall = 0.769
F1 Score = 0.833

When Malignant is positive
Accuracy = 0.882
Precision = 0.870
Recall = 0.952
F1 Score = 0.909

This shows that the model detects Malignant cases with higher recall compared to Benign cases.

Explore the full course: Hpsc Pgt Computer Science