Skip to content
Quantoros

What is precision and recall at k?

Classic MLLevel: IntermediateRanking and search

What is precision and recall at k?

Hints
  • Write TP, FP, TN and FN for a small example.
  • Separate ranking quality, threshold selection and probability calibration. Which error costs more?

Answer

Precision at k and recall at k are evaluation metrics for ranking algorithms. Precision at k shows the share of relevant items in the first k results of the ranking algorithm. And Recall at k indicates the share of relevant items returned in top k results out of all correct answers for a given query.

Example: For a search query "Car" there are 3 relevant products in your shop. Your search algorithm returns 2 of those relevant products in the first 5 search results. Precision at 5 = # num of relevant products in search result / k = 2/5 = 40% Recall at 5 = # num of relevant products in search result / # num of all relevant products = 2/3 = 66.6%

Source and licence: Alexey Grigorev & contributors — Data Science Interviews · CC-BY-4.0

Related questions