Companion to Precision@K. Measures what fraction of ALL relevant documents appear in the top-K results.
Recall@K = |relevant ∩ retrieved[:K]| / |relevant|relevant = [1, 2, 3] retrieved = [1, 4, 2, 5, 6] K = 3 → top-3 = [1, 4, 2] → 2 relevant in top-3 out of 3 total → 2/3 = 0.66667
Round to **5 decimal places**.
Similar Problems
Test Cases (2 visible · 2 hidden)
Case 1: 2/3 found in top-3
Input: recall_at_k([1,2,3],[1,4,2,5,6],3)
Expected: 0.66667
Case 2: All found in top-2
Input: recall_at_k([1,2],[1,2,3,4,5],2)
Expected: 1.0
⌘↵ Run · ⌘⇧↵ Submit