utils.py 272 Bytes
Newer Older
KounianhuaDu's avatar
KounianhuaDu committed
1
import numpy as np
2
3
from sklearn.metrics import f1_score

KounianhuaDu's avatar
KounianhuaDu committed
4

5
# function to compute f1 score
KounianhuaDu's avatar
KounianhuaDu committed
6
7
8
9
10
def evaluate_f1_score(pred, label):
    pred = np.round(pred, 0).astype(np.int16)
    pred = pred.flatten()
    label = label.flatten()
    return f1_score(y_pred=pred, y_true=label)