Beginner
Recall at k, and its average
Write recall_at_k(found, truth, k): look only at the first k ids of each list, and return the fraction of truth[:k] that also appears in found[:k]. Order does not matter. If truth[:k] is empty, return 1.0 (there was nothing to find).
Write average_recall(runs, k) where runs is a list of (found, truth) pairs. Return the average recall@k, or 0.0 for an empty list.
What Check tests
- Two of four neighbours found gives 0.5
- Order does not matter
- Only the first k ids count
- Nothing found gives 0
- Nothing to find gives 1
- The average is over queries
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.