precision at k
**Precision@K** measures **fraction of top-K results that are relevant** — evaluating what percentage of the first K results are actually useful, a simple and intuitive ranking metric.
**What Is Precision@K?**
- **Definition**: Percentage of top-K results that are relevant.
- **Formula**: P@K = (# relevant in top-K) / K.
- **Range**: 0 (no relevant results) to 1 (all top-K relevant).
**Example**
Top 10 results: 7 relevant, 3 not relevant.
- Precision@10 = 7/10 = 0.7 (70% precision).
**Why Precision@K?**
- **User-Centric**: Users typically view only top-K results.
- **Simple**: Easy to understand and explain.
- **Practical**: Reflects real user experience.
- **Actionable**: Clear target for improvement.
**Common K Values**
- **P@1**: Is top result relevant? (most critical).
- **P@5**: Are top 5 results relevant?
- **P@10**: Are top 10 results relevant? (common for search).
- **P@20**: For longer result lists.
**Limitations**
- **Ignores Position**: Treats all top-K positions equally.
- **Ignores Recall**: Doesn't consider relevant results beyond K.
- **Binary**: Doesn't handle graded relevance.
- **K-Dependent**: Different K values give different scores.
**Precision@K vs. Other Metrics**
**vs. Recall@K**: Precision = relevant retrieved / retrieved, Recall = relevant retrieved / total relevant.
**vs. NDCG**: Precision@K binary, NDCG handles graded relevance and position.
**vs. MAP**: Precision@K single cutoff, MAP averages precision at all relevant positions.
**Applications**: Search evaluation, recommendation evaluation, information retrieval, any ranked list evaluation.
**Tools**: scikit-learn, IR evaluation libraries, easy to implement.
Precision@K is **the most intuitive ranking metric** — by measuring what fraction of top results are relevant, it directly captures user experience and is easy to understand and communicate.