Math · Machine learning · Ranking metrics

Precision at k calculator.

Score a ranked list from a search engine, recommender or retrieval model. Mark each result 1 if relevant or 0 if not, in rank order, and choose k.

For the ranked list 1 0 1 0 0 1 0 1 0 0 with 5 relevant items in total, precision@5 is 0.40 (2 of the top 5), recall@5 is 0.40 and average precision is 0.5333.

P@k = relevant in top k / k · AP = (1/R) Σ P@rank of each relevant resultOpened sources 15 October 2026

Advertisement

Inputs

Separate with spaces or commas. Rank 1 is the first value.
Include relevant items the system never returned.

Your result

Fill the form and press Calculate.

Definitions

Manning, Raghavan and Schütze describe measuring precision at fixed low levels of retrieved results, such as 10 or 30 documents, called "precision at k" (for example precision at 10). It is the share of the top k results that are relevant: P@k = (relevant in top k) / k. Recall@k = (relevant in top k) / (total relevant) uses the usual definition of recall. R-precision is the precision of the top |Rel| documents returned, where Rel is the set of known relevant documents. Average precision averages the precision values obtained after each relevant document is retrieved; a relevant document that is never retrieved counts as precision 0. MAP is the mean of average precision across queries.

Worked example

List 1 0 1 0 0 1 0 1 0 0 with 5 relevant in total (4 appear in the list). Top 5 holds 2 relevant, so P@5 = 2/5 = 0.40 and recall@5 = 2/5 = 0.40. Precision after each relevant hit: rank 1 = 1/1, rank 3 = 2/3, rank 6 = 3/6, rank 8 = 4/8. Their sum is 2.6667, divided by the 5 relevant items (one never retrieved, adding 0): AP = 0.5333. R-precision looks at the top 5, so it is also 0.40.

Limits

Precision at k ignores order within the top k, so swapping rank 1 and rank 5 changes nothing. It also depends on k, and a query with fewer than k relevant items can never reach 1.0. Average precision rewards putting relevant items early. This page needs the list to be at least k long; it does not compute graded-relevance measures such as nDCG.

Sources, opened 15 October 2026: Manning, Raghavan and Schütze, Introduction to Information Retrieval, Evaluation of ranked retrieval results.

Frequently asked questions

What is precision at k?

The fraction of the top k ranked results that are relevant. If 2 of the top 5 results are relevant, precision@5 is 0.4.

What is the difference between precision@k and recall@k?

Precision@k divides the relevant results in the top k by k. Recall@k divides them by the total number of relevant items that exist, so it needs that total.

How is average precision calculated?

Take the precision at the rank of each relevant result, sum those values and divide by the total number of relevant items. Relevant items never returned contribute 0. MAP is the mean over many queries.

What k should I use?

Use the number of results a user realistically sees, such as the first page of 10. Report several values of k if you are unsure.

Why must k be no larger than my list?

Beyond the end of the list the ranks are unknown, so the precision would be a guess. Add the missing results (as 0 if not relevant) or lower k.

Learning and planning aid

Results are computed in your browser from the numbers you enter and the formulas described above. Check them against your own evaluation code before relying on them in a paper or a production decision.

Advertisement
Advertisement