forked from catalyst-team/catalyst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mrr.py
40 lines (33 loc) · 1.12 KB
/
mrr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from typing import List
from catalyst.core import MetricCallback
from catalyst.utils import metrics
class MRRCallback(MetricCallback):
"""Calculates the AUC per class for each loader.
.. note::
Currently, supports binary and multi-label cases.
"""
def __init__(
self,
input_key: str = "targets",
output_key: str = "logits",
prefix: str = "mrr",
activation: str = "none",
):
"""
Args:
input_key (str): input key to use for auc calculation
specifies our ``y_true``
output_key (str): output key to use for auc calculation;
specifies our ``y_pred``
prefix (str): name to display for mrr when printing
activation (str): An torch.nn activation applied to the outputs.
Must be one of ``'none'``, ``'Sigmoid'``, or ``'Softmax2d'``
"""
super().__init__(
prefix=prefix,
metric_fn=metrics.mrr,
input_key=input_key,
output_key=output_key,
activation=activation,
)
__all__ = ["MRRCallback"]