Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecSys callbacks notes #1339

Merged
merged 2 commits into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions catalyst/callbacks/metrics/accuracy.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ class AccuracyCallback(BatchMetricCallback):
Args:
input_key: input key to use for metric calculation, specifies our `y_pred`
target_key: output key to use for metric calculation, specifies our `y_true`
topk_args: specifies which accuracy@K to log:
[1] - accuracy
[1, 3] - accuracy at 1 and 3
[1, 3, 5] - accuracy at 1, 3 and 5
topk_args: specifies which accuracy@K to log
num_classes: number of classes to calculate ``topk_args`` if ``accuracy_args`` is None
log_on_batch: boolean flag to log computed metrics every batch
prefix: metric prefix
Expand Down Expand Up @@ -73,6 +70,18 @@ class AccuracyCallback(BatchMetricCallback):
],
)

.. note::
Metric names depending on input parameters:

- ``topk_args = None`` ---> see \
:py:mod:`catalyst.metrics.functional._misc.get_default_topk_args`
- ``topk_args = (1,)`` ---> ``"accuracy01"``
- ``topk_args = (1, 3)`` ---> ``"accuracy01"``, ``"accuracy03"``
- ``topk_args = (1, 3, 5)`` ---> ``"accuracy01"``, ``"accuracy03"``, ``"accuracy05"``

You can find them in ``runner.batch_metrics``, ``runner.loader_metrics`` or
``runner.epoch_metrics``.

.. note::
Please follow the `minimal examples`_ sections for more use cases.

Expand Down
15 changes: 11 additions & 4 deletions catalyst/callbacks/metrics/cmc_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ class CMCScoreCallback(LoaderMetricCallback):
embeddings_key: embeddings key in output dict
labels_key: labels key in output dict
is_query_key: bool key True if current object is from query
topk_args: specifies which cmc@K to log.
[1] - cmc@1
[1, 3] - cmc@1 and cmc@3
[1, 3, 5] - cmc@1, cmc@3 and cmc@5
topk_args: specifies which cmc@K to log
prefix: metric prefix
suffix: metric suffix

Expand Down Expand Up @@ -123,6 +120,16 @@ def handle_batch(self, batch) -> None:
num_epochs=10,
)

.. note::
Metric names depending on input parameters:

- ``topk_args = (1,) or None`` ---> ``"cmc01"``
- ``topk_args = (1, 3)`` ---> ``"cmc01"``, ``"cmc03"``
- ``topk_args = (1, 3, 5)`` ---> ``"cmc01"``, ``"cmc03"``, ``"cmc05"``

You can find them in ``runner.batch_metrics``, ``runner.loader_metrics`` or
``runner.epoch_metrics``.

.. note::
Please follow the `minimal examples`_ sections for more use cases.

Expand Down
60 changes: 44 additions & 16 deletions catalyst/callbacks/metrics/recsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ class HitrateCallback(BatchMetricCallback):
Args:
input_key: input key to use for metric calculation, specifies our `y_pred`
target_key: output key to use for metric calculation, specifies our `y_true`
topk_args: specifies which HR@K to log:
[1] - HR
[1, 3] - HR at 1 and 3
[1, 3, 5] - HR at 1, 3 and 5
topk_args: specifies which HR@K to log
log_on_batch: boolean flag to log computed metrics every batch
prefix: metric prefix
suffix: metric suffix
Expand Down Expand Up @@ -83,6 +80,16 @@ class HitrateCallback(BatchMetricCallback):
]
)

.. note::
Metric names depending on input parameters:

- ``topk_args = (1,) or None`` ---> ``"hitrate01"``
- ``topk_args = (1, 3)`` ---> ``"hitrate01"``, ``"hitrate03"``
- ``topk_args = (1, 3, 5)`` ---> ``"hitrate01"``, ``"hitrate03"``, ``"hitrate05"``

You can find them in ``runner.batch_metrics``, ``runner.loader_metrics`` or
``runner.epoch_metrics``.

.. note::
Please follow the `minimal examples`_ sections for more use cases.

Expand Down Expand Up @@ -115,10 +122,7 @@ class MAPCallback(BatchMetricCallback):
input_key: input key to use for metric calculation, specifies our `y_pred`
target_key: output key to use for metric calculation, specifies our `y_true`
prefix: key for the metric's name
topk_args: specifies which MAP@K to log:
[1] - MAP
[1, 3] - MAP at 1 and 3
[1, 3, 5] - MAP at 1, 3 and 5
topk_args: specifies which MAP@K to log
log_on_batch: boolean flag to log computed metrics every batch
prefix: metric prefix
suffix: metric suffix
Expand Down Expand Up @@ -184,6 +188,16 @@ class MAPCallback(BatchMetricCallback):
]
)

.. note::
Metric names depending on input parameters:

- ``topk_args = (1,) or None`` ---> ``"map01"``
- ``topk_args = (1, 3)`` ---> ``"map01"``, ``"map03"``
- ``topk_args = (1, 3, 5)`` ---> ``"map01"``, ``"map03"``, ``"map05"``

You can find them in ``runner.batch_metrics``, ``runner.loader_metrics`` or
``runner.epoch_metrics``.

.. note::
Please follow the `minimal examples`_ sections for more use cases.

Expand Down Expand Up @@ -216,10 +230,7 @@ class MRRCallback(BatchMetricCallback):
input_key: input key to use for metric calculation, specifies our `y_pred`
target_key: output key to use for metric calculation, specifies our `y_true`
prefix: key for the metric's name
topk_args: specifies which MRR@K to log:
[1] - MRR
[1, 3] - MRR at 1 and 3
[1, 3, 5] - MRR at 1, 3 and 5
topk_args: specifies which MRR@K to log
log_on_batch: boolean flag to log computed metrics every batch
prefix: metric prefix
suffix: metric suffix
Expand Down Expand Up @@ -285,6 +296,16 @@ class MRRCallback(BatchMetricCallback):
]
)

.. note::
Metric names depending on input parameters:

- ``topk_args = (1,) or None`` ---> ``"mrr01"``
- ``topk_args = (1, 3)`` ---> ``"mrr01"``, ``"mrr03"``
- ``topk_args = (1, 3, 5)`` ---> ``"mrr01"``, ``"mrr03"``, ``"mrr05"``

You can find them in ``runner.batch_metrics``, ``runner.loader_metrics`` or
``runner.epoch_metrics``.

.. note::
Please follow the `minimal examples`_ sections for more use cases.

Expand Down Expand Up @@ -317,10 +338,7 @@ class NDCGCallback(BatchMetricCallback):
input_key: input key to use for metric calculation, specifies our `y_pred`
target_key: output key to use for metric calculation, specifies our `y_true`
prefix: key for the metric's name
topk_args: specifies which NDCG@K to log:
[1] - NDCG
[1, 3] - NDCG at 1 and 3
[1, 3, 5] - NDCG at 1, 3 and 5
topk_args: specifies which NDCG@K to log
log_on_batch: boolean flag to log computed metrics every batch
prefix: metric prefix
suffix: metric suffix
Expand Down Expand Up @@ -386,6 +404,16 @@ class NDCGCallback(BatchMetricCallback):
]
)

.. note::
Metric names depending on input parameters:

- ``topk_args = (1,) or None`` ---> ``"ndcg01"``
- ``topk_args = (1, 3)`` ---> ``"ndcg01"``, ``"ndcg03"``
- ``topk_args = (1, 3, 5)`` ---> ``"ndcg01"``, ``"ndcg03"``, ``"ndcg05"``

You can find them in ``runner.batch_metrics``, ``runner.loader_metrics`` or
``runner.epoch_metrics``.

.. note::
Please follow the `minimal examples`_ sections for more use cases.

Expand Down