Spaces:
Runtime error
Runtime error
change of behaviour for empty
Browse files- README.md +12 -0
- multi_label_precision_recall_accuracy_fscore.py +3 -0
- tests.py +4 -4
README.md
CHANGED
@@ -62,6 +62,7 @@ It uses the same definition as in previous case, but it works with multiset of l
|
|
62 |
- **predictions** *(list[Union[int,str]]): list of predictions to score. Each predictions should be a list of predicted labels*
|
63 |
- **references** *(list[Union[int,str]]): list of reference for each prediction. Each reference should be a list of reference labels*
|
64 |
|
|
|
65 |
### Output Values
|
66 |
|
67 |
This metric outputs a dictionary, containing:
|
@@ -70,6 +71,17 @@ This metric outputs a dictionary, containing:
|
|
70 |
- accuracy
|
71 |
- fscore
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
## Citation
|
74 |
|
75 |
```bibtex
|
|
|
62 |
- **predictions** *(list[Union[int,str]]): list of predictions to score. Each predictions should be a list of predicted labels*
|
63 |
- **references** *(list[Union[int,str]]): list of reference for each prediction. Each reference should be a list of reference labels*
|
64 |
|
65 |
+
|
66 |
### Output Values
|
67 |
|
68 |
This metric outputs a dictionary, containing:
|
|
|
71 |
- accuracy
|
72 |
- fscore
|
73 |
|
74 |
+
|
75 |
+
Ff prediction and reference are empty lists, the output will be:
|
76 |
+
```python
|
77 |
+
{
|
78 |
+
"precision": 1.0,
|
79 |
+
"recall": 1.0,
|
80 |
+
"accuracy": 1.0,
|
81 |
+
"fscore": 1.0
|
82 |
+
}
|
83 |
+
```
|
84 |
+
|
85 |
## Citation
|
86 |
|
87 |
```bibtex
|
multi_label_precision_recall_accuracy_fscore.py
CHANGED
@@ -104,6 +104,9 @@ class MultiLabelPrecisionRecallAccuracyFscore(evaluate.Metric):
|
|
104 |
)
|
105 |
|
106 |
def eval_example(self, prediction, reference):
|
|
|
|
|
|
|
107 |
if self.use_multiset:
|
108 |
prediction = Counter(prediction)
|
109 |
reference = Counter(reference)
|
|
|
104 |
)
|
105 |
|
106 |
def eval_example(self, prediction, reference):
|
107 |
+
if len(prediction) == 0 and len(reference) == 0:
|
108 |
+
return 1, 1, 1
|
109 |
+
|
110 |
if self.use_multiset:
|
111 |
prediction = Counter(prediction)
|
112 |
reference = Counter(reference)
|
tests.py
CHANGED
@@ -58,10 +58,10 @@ class MultiLabelPrecisionRecallAccuracyFscoreTest(TestCase):
|
|
58 |
def test_empty(self):
|
59 |
self.assertDictEqual(
|
60 |
{
|
61 |
-
"precision":
|
62 |
-
"recall":
|
63 |
-
"accuracy":
|
64 |
-
"fscore":
|
65 |
},
|
66 |
self.multi_label_precision_recall_accuracy_fscore.compute(
|
67 |
predictions=[
|
|
|
58 |
def test_empty(self):
|
59 |
self.assertDictEqual(
|
60 |
{
|
61 |
+
"precision": 1.0,
|
62 |
+
"recall": 1.0,
|
63 |
+
"accuracy": 1.0,
|
64 |
+
"fscore": 1.0
|
65 |
},
|
66 |
self.multi_label_precision_recall_accuracy_fscore.compute(
|
67 |
predictions=[
|