All problems
Hit Rate at K
Problem
Hit rate at k is one when at least one relevant document appears in the top k and zero otherwise.
Given the ranked ids, the relevant set, and k, return the hit rate as a boolean.
Hint
Only the first k documents are inspected.
Test cases
case 1
in: [["a","b"],["b"],2]
expected: true
case 2
in: [["x"],["y"],1]
expected: false
case 3
in: [["a"],["a"],0]
expected: false
Starter codePython
def hit_rate_at_k(retrieved, relevant, k):
# Your code here
pass3 test cases · run your code against them in the editor