简体   繁体   English

如何在训练 SSD 后预测 Precision、Recall 和 F1 分数

[英]How to predict Precision, Recall and F1 score after training SSD

I am new to deep learning and I want to be able to evaluate the model which underwent training for certain epochs using F1 score.我是深度学习的新手,我希望能够使用 F1 分数评估经过特定时期训练的模型。 I believe it requires the calculation of precision and recall first.我相信它首先需要计算精度和召回率。

The model trained is SSD-300-Tensorflow.训练的模型是 SSD-300-Tensorflow。 Is there a code or something that can produce these results?是否有代码或可以产生这些结果的东西? I am not using sci-kit or anything as I am not sure if that is required to calculate the score but any guidance is appreciated.我没有使用 sci-kit 或任何东西,因为我不确定计算分数是否需要这样做,但感谢任何指导。

You should first calculate False positive, False negatives, True positive and True negatives.您应该首先计算假阳性、假阴性、真阳​​性和真阴性。 To obtain these values you must evaluate your model with test dataset.要获得这些值,您必须使用测试数据集评估您的模型。 This link might help此链接可能会有所帮助

with these formulas you can calculate precision and recall and here is some example code:使用这些公式,您可以计算精度和召回率,以下是一些示例代码:

y_hat = []
y = []
threshold = 0.5
for data, label in test_dataset:
    y_hat.extend(model.predict(data))
    y.extend(label.numpy()[:, 1])
    y_hat = np.asarray(y_hat)
    y = np.asarray(y)
    m = len(y)
    y_hat = np.asarray([1 if i > threshold else 0 for i in y_hat[:, 1]])
    true_positive = np.logical_and(y, y_hat).sum()
    true_negative = np.logical_and(np.logical_not(y_hat), np.logical_not(y)).sum()
    false_positive = np.logical_and(np.logical_not(y), y_hat).sum()
    false_negative = np.logical_and(np.logical_not(y_hat), y).sum()
    total = true_positive + true_negative + false_negative + false_positive
    assert total == m
    precision = true_positive / (true_positive + false_positive)
    recall = true_positive / (true_positive + false_negative)
    accuracy = (true_positive + true_negative) / total
    f1score = 2 * precision * recall / (precision + recall)

If you are using the Tensorflow Object Detection API, it provides a way for running model evaluation that can be configured for different metrics.如果您使用的是 Tensorflow 对象检测 API,它提供了一种运行模型评估的方法,可以针对不同的指标进行配置。 A tutorial on how to do this is here .有关如何执行此操作的教程在这里

The COCO evaluation metrics includes analogous measures of precision and recall for object detection use cases. COCO 评估指标包括对对象检测用例的精确度和召回率的类似测量。 A good overview of these metrics is here .这些指标的一个很好的概述是here The concepts of precision and recall need to be adapted somewhat for object detection scenarios because you have to define "how closely" a predicted bounding box needs to match the ground truth bounding box to be considered a true positive.精确率和召回率的概念需要针对对象检测场景进行一些调整,因为您必须定义预测边界框与地面实况边界框匹配的“接近程度”才能被视为真正的正例。

I am not certain what the analog for F1 score would be for object detection scenarios.我不确定对象检测场景中 F1 分数的模拟是什么。 Typically, I have seen models compared using mAP as the single evaluation metric.通常,我已经看到使用 mAP 作为单一评估指标来比较模型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Tensorflow:计算精度、召回率、F1 分数 - Tensorflow: Compute Precision, Recall, F1 Score 精度,召回率,F1得分与sklearn相等 - Precision, recall, F1 score equal with sklearn Tensorflow Precision / Recall / F1 分数和混淆矩阵 - Tensorflow Precision / Recall / F1 score and Confusion matrix 在Keras获得每班的精确度,召回率和F1分数 - Getting precision, recall and F1 score per class in Keras 使用 precision_recall_curve 计算最大 f1 分数? - compute maximum f1 score using precision_recall_curve? 使用自制分离器获得精确度、召回率、F1 分数 - Get Precision, Recall, F1 Score with self-made splitter 在tfhub重新训练脚本中计算F1得分,精度,召回率 - Calculating F1 score, precision, recall in tfhub retraining script 计算多 label 分类 keras 的召回精度和 F1 分数 - compute the recall precision and F1 score for a multi label classification keras 如何在迁移学习 vgg16 模型中获得准确率、召回率、f1 分数? - How to get precision, recall, f1 score in transfer learning vgg16 model? 如何找到我的 word2vec model 的准确度、精确度、召回率和 f1 分数? - How to find accuracy, precision, recall, f1 score for my word2vec model?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM