Solved – How to find TP,TN, FP and FN values from 8×8 Confusion Matrix

confusion matrixweka

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 ?

Can we consider summation of the RED bordered area as TN value for class 'a'?

Can we consider summation of the RED bordered area as TN value for class 'a'?

Best Answer

True Positive, True Negative, False Positive, and False Negative are defined for binary classification problems (in which one outcome is defined as "positive" and the other "negative").

So to use this terminology as a measure of success for a larger confusion matrix, you must break the table down into a series of binary classification sub-tables.

For example, we could calculate the TP, TN, FP, and FN for class A. This breaks down as follows

  • TP: True A's that are correctly classified as A
  • TN: All other classes correctly classified as not A
  • FP: Other classes incorrectly classified as A
  • FN: A's that were incorrectly classified as not A

This could then be repeated for all classes to get a TP, TN, FP, and FN conditional on each actual class.

Alternatively, you could use a measure calculated on the table as a whole such as overall accuracy. More sophisticated measures can also be calculated to evaluate purity of the classification. This Stack Overflow link provides a good start for investigating some of these methods: how to calculate classification error rate