| 78 | |
| 79 | @datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION) |
| 80 | class Accuracy(datasets.Metric): |
| 81 | def _info(self): |
| 82 | return datasets.MetricInfo( |
| 83 | description=_DESCRIPTION, |
| 84 | citation=_CITATION, |
| 85 | inputs_description=_KWARGS_DESCRIPTION, |
| 86 | features=datasets.Features( |
| 87 | { |
| 88 | "predictions": datasets.Sequence(datasets.Value("int32")), |
| 89 | "references": datasets.Sequence(datasets.Value("int32")), |
| 90 | } |
| 91 | if self.config_name == "multilabel" |
| 92 | else { |
| 93 | "predictions": datasets.Value("int32"), |
| 94 | "references": datasets.Value("int32"), |
| 95 | } |
| 96 | ), |
| 97 | reference_urls=["https://scikit-learn.org/stable/modules/generated/sklearn.metrics.accuracy_score.html"], |
| 98 | ) |
| 99 | |
| 100 | def _compute(self, predictions, references, normalize=True, sample_weight=None): |
| 101 | return { |
| 102 | "accuracy": float( |
| 103 | accuracy_score(references, predictions, normalize=normalize, sample_weight=sample_weight) |
| 104 | ) |
| 105 | } |
nothing calls this directly
no outgoing calls
no test coverage detected