Hit rate at K, written HR@K and sometimes called the hit ratio, is an offline evaluation metric in recommender systems that measures the fraction of users or test cases for which at least one relevant item appears in the top K recommendations. A result counts as a hit when the held-out item the user actually interacted with is ranked within the first K positions; otherwise it counts as a miss.
The metric is popular because it is simple to compute and easy to explain: an HR@10 of 0.42 means that for 42 percent of test users, the model placed a correct item in its top ten. It is a standard yardstick in research on collaborative filtering, sequential recommendation and neural ranking models, usually reported alongside position-aware metrics such as NDCG.
How hit rate at K is calculated
The calculation is a binary check per test case, averaged over all cases. For each user, the model produces a ranked list; the indicator is 1 if any relevant held-out item appears in the first K positions and 0 otherwise. The formula is HR@K = (number of users with a hit in top K) / (total number of test users), giving a value between 0 and 1.
HR@K is most often used with leave-one-out evaluation, in which the last interaction of each user is held out as the single test item and the rest of the history is used for training. With exactly one relevant item per user, HR@K equals recall at K, because finding that item is the same as recalling all relevant items.
The steps below show how a typical evaluation pipeline produces the score.
| Step | Action | Output |
|---|---|---|
| Split | Hold out the latest interaction per user | Training history and one test item |
| Score | Rank candidate items for each user | Ordered recommendation list |
| Cut off | Keep only the first K items | Top-K list |
| Check | Test whether the held-out item is in the list | Hit (1) or miss (0) |
| Average | Divide hits by number of users | HR@K between 0 and 1 |
Key parameters that change the score
The value of HR@K depends heavily on evaluation choices, so two papers reporting the same metric are often not comparable. The most influential settings are the cutoff K, the candidate set and the treatment of items the user has already seen.
| Setting | Typical values | Effect on HR@K |
|---|---|---|
| Cutoff K | 5, 10, 20, 50 | Higher K always gives an equal or higher score |
| Candidate set | Full catalog or 100 sampled items | Sampled sets inflate scores sharply |
| Negative sampling | Random or popularity-based | Popularity sampling makes the task harder |
| Seen-item filtering | Exclude or keep training items | Excluding them raises the score |
| Test split | Leave-one-out or time-based | Time-based splits are more realistic |
A widely used protocol, popularized by neural collaborative filtering research, ranks the held-out item against 100 randomly sampled negative items instead of the full catalog. Later analysis showed that such sampled metrics can reverse model rankings, because they reward getting the item roughly near the top rather than at the top of the full catalog. Current best practice favors full-catalog ranking or statistically corrected sampled metrics.
Hit rate compared with other ranking metrics
Hit rate at K answers a single question, whether a relevant item appears at all, and ignores its exact position within the top K. Other metrics add position sensitivity or handle multiple relevant items, which is why HR@K is rarely reported alone.
| Metric | What it measures | Position-aware | Best suited to |
|---|---|---|---|
| Hit rate at K | At least one relevant item in top K | No | Leave-one-out, quick comparisons |
| Recall at K | Share of relevant items found in top K | No | Users with several relevant items |
| Precision at K | Share of top-K items that are relevant | No | Fixed-size result pages |
| MRR | Inverse rank of the first relevant item | Yes | Single correct answer tasks |
| NDCG at K | Discounted gain by rank position | Yes | Graded relevance and ranking quality |
In practice, HR@K and NDCG@K are usually reported together: hit rate shows coverage of correct answers, while NDCG shows how high those answers are ranked. A model with a high hit rate but a low NDCG tends to place relevant items near the bottom of the list, where users are less likely to notice them because of position bias.
Using hit rate at K in practice
Hit rate is most useful for candidate generation in multi-stage ranking, where the question is whether the retrieval stage passes the right item to the ranker at all. A retrieval model with HR@500 of 0.9, for example, loses about one in ten relevant items before the ranking stage ever sees them.
- Choose K to match the real interface, such as the number of slots in a carousel or the candidate budget of a retrieval stage.
- Report HR@K at several cutoffs to show how quickly the curve rises.
- Compare models only under the same split, candidate set and filtering rules.
- Pair the metric with beyond-accuracy metrics such as coverage, diversity and novelty.
Offline hit rate is a proxy for online success, not a substitute for it. Gains of a few hundredths in HR@10 often fail to appear in online A/B tests, because offline logs reflect what the previous system chose to show, a form of exposure bias.
Limitations and common mistakes
The binary nature of the metric hides important differences, and several evaluation mistakes routinely inflate reported results. The table lists the most frequent ones.
| Mistake | Consequence | Fix |
|---|---|---|
| Sampled candidates only | Overstated scores, unstable rankings | Rank against the full catalog |
| Random rather than temporal split | Information leaks from the future | Hold out the latest interactions |
| Ignoring popularity | A popularity baseline scores surprisingly well | Always report a popularity baseline |
| Single cutoff | Hides ranking quality | Report several K values and NDCG |
Hit rate also favors popular items, because popular items are more likely to be the held-out interaction. A model can raise HR@K simply by recommending bestsellers, which may worsen popularity bias and reduce recommendation diversity.
The idea in brief
Hit rate at K asks a simple question. Did the recommender show at least one thing the person really wanted among its first K suggestions? If yes, that is a hit. If no, it is a miss.
Imagine a friend who suggests ten movies. Later you watch one of them. That counts as a hit. Hit rate is the share of people who got a hit. It does not care whether the good movie was first or tenth on the list.
A practical scenario
A data science team at an online bookstore evaluates a new sequential recommendation model before an A/B test. They hold out the last purchase of 200,000 customers and ask both the current model and the new one to rank the full catalog of about 1.5 million titles.
The current model reaches an HR@10 of 0.081, and the new model reaches 0.097. When the team repeats the test with the older protocol of 100 sampled negatives, both models score above 0.6 and the difference almost disappears, which confirms that full-catalog evaluation is needed to see the gain.
The team also checks NDCG@10, which improves by a similar margin, and a popularity baseline, which scores 0.052. Satisfied that the improvement is real, they launch a two-week A/B test, where the new model raises clicks on the recommendation shelf by a modest but statistically significant amount.