Spaces:
Sleeping
Sleeping
up
Browse files- requirements.txt +3 -1
- sklearn_proxy.py +4 -7
requirements.txt
CHANGED
@@ -1 +1,3 @@
|
|
1 |
-
git+https://github.com/huggingface/evaluate@main
|
|
|
|
|
|
1 |
+
git+https://github.com/huggingface/evaluate@main
|
2 |
+
|
3 |
+
scikit-learn
|
sklearn_proxy.py
CHANGED
@@ -15,6 +15,7 @@
|
|
15 |
|
16 |
import evaluate
|
17 |
import datasets
|
|
|
18 |
|
19 |
|
20 |
# TODO: Add BibTeX citation
|
@@ -86,10 +87,6 @@ class SklearnProxy(evaluate.Metric):
|
|
86 |
# TODO: Download external resources if needed
|
87 |
pass
|
88 |
|
89 |
-
def _compute(self, predictions, references):
|
90 |
-
|
91 |
-
|
92 |
-
accuracy = sum(i == j for i, j in zip(predictions, references)) / len(predictions)
|
93 |
-
return {
|
94 |
-
"accuracy": accuracy,
|
95 |
-
}
|
|
|
15 |
|
16 |
import evaluate
|
17 |
import datasets
|
18 |
+
from sklearn.metrics import get_scorer
|
19 |
|
20 |
|
21 |
# TODO: Add BibTeX citation
|
|
|
87 |
# TODO: Download external resources if needed
|
88 |
pass
|
89 |
|
90 |
+
def _compute(self, predictions, references, metric_name="accuracy", **kwargs):
|
91 |
+
scorer = get_scorer(metric_name)
|
92 |
+
return scorer(references, predictions, **kwargs)
|
|
|
|
|
|
|
|