Hunar
Hunar

Reputation: 399

how to read tensorflow confusion matrix rows and columns

For my 2 classes (1 = [0, 1] and 0 = [1, 0]) CNN model I use tf.confusion_matrix to finding a confusion matrix for the model. one of my results is like below for validation set:

[ [1800  17] 
  [283  600] ]

after doing some search I see more than one type of reading, some of them say [[TN FP][FN TP]], but some others read it in this way [[TP FP][FN TN]], I am confused which one is right for my case? please give me an answer that depends on scientific research if you can.

Upvotes: 0

Views: 407

Answers (1)

m33n
m33n

Reputation: 1751

The truth is behind the code ;) https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/confusion_matrix.py

Class labels are expected to start at 0. For example, if num_classes is 3, then the possible labels would be [0, 1, 2]. Note that the possible labels are assumed to be [0, 1, 2, 3, 4], resulting in a 5x5 confusion matrix.

So better don't pass one hot tensors to the function ;) (tf.argmax might be a good friend here)

This means that the first element (row 0 col 0) corresponds with the number of elements that have been properly classified for class 0.

Row 0 col 1 will correspond with the missclassified elements of the class 0 and so on.

Upvotes: 1

Related Questions