Skip to content
DeepForgeby svx
All problems
MediumNLPnlp-251

Recall at Multiple Cutoffs

Problem

Compute recall at each cutoff in cutoffs. For a cutoff k, recall is the fraction of relevant ids found in the first k retrieved ids, with duplicates removed.

Return one value per cutoff, in order. A cutoff of 0 or fewer, or an empty relevant set, gives 0.0.

Hint

Cut the retrieved list, intersect with the relevant set, and divide by the relevant count.

Test cases

case 1
in: [["a","b","c","d"],["a","c"],[1,2,4]]
expected: [0.5,0.5,1]
case 2
in: [[],["a"],[2]]
expected: [0]
case 3
in: [["a"],[],[1]]
expected: [0]
case 4
in: [["a","b"],["a","b"],[0,1]]
expected: [0,0.5]
case 5
in: [["a","b","c"],["b"],[3]]
expected: [1]
Starter codePython
def recall_at_cutoffs(retrieved, relevant, cutoffs):
    # Your code here
    pass

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