Skip to content

Add MRR (Mean Reciprocal Rank) metric to rec_sys#3572

Closed
suportly wants to merge 1 commit intopytorch:masterfrom
suportly:feat/mrr-metric
Closed

Add MRR (Mean Reciprocal Rank) metric to rec_sys#3572
suportly wants to merge 1 commit intopytorch:masterfrom
suportly:feat/mrr-metric

Conversation

@suportly
Copy link
Copy Markdown

Summary

  • Add MRR (Mean Reciprocal Rank) metric to ignite/metrics/rec_sys/
  • MRR measures the average of 1/rank of the first relevant item across all queries
  • Follows the exact same pattern as HitRate — supports multiple top_k values, ignore_zero_hits, distributed computation via @sync_all_reduce
  • Comprehensive test suite including edge cases, parametrized tests, and distributed tests

Refs #3569

New Files

  • ignite/metrics/rec_sys/mrr.py — MRR metric class
  • tests/ignite/metrics/rec_sys/test_mrr_metric.py — 23 tests (all passing)

Modified Files

  • ignite/metrics/rec_sys/__init__.py — export MRR
  • ignite/metrics/__init__.py — export MRR at top level

Test plan

  • All 23 MRR tests pass (CPU, CUDA, distributed nccl/gloo)
  • All 19 existing HitRate tests still pass
  • from ignite.metrics import MRR works correctly
  • Manual verification with known values (MRR@1=0, MRR@2=0.5 for rank-2 hit)

🤖 Generated with Claude Code

Add Mean Reciprocal Rank metric for evaluating retrieval and
recommendation systems. MRR measures the average of 1/rank of the
first relevant item, supporting multiple top-k values and distributed
computation, following the same pattern as HitRate.

Refs pytorch#3569

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vfdev-5
Copy link
Copy Markdown
Collaborator

vfdev-5 commented Mar 10, 2026

Duplicate of #3573

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: metrics Metrics module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants