Getting Started

What is MRR in Machine Learning?

What is Mean Reciprocal Rank (MRR)?

Mean Reciprocal Rank (MRR) is a metric that measures the effectiveness of a ranking system by focusing on the position of the first relevant result in the ranked list returned by the model. It provides insight into how efficiently a system retrieves the top relevant item for a query, which is especially useful in applications like search engines, recommendation systems, and question-answering systems.

To calculate MRR, you first need to compute the reciprocal rank for each query. This is defined as:

$$ \text{Reciprocal Rank} = \frac{1}{\text{rank of the first relevant result}} $$

The MRR is the average of the reciprocal ranks across all queries:

$$ \text{MRR} = \frac{1}{|Q|} \sum^{|Q|}_{i=1} \frac{1}{\text{rank}}_i $$

where \(Q\) is the total number of queries and \(rank_i\) is the rank position of the first relevant result for the \(i\)-th query.

Example Mean Reciprocal Rank (MRR) Calculation

Let’s say we have three queries with the following first relevant result ranks:

  1. For query 1, the first relevant item is in position 2, so the Reciprocal Rank is \(1/2 = 0.5\)
  2. For query 2, the first relevant item is in position 1, so the Reciprocal Rank is \(1/1 = 1\)
  3. For query 3, the first relevant item is in position 4 so the Reciprocal Rank is \(1/4 = 0.25\)

Now, the MRR is the mean of these reciprocal ranks:

$$ \text{MRR} = \frac{1}{3}\big( 0.5 + 1 + 0.25\big) = 0.583 $$

In this example, an MRR of \(0.583\) suggests that, on average, the first relevant item appears around the second position.

What is MRR@10?

When working with MRR, you might see it specified with an “@” symbol followed by a number, like MRR@10 or MRR@100. These denote the cutoff point for evaluating how quickly the first relevant result appears within the result list. For example:

  • MRR@10 considers only the top 10 results when calculating the reciprocal rank. This is especially useful for scenarios like search engines, ecommerce, and recommendation engines, where it’s crucial to surface relevant items early.
  • MRR@100 expands the evaluation to the top 100 results. This can be advantageous in extensive catalog searches or complex retrieval tasks where relevance might be found deeper in the list.

These metrics provide insight into how quickly a system presents relevant results to users within specified sections of the results list.

Why Use MRR?

MRR is particularly useful for systems where users are likely to care more about the first relevant result rather than later results. Such scenarios include:

  1. Search Engines: When users enter a query, they generally expect the most relevant result to appear at the top. MRR helps determine if the search engine can consistently display relevant content as the first result.
  2. Recommendation Systems: For a recommendation system, the effectiveness of the first item displayed in response to a user's interests or needs can make a big impact on user satisfaction.
  3. Question-Answering Systems: In these systems, accuracy in returning the correct answer as the first result is often the goal. MRR enables developers to evaluate how frequently the system ranks the correct answer at the top.

Conclusion

MRR is a powerful, easy-to-understand metric that provides insight into a model’s ability to rank the first relevant item at the top. While it has limitations, its simplicity makes it an excellent starting point for evaluating search and recommendation systems where the relevance of the first result is crucial. By focusing on MRR, you can better understand your model’s strengths and identify areas for improvement, ultimately leading to better user satisfaction in your applications.

Ellie Sleightholm
Head of Developer Relations at Marqo