简体   繁体   English

使用 tensorflow 获取真阳性、假阳性、假阴性和真阴性列表

[英]Get list of true positives, false positives, false negatives and true negatives with tensorflow

Here is my work:这是我的工作:

  • I have annotated images of "Living" cells (circa 8.000) and images of "Dead" cells (circa 2.000) (+ 800 and 200 for testing set)我注释了“活”细胞的图像(大约 8.000)和“死”细胞的图像(大约 2.000)(+ 800 和 200 用于测试集)
  • I am using CNN (with tensorflow and keras) in order to classify images as "Living" or "Dead".我正在使用 CNN(使用 tensorflow 和 keras)将图像分类为“活”或“死”。
  • I trained my model: validation loss = 0.35, recall = 0.81, accuracy = 0.81.我训练了我的 model:验证损失 = 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?)问题是:如何获取分类为“活”或“死”的图像列表,以便我可以检查它们(可能有些图像不在正确的文件夹中?或者 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.

相关问题 考虑到所有类,如何找到所有真阳性、阴性和假阳性和阴性 - How to find all the True Positives,negatives and False Positives and Negatives considering all the classes 计算 DataFrame 中响应的真阳性和假阴性 - Calculate True Positives and False Negatives for Responses Within a DataFrame 从混淆矩阵中获取假阴性、假阳性、真阳性和真阴性的相关数据集 - Getting relevant datasets of false negatives, false positives, true positive and true negative from confusion matrix 如何在逻辑回归中增加假阳性和减少假阴性? - How to increase false positives and reduce false negatives in a logistic regression? 如何惩罚误报而不是误报 - How to penalize False Negatives more than False Positives 是否可以检索由混淆矩阵识别的误报/误报? - Is it possible to retrieve False Positives/ False Negatives identified by a confusion Matrix? 获取混淆矩阵的误报和漏报相关数据集? - Getting False positives and False negatives relevant datasets of confusion matrix? 为什么在机器学习模型中所有的真阳性都被归类为真阴性? - Why all the true positives are classified as true negatives in the machine learning model? 列表中的否定和肯定 - negatives and positives in lists 在numpy中平衡正负 - balance positives and negatives in numpy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM