Spaces:
Runtime error
Runtime error
Update Space (evaluate main: c447fc8e)
Browse files- requirements.txt +1 -1
- spearmanr.py +3 -18
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
git+https://github.com/huggingface/evaluate@
|
2 |
scipy
|
|
|
1 |
+
git+https://github.com/huggingface/evaluate@c447fc8eda9c62af501bfdc6988919571050d950
|
2 |
scipy
|
spearmanr.py
CHANGED
@@ -13,8 +13,6 @@
|
|
13 |
# limitations under the License.
|
14 |
"""Spearman correlation coefficient metric."""
|
15 |
|
16 |
-
from dataclasses import dataclass
|
17 |
-
|
18 |
import datasets
|
19 |
from scipy.stats import spearmanr
|
20 |
|
@@ -98,26 +96,13 @@ _CITATION = r"""\
|
|
98 |
"""
|
99 |
|
100 |
|
101 |
-
@dataclass
|
102 |
-
class SpearmanrConfig(evaluate.info.Config):
|
103 |
-
|
104 |
-
name: str = "default"
|
105 |
-
|
106 |
-
return_pvalue: bool = False
|
107 |
-
|
108 |
-
|
109 |
@evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
|
110 |
class Spearmanr(evaluate.Metric):
|
111 |
-
|
112 |
-
CONFIG_CLASS = SpearmanrConfig
|
113 |
-
ALLOWED_CONFIG_NAMES = ["default"]
|
114 |
-
|
115 |
-
def _info(self, config):
|
116 |
return evaluate.MetricInfo(
|
117 |
description=_DESCRIPTION,
|
118 |
citation=_CITATION,
|
119 |
inputs_description=_KWARGS_DESCRIPTION,
|
120 |
-
config=config,
|
121 |
features=datasets.Features(
|
122 |
{
|
123 |
"predictions": datasets.Value("float"),
|
@@ -127,9 +112,9 @@ class Spearmanr(evaluate.Metric):
|
|
127 |
reference_urls=["https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.spearmanr.html"],
|
128 |
)
|
129 |
|
130 |
-
def _compute(self, predictions, references):
|
131 |
results = spearmanr(references, predictions)
|
132 |
-
if
|
133 |
return {"spearmanr": results[0], "spearmanr_pvalue": results[1]}
|
134 |
else:
|
135 |
return {"spearmanr": results[0]}
|
|
|
13 |
# limitations under the License.
|
14 |
"""Spearman correlation coefficient metric."""
|
15 |
|
|
|
|
|
16 |
import datasets
|
17 |
from scipy.stats import spearmanr
|
18 |
|
|
|
96 |
"""
|
97 |
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
@evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
|
100 |
class Spearmanr(evaluate.Metric):
|
101 |
+
def _info(self):
|
|
|
|
|
|
|
|
|
102 |
return evaluate.MetricInfo(
|
103 |
description=_DESCRIPTION,
|
104 |
citation=_CITATION,
|
105 |
inputs_description=_KWARGS_DESCRIPTION,
|
|
|
106 |
features=datasets.Features(
|
107 |
{
|
108 |
"predictions": datasets.Value("float"),
|
|
|
112 |
reference_urls=["https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.spearmanr.html"],
|
113 |
)
|
114 |
|
115 |
+
def _compute(self, predictions, references, return_pvalue=False):
|
116 |
results = spearmanr(references, predictions)
|
117 |
+
if return_pvalue:
|
118 |
return {"spearmanr": results[0], "spearmanr_pvalue": results[1]}
|
119 |
else:
|
120 |
return {"spearmanr": results[0]}
|