简体   繁体   中英

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). Now if I want to get the f1 score of that model then how to do it using python? Anyone who khows this please help.

y_true is the result list you already have and testing your model against.

y_pred is the list predicted by your 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM