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