Definitioncore
Normalized discounted cumulative gain
Also called nDCG, discounted cumulative gain, DCG.
Sums graded relevance gains discounted by the log of the rank, and divides by the same sum for the ideal ordering.
Discounted cumulative gain (DCG) scores a ranking with graded judgments. Each document adds a gain that grows with its grade, divided by a discount that grows with its rank, so a highly relevant document near the top adds the most. Normalized DCG (nDCG) divides DCG by the DCG of the best possible ranking for the query, so the value lies between 0 and 1 and can be averaged over queries. Two gain functions are in common use, and they can order two systems in opposite ways.
Definition
Input. A ranking of distinct document ids for a query, with ranks starting at 1, graded judgments , where a document that is not judged has , and a cutoff . Write .
Gain. A nondecreasing function with . There are two standard choices:
- . trec_eval uses the relevance values of the judgments file as the gains (files m_ndcg.c and m_ndcg_cut.c).
- . Burges et al. (2005, equation 16) use this form. It gives the top grades much more weight: on a scale 0 to 5, grade 5 is worth 31 and grade 1 is worth 1.
The two agree when the grades are only 0 and 1. A report must say which one it uses.
Discount. Rank is divided by . Rank 1 has weight 1, rank 2 has weight , rank 3 has weight .
Normalization. Sort the grades of all judged documents of the query, retrieved or not, in decreasing order to get the ideal list , padded with zeros. The ideal DCG is , and
The ideal list must come from the judgments. If it comes from the retrieved documents only, a run that misses a highly relevant document is compared with a weaker ideal and scores too high. trec_eval builds the ideal list from the counts of all judged relevance levels.
Cutoff. is part of the name: nDCG@5, nDCG@10. With no cutoff, is the length of the run, which is the trec_eval measure ndcg. The trec_eval measure ndcg_cut uses the cutoffs 5, 10, 15, 20, 30, 100, 200, 500 and 1000 by default.
Ties. Tied scores change DCG when the tied documents have different grades. This area orders by score descending, then by document id ascending. trec_eval orders tied documents by document number in reverse lexical order.
No relevant documents. If no judged document has , then and nDCG is undefined. Return None and leave the query out of the mean. trec_eval skips the division in that case, reports 0 and counts the query in its mean.
The mean over queries is the arithmetic mean of nDCG@k over the queries where it is defined. Unnormalized DCG should not be averaged over queries, because a query with many highly relevant documents has a larger DCG for any system.
The form of Jarvelin and Kekalainen
Jarvelin and Kekalainen (2002, Section 2) define DCG with a parameter : ranks have no discount, and rank is divided by . With , ranks 1 and 2 both have weight 1, and rank 3 has weight . This is a different form from the one above, though trec_eval cites their paper for its measure. The two forms give different values on the same ranking, as the examples show.
Properties
Claim 1. whenever .
Proof. Write , which is positive and strictly decreasing in . The value is at least 0 because every term is at least 0. For the upper bound, let be the grades at the first ranks of the run, with for .
Step 1. Let be the same grades sorted in decreasing order. Then . Take any with . Swapping the two grades changes the sum by . Each such swap makes the number of out-of-order pairs smaller, so after a finite number of swaps the list is sorted, and the sum has not gone down.
Step 2. for every . The grades belong to distinct documents, so their nonzero values are some of the grades of the judged documents. The -th largest value of a part of a list is at most the -th largest value of the whole list.
Since is nondecreasing, . With Step 1, .
This is the exchange argument behind the rearrangement inequality. It uses only that the discount decreases and that does not decrease, so it holds for both gains.
Claim 2. In the form above, the base of the logarithm does not change nDCG.
Proof. For a base , . So every term of DCG and of IDCG is multiplied by the same constant , and the constant cancels in the ratio.
So equation 16 of Burges et al., which writes with no base, gives the same NDCG as base 2. In the Jarvelin and Kekalainen form the base does matter, because also decides which ranks have no discount. An example follows.
Examples and non-examples
The fixed run on the toy collection
Query q1 "sorted array search" has the judgments d1 grade 2, d2 grade 1 and d8 grade 1. The fixed run ranks 1, 6, 8, 2, 4 with the tie rule of this area, so the grades are 2, 0, 1, 1, 0. The ideal list is 2, 1, 1.
| Rank | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| Document | d1 | d6 | d8 | d2 | d4 |
| Grade | 2 | 0 | 1 | 1 | 0 |
| 1 | 0.6309 | 0.5 | 0.4307 | 0.3869 | |
| Term with | 2 | 0 | 0.5 | 0.4307 | 0 |
| Term with | 3 | 0 | 0.5 | 0.4307 | 0 |
- Gain : and , so .
- Gain : and , so .
- At , is the same as at , because the ideal list has three nonzero entries. With gain , . With gain , it is .
A run that ranks 1, 2, 8, 7, 4 puts the grades in the order 2, 1, 1, 0, 0 and has nDCG 1 at every cutoff, with both gains.
The ideal list from the wrong place
If the ideal list at is built from the first three retrieved documents only, its grades are 2, 1, 0 and its DCG is . The run then scores instead of 0.7985, because d2, which the run ranks 4th, is no longer in the ideal.
Ties change nDCG
trec_eval reads the same scores as the order 6, 1, 8, 4, 2. Then is 0.6863 with gain and 0.6729 with gain , and is 0.5627 and 0.5792. The tie-aware value of McSherry and Najork (2008) is the mean over the four orders of the tied documents. Because DCG is a sum of gain times weight, the mean is the same as giving each position of a tie group the mean gain of the group. With gain , the gains become 1, 1, 1, 0.5, 0.5, and . With gain they become 1.5, 1.5, 1, 0.5, 0.5, and .
The gain can reverse a comparison
Take two rankings of length 3 for q1: X ranks d2, d1, d3 (grades 1, 2, 0), and Y ranks d1, d3, d4 (grades 2, 0, 0).
| Ranking | nDCG@3, gain | nDCG@3, gain |
|---|---|---|
| X | ||
| Y |
With gain , X is better. With gain , Y is better: its grade 2 document at rank 1 adds 3, while X gets only from a grade 1 document at rank 1 and a grade 2 document at rank 2.
The Jarvelin and Kekalainen form
With , the fixed run has DCG and the ideal 2, 1, 1 has DCG , so the normalized value is , not 0.9360. With , ranks 1 to 9 have no discount, the run and the ideal both sum to 4, and the value is 1. The base changes the value in this form.
Query q4
q4 "quantum circuit" has no relevant document. The ideal list is empty, , and nDCG is None.
Non-examples
- Mean unnormalized DCG over queries. It mixes queries with different ideal values.
- Alpha-nDCG. It changes the gain so that a document that repeats a subtopic already covered higher in the ranking is worth less. It measures diversity, not graded relevance alone.
- Average precision, which uses binary relevance and normalizes by , not by an ideal ranking.
Related definitions
- Expected reciprocal rank and rank-biased precision also weight ranks, but from a model of when the user stops. The CWL framework describes all of them with one user model.
- LambdaRank and other methods of learning to rank train directly towards nDCG, usually with the gain .
- Precision at k is the special case of DCG@k with binary gains and the flat weight in place of the log discount.
Claims 1 and 2 are proved and hold for every ranking. Which gain and which cutoff agree best with users is a question of measurement, and the gain-flip example shows that the choice can decide which system wins. A claim that one system has a higher mean nDCG than another needs a paired test over the queries, such as the Wilcoxon signed-rank test, a permutation test or a bootstrap interval.
References
- Kalervo Jarvelin and Jaana Kekalainen, Cumulated gain-based evaluation of IR techniques, ACM Transactions on Information Systems 20(4), 2002, pp. 422-446, Section 2 (cumulated gain, discounted cumulated gain with log base b and no discount before rank b, and the normalized form divided by the ideal vector)
- Chris Burges, Tal Shaked, Erin Renshaw, Ari Lazier, Matt Deeds, Nicole Hamilton and Greg Hullender, Learning to rank using gradient descent, ICML 2005, pp. 89-96, Section 6.1, equation (16) (NDCG at rank 15 with gain 2 to the power r(j) minus 1 and discount log(1+j))
- trec_eval, the TREC evaluation program by Chris Buckley, maintained by NIST, files m_ndcg.c and m_ndcg_cut.c (gain is the relevance value in the judgments file, discount log2(rank+1), ideal ranking built from the counts of all judged relevance levels, no division when the ideal DCG is 0)
- Frank McSherry and Marc Najork, Computing information retrieval performance measures efficiently in the presence of tied scores, ECIR 2008, LNCS 4956, pp. 414-421, tie-aware NDCG, where each position of a tie group gets the mean gain of the group
- Christopher D. Manning, Prabhakar Raghavan and Hinrich Schuetze, Introduction to Information Retrieval, Cambridge University Press, 2008, Chapter 8, Section 8.4 (NDCG)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag MDZKM4 Edit this page History Report an error Markdown