Spaces:
Sleeping
Sleeping
John Graham Reynolds
commited on
Commit
·
b1e5224
1
Parent(s):
de39461
update citation, comments
Browse files- fixed_f1.py +4 -3
fixed_f1.py
CHANGED
@@ -13,12 +13,12 @@ F1 = 2 * (precision * recall) / (precision + recall)
|
|
13 |
"""
|
14 |
|
15 |
_CITATION = """
|
16 |
-
@online{
|
17 |
author = {John Graham Reynolds aka @MarioBarbeque},
|
18 |
title = {{Fixed F1 Hugging Face Metric},
|
19 |
year = 2024,
|
20 |
url = {https://huggingface.co/spaces/MarioBarbeque/FixedF1},
|
21 |
-
urldate = {
|
22 |
}
|
23 |
"""
|
24 |
|
@@ -28,7 +28,7 @@ If None, the scores for each class are returned. Otherwise, this determines the
|
|
28 |
Options include: {‘micro’, ‘macro’, ‘samples’, ‘weighted’, ‘binary’} or None.
|
29 |
"""
|
30 |
|
31 |
-
# could in principle subclass the F1 Metric, but ideally we can work the fix into
|
32 |
# for this fix we create a new class
|
33 |
|
34 |
class FixedF1(evaluate.Metric):
|
@@ -58,6 +58,7 @@ class FixedF1(evaluate.Metric):
|
|
58 |
)
|
59 |
|
60 |
# could remove specific kwargs like average, sample_weight from _compute() method of F1
|
|
|
61 |
|
62 |
def _compute(self, predictions, references, labels=None, pos_label=1, average="binary", sample_weight=None):
|
63 |
score = f1_score(
|
|
|
13 |
"""
|
14 |
|
15 |
_CITATION = """
|
16 |
+
@online{MarioBbq@HFf1,
|
17 |
author = {John Graham Reynolds aka @MarioBarbeque},
|
18 |
title = {{Fixed F1 Hugging Face Metric},
|
19 |
year = 2024,
|
20 |
url = {https://huggingface.co/spaces/MarioBarbeque/FixedF1},
|
21 |
+
urldate = {2024-11-5}
|
22 |
}
|
23 |
"""
|
24 |
|
|
|
28 |
Options include: {‘micro’, ‘macro’, ‘samples’, ‘weighted’, ‘binary’} or None.
|
29 |
"""
|
30 |
|
31 |
+
# could in principle subclass the F1 Metric, but ideally we can work the fix into HF evaluate's main F1 class to maintain SOLID code
|
32 |
# for this fix we create a new class
|
33 |
|
34 |
class FixedF1(evaluate.Metric):
|
|
|
58 |
)
|
59 |
|
60 |
# could remove specific kwargs like average, sample_weight from _compute() method of F1
|
61 |
+
# but leaving for sake of potentially subclassing F1
|
62 |
|
63 |
def _compute(self, predictions, references, labels=None, pos_label=1, average="binary", sample_weight=None):
|
64 |
score = f1_score(
|