mgunther commited on
Commit
c35a76f
·
verified ·
1 Parent(s): 088d973

BUG: scikit learn's metric f1 score now returns a python native float

Browse files

BUG: scikit learn's metric f1 score now returns a python native float. Converting it back to a numpy array for backward compatibility

Files changed (1) hide show
  1. f1.py +2 -0
f1.py CHANGED
@@ -14,6 +14,7 @@
14
  """F1 metric."""
15
 
16
  import datasets
 
17
  from sklearn.metrics import f1_score
18
 
19
  import evaluate
@@ -127,4 +128,5 @@ class F1(evaluate.Metric):
127
  score = f1_score(
128
  references, predictions, labels=labels, pos_label=pos_label, average=average, sample_weight=sample_weight
129
  )
 
130
  return {"f1": float(score) if score.size == 1 else score}
 
14
  """F1 metric."""
15
 
16
  import datasets
17
+ import numpy as np
18
  from sklearn.metrics import f1_score
19
 
20
  import evaluate
 
128
  score = f1_score(
129
  references, predictions, labels=labels, pos_label=pos_label, average=average, sample_weight=sample_weight
130
  )
131
+ score=np.array(score)
132
  return {"f1": float(score) if score.size == 1 else score}