[英]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.