[英]Get list of true positives, false positives, false negatives and true negatives with tensorflow
Here is my work:这是我的工作:
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?)问题是:如何获取分类为“活”或“死”的图像列表,以便我可以检查它们(可能有些图像不在正确的文件夹中?或者 model 对特定类型的图像有问题?)
Please, could you let me know if you have any clue in order to solve this issue?拜托,如果你有任何线索来解决这个问题,你能告诉我吗?
Kindly yours.请你的。
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.
差异向量将包含正确分类的零,-1 表示误报,1 表示误报。 You can then for example use
np.where
to find the indices of false positives and whatnot.然后,您可以例如使用
np.where
来查找误报和诸如此类的索引。
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])
output: output:
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]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.