简体   繁体   English

如何在 python 中找到已经训练和保存的 model 的 f1 分数

[英]How to find f1 score of a already trained & saved model in python

Suppose I have a model which I have already trained and saved(using python).假设我有一个 model,我已经训练并保存了(使用 python)。 Now if I want to get the f1 score of that model then how to do it using python?现在,如果我想获得 model 的 f1 分数,那么如何使用 python 来做到这一点? Anyone who khows this please help.任何知道这一点的人请帮忙。

y_true is the result list you already have and testing your model against. y_true 是您已经拥有并测试您的 model 的结果列表。

y_pred is the list predicted by your model. y_pred 是您的 model 预测的列表。

from sklearn.metrics import f1_score
y_true = [0, 1, 2, 0, 1, 2]
y_pred = [0, 2, 1, 0, 0, 1]

f1_score(y_true, y_pred, average='macro')
0.26
f1_score(y_true, y_pred, average='micro')
0.33
f1_score(y_true, y_pred, average='weighted')
0.26
f1_score(y_true, y_pred, average=None)
array([0.8, 0. , 0. ])

You can mark it solved, If it works.如果有效,您可以将其标记为已解决。

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

相关问题 如何找出在 Python 中网格搜索中选择的最佳 model 的精度、召回率、特异性和 F1 分数? - How to find out precision, recall, specificity & F1 score of the best model which is selected in Grid Search in Python? 如何在 Keras 模型中使用 F1 Score? - How to use F1 Score with Keras model? 如何找到我的 word2vec model 的准确度、精确度、召回率和 f1 分数? - How to find accuracy, precision, recall, f1 score for my word2vec model? 如何计算 python 中平衡逻辑回归 model 的精度、召回率和 f1 分数 - How to compute precision,recall and f1 score of an balanced logistic regression model in python 如何在 python 中使用多处理计算 f1 分数? - How to calculate f1 score using multiprocessing in python? Keras F1评分指标用于训练模型 - Keras F1 score metrics for training the model 如何提高分类的 F1 分数 - How to improve F1 score for classification 当输出是单热编码时如何计算 Roberta model 的 F1 分数(Pytorch) - How to compute F1 score for Roberta model when outputs are one-hot encoded (Pytorch) 如何在迁移学习 vgg16 模型中获得准确率、召回率、f1 分数? - How to get precision, recall, f1 score in transfer learning vgg16 model? Python Catboost:多类 F1 得分自定义指标 - Python Catboost: Multiclass F1 score custom metric
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM