[英]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. 对于我的2个类( 1 = [0, 1]
和0 = [1, 0]
),我们使用tf.confusion_matrix
查找该模型的混淆矩阵。 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? 搜索后,我看到的阅读类型不止一种,其中有些人说[[TN FP][FN TP]]
,但另一些人则以这种方式阅读[[TP FP][FN TN]]
,我很困惑哪一个适合我的情况? please give me an answer that depends on scientific research if you can. 如果可以的话,请给我一个取决于科学研究的答案。
The truth is behind the code ;) https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/confusion_matrix.py 事实是代码背后;) 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]
. 类标签应从0开始。例如,如果num_classes
为3,则可能的标签为[0, 1, 2]
。 Note that the possible labels are assumed to be[0, 1, 2, 3, 4]
, resulting in a 5x5 confusion matrix. 请注意,假定可能的标签为[0, 1, 2, 3, 4]
,从而导致5x5混淆矩阵。
So better don't pass one hot tensors to the function ;) (tf.argmax might be a good friend here) 因此最好不要将一个热张量传递给该函数;)(tf.argmax在这里可能是个好朋友)
This means that the first element (row 0 col 0) corresponds with the number of elements that have been properly classified for class 0. 这意味着第一个元素(行0 col 0)对应于已为类别0正确分类的元素数量。
Row 0 col 1 will correspond with the missclassified elements of the class 0 and so on. 第0行第1行将与类别0的未分类元素相对应,依此类推。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.