简体   繁体   English

如何计算实体预测的精度、召回率和 F1

[英]How to Calculate Precision, Recall, and F1 for Entity Prediction

I used an Entity Linking Model from Github to predict a set of documents.我使用来自Github的实体链接 Model 来预测一组文档。 Since they do not actually explain how to calculate precision, recall, and F1.因为他们实际上并没有解释如何计算精度、召回率和 F1。 So I created a dataframe by using the actual tag and predict tag from the testing data.因此,我使用实际标签创建了一个 dataframe,并从测试数据中预测标签。

 Actual           Predict
security          security
london             london
  UK                 US
  :                   :
  :                   :
domain              menu
sushi               soso
tom                jerry

I am wondering based on this, will I be able to calculate the precision, recall, and f1 on my own and if I can, how can I do it?我想知道基于此,我是否能够自己计算精度、召回率和 f1,如果可以,我该怎么做? Thanks!谢谢!

I assume that you have the value of y_test then you may have y_pred according with your prediction.我假设你有 y_test 的值,那么你可能有 y_pred 根据你的预测。

Calculating the precision, recall, and fscore are able using these library from sklearn.metrics import precision_score, recall_score, f1_score计算精度、召回率和 fscore 可以使用 sklearn.metrics 中的这些库导入precision_score、recall_score、f1_score

calculate metrics计算指标

import sklearn
from sklearn.metrics import precision_score, recall_score, f1_score
precision = precision_score(y_test, y_pred)
recall = recall_score(y_test, y_pred)
f1_score = f1_score(y_test, y_pred)

i got it from https://machinelearningmastery.com/precision-recall-and-f-measure-for-imbalanced-classification/ https://machinelearningmastery.com/how-to-calculate-precision-recall-f1-and-more-for-deep-learning-models/我从https://machinelearningmastery.com/precision-recall-and-f-measure-for-imbalanced-classification/ https://machinelearningmastery.com/how-to-calculate-precision-recall-f1-and-得到它更多深度学习模型/

暂无
暂无

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

相关问题 如何在训练 SSD 后预测 Precision、Recall 和 F1 分数 - How to predict Precision, Recall and F1 score after training SSD 相同的测试和预测值给出 0 精度、召回率和 NER 的 f1 分数 - Same test and prediction values gives 0 precision, recall, f1 score for NER 如何计算多类的精度、召回率和 f1 分数? 我们如何在交叉验证中使用 average='micro','macro' 等? - How to calculate precision ,recall & f1 score for multiclass? How can we use average='micro','macro' etc. in cross validation? 精度,召回率,F1得分与sklearn相等 - Precision, recall, F1 score equal with sklearn Tensorflow:计算精度、召回率、F1 分数 - Tensorflow: Compute Precision, Recall, F1 Score 如何计算召回率,精度和f值? - How to calculate recall, precision and f-measure? 在 tf.Estimator 设置中使用 tf.metrics.precision/recall 计算 F1 分数 - Calculate F1 Score using tf.metrics.precision/recall in a tf.Estimator setup 如何获得sklearn的平均精度,召回率,f1,交叉验证的精度? - How to get average precision, recall, f1, accuracy of cross-validation with sklearn? 如何找出在 Python 中网格搜索中选择的最佳 model 的精度、召回率、特异性和 F1 分数? - How to find out precision, recall, specificity & F1 score of the best model which is selected in Grid Search in Python? 如何计算 K 折交叉验证的不平衡数据集的精度、召回率和 f1 分数? - How to compute precision,recall and f1 score of an imbalanced dataset for K fold cross validation?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM