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.
Asked
Active
Viewed 317 times
0
-
1please refer this [link](https://stackoverflow.com/questions/31421413/how-to-compute-precision-recall-accuracy-and-f1-score-for-the-multiclass-case). For keras check this [one](https://datascience.stackexchange.com/questions/45165/how-to-get-accuracy-f1-precision-and-recall-for-a-keras-model) [link2](https://towardsdatascience.com/f-beta-score-in-keras-part-i-86ad190a252f) – gowridev Jun 01 '21 at 05:08
1 Answers
0
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.

Aavesh
- 94
- 8