Spaces:
Running
Running
BUG: scikit learn's metric f1 score now returns a python native float
Browse filesBUG: scikit learn's metric f1 score now returns a python native float. Converting it back to a numpy array for backward compatibility
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}
|