← Lessons

quiz vs the machine

Platinum1760

Machine Learning

NDCG for Ranking

Rewarding graded relevance placed high in a ranked list.

6 min read · advanced · beat Platinum to climb

Beyond relevant or not

NDCG scores rankings when relevance comes in grades, not just yes or no. A search result might be perfect, useful, or irrelevant, and NDCG honors those levels rather than collapsing them to a binary.

How it is built

It starts from discounted cumulative gain. Each result contributes its relevance grade divided by a discount that grows with its position, so an item ranked first counts fully while an item ranked tenth is heavily discounted. This captures that users look at the top first.

  • Gain is the relevance grade, often grown exponentially so top grades dominate.
  • Discount shrinks the contribution of lower positions, usually by a logarithm of the rank.

Normalizing

Raw DCG depends on how many relevant items exist, so it is hard to compare across queries. NDCG divides DCG by the ideal DCG, the score of the best possible ordering. The result lands between zero and one, where one means the ranking matches the ideal order.

This normalization lets you average NDCG fairly across queries with different amounts of relevant content.

Key idea

NDCG rewards placing highly relevant items near the top using a position discount, then normalizes by the ideal ordering so scores compare fairly across queries.

Check yourself

Answer to earn rating on the learn ladder.

1. What does the discount in DCG capture?

2. Why normalize DCG into NDCG?