Recall@K, Precision@K, MRR, and nDCG

Recall@K measures relevant evidence found within the top K; Precision@K measures the share of top K that is relevant; MRR rewards early placement of the first relevant result; nDCG supports graded relevance and ranking quality. No single metric is enough. Use different metrics for coverage and noise, and inspect examples manually.

Implementation example
function recallAtK(ids,relevant,k) {
 const set=new Set(relevant);
 if(!set.size) return null;
 return ids.slice(0,k).filter(id=>set.has(id)).length/set.size;
}
💡 This simple implementation assumes IDs and relevance labels are correct.
Key Takeaways
  • Inspect the relevant pipeline stage instead of guessing.
  • Preserve source provenance, versions, and access scope.
  • Measure quality on representative queries.
Knowledge Check

Which metric asks whether relevant items appear within top K?