错误否定和真实否定的列表

错误否定和真实否定的列表

本文介绍了使用tensorflow获取真实肯定,错误肯定,错误否定和真实否定的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的工作:

  • 我标注了活"细胞的图像(约8.000)和死"细胞的图像(约2.000)(测试集分别为800和200)
  • 我正在使用CNN(具有tensorflow和keras)以便将图像分类为活着"或死亡".
  • 我训练了我的模型:验证损失= 0.35,召回率= 0.81,准确性= 0.81.

这是问题所在:如何获取分类为活动"或死"的图像列表,以便我可以检查它们(也许某些图像不在正确的文件夹中?或者模型的特定类型有问题)图片?)

Here is the problem : how can I get the list of images classified as "Living" or "Dead" so I can check them (maybe some of images are not in the right folder ? Or model has issue with specific type of images ?)

请,请问您是否有任何线索可以解决此问题?

Please, could you let me know if you have any clue in order to solve this issue ?

亲爱的.

推荐答案

对于二进制分类,您可以在真实标签向量和预测标签之间进行区别.差分向量在正确分类的地方将包含零,对于误报为-1,对于误报为1.然后,您可以使用np.where查找误报的索引,而不是查找误报的索引.

For the case of binary classification you can take difference between the vector of true labels and the predicted labels. The difference vector will contain zeros where it classified correctly, -1 for false positives, 1 for false negatives. You can then for example use np.where to find the indices of false positives and whatnot.

要获取假阳性和假阴性等的索引,您只需执行以下操作:

To get the indices of false positives and false negatives etc you can simply do:

import numpy as np

real = np.array([1,0,0,1,1,1,1,1])
predicted = np.array([1,1,0,0,1,1,0,1])

diff = real-predicted
print('diff: ',diff)

# Correct is 0
# FP is -1
# FN is 1
print('Correctly classified: ', np.where(diff == 0)[0])
print('Incorrectly classified: ', np.where(diff != 0)[0])
print('False positives: ', np.where(diff == -1)[0])
print('False negatives: ', np.where(diff == 1)[0])

输出:

diff:  [ 0 -1  0  1  0  0  1  0]
Correctly classified:  [0 2 4 5 7]
Incorrectly classified:  [1 3 6]
False positives:  [1]
False negatives:  [3 6]

这篇关于使用tensorflow获取真实肯定,错误肯定,错误否定和真实否定的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 05:06