Confusion matrix for multi-class classification | Abhishek Jain | Sep 2024

SeniorTechInfo
2 Min Read
Abhishek Jain

FN: The False-negative value for a class will be the sum of values of corresponding rows except for the TP value.

FP: The False-positive value for a class will be the sum of values of the corresponding column except for the TP value.

TN: The True-negative value for a class will be the sum of the values of all columns and rows except the values of that class that we are calculating the values for.

And TP: the True-positive value is where the actual value and predicted value are the same.

The 3×3 confusion matrix multiclass for the IRIS dataset is as below:

Let us calculate the TP, TN, FP, and FN values for the class Setosa using the Above tricks:

TP: The actual value and predicted value should be the same. So concerning Setosa class, the value of cell 1 is the TP value which is 16.

TN: The sum of values of all columns and rows except the values of that class that we are calculating the values for.

TN = (cell 5 + cell 6 + cell 8 + cell 9)

= 17 + 1 +0 + 11

= 29

FP: The sum of values of the corresponding column except for the TP value.

FP = (cell 4 + cell 7)

= (0 + 0)

= 0

FN: The sum of values of corresponding rows except for the TP value

FN = (cell 2 + cell 3)

= (0 + 0)

= 0

Similarly, for the Versicolor class, the values/metrics are calculated as below:

TP: 17 (cell 5)

TN : 16 +0 +0 + 11 =27 (cell 1 + cell 3 + cell 7 + cell 9).

FP : 0 + 0 = 0 (cell 2 + cell 8)

FN : 0 + 1 = 1 (cell 4 +cell 6)

Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *