t5-nynorsk-norbench / my_metrics.py
pere's picture
new norbench
f811c13
import sklearn.metrics
import numpy as np
def f1_macro(targets, predictions):
targets, predictions = np.asarray(targets), np.asarray(predictions)
unique_labels = np.unique(np.concatenate((targets, predictions)))
return {"f1_macro": 100 * sklearn.metrics.f1_score(targets, predictions, labels=unique_labels, average='macro')}