Search code examples
wekaconfusion-matrix

How to find TP,TN, FP and FN values from 8x8 Confusion Matrix


I have confusion matrix as follow:

   a    b    c    d    e    f    g    h   <-- classified as
1086 7 1 0 2 4 0 0 | a
7 1064 8 6 0 2 2 0 | b
0 2 1091 2 3 0 1 1 | c
0 8 0 1090 1 1 0 0 | d
1 1 1 1 597 2 2 0 | e
4 2 1 0 3 1089 0 1 | f
0 2 1 3 0 0 219 0 | g
0 0 1 0 1 4 1 443 | h

Now how to find the True positive, True Negative, False Positive and False Negative values from this confusion matrix. The Weka gave me TP Rate is that same as True positive value ?


Solution

  • You have total 8 classes: a, b, c, d, e, f, g, h. You will thus get 8 different TP, FP, FN, and TN numbers. For instance, in the case of a class,

    TP (instance belongs to a, classified as a) = 1086
    FP (instance belongs to others, classified as a) = 7 + 0 + 0 + 1 + 4 + 0 + 0 = 12
    FN (instance belongs to a, classified as others) = 7 + 1 + 0 + 2 + 4 + 0 + 0 = 14
    TN (instance belongs to others, classified as others) = Total instance - (TP + FP + FN)
    

    TP rate is not TP. It is the Recall or TP/TP+FN.