16/31
Part 4 of 6 · Yes-or-no metricsLearn and do
Pick the metric by the stage
With five metrics in hand, the interviewer will ask which one you'd use.
| Metric | Use it when |
|---|---|
| Recall@k | you're judging retrieval: did the good items survive the cut? |
| Precision@k | there's a fixed number of slots and each counts the same |
| MRR | there's one right answer: a known item, a navigational query, the listing they booked |
| MAP | labels are yes or no, several items are relevant, and the whole order matters |
| NDCG@k | labels are graded and the top matters most |
With one booked listing, NDCG and MRR differ only in the discount
Say the only relevant item is the listing that got booked. Both metrics then depend only on its rank:
for r in [1, 2, 3, 5, 10]:
booked = [0] * (r - 1) + [1]
print(r, round(reciprocal_rank(booked), 2), round(ndcg_at_k(booked, 10), 2))
One booked listing, at rank 5. What are its reciprocal rank and NDCG@10?
Pick one to see what it prints.
Pick an answer above to see the rest