Skip to content
DeepForgeby svx
All problems
EasyML Fundamentalsml-225

Mean Reciprocal Rank

Problem

Compute mean reciprocal rank over users: for each ranked binary list add 1 / rank of the first relevant item (0 if none), then average.

Empty input returns 0.0.

Hint

MRR only cares about where the first relevant item appears.

Test cases

case 1
in: [[[0,1,0],[1,0]]]
expected: 0.75
case 2
in: [[[0,0],[1]]]
expected: 0.5
case 3
in: [[[0,0],[0,0]]]
expected: 0
case 4
in: [[]]
expected: 0
Starter codePython
def mean_reciprocal_rank(ranked_relevance):
    # Your code here
    pass

4 test cases · run your code against them in the editor