3/31
Part 1 of 6 · DCGLearn and do

DCG adds up gains, and lower ranks count for less

Grading a ranked list needs two ideas: how much each result is worth, and how much its position counts.

A better grade is worth much more

Gain 2^grade − 1
grade 0
0
grade 1
1
grade 2
3
grade 3
7
grade 4
15

Results get grades from human judges or from what users did. A common scale runs from 0 to 3, where 3 is exactly right and 0 is wrong.

The gain turns a grade into points. With 2grade−12^{grade} - 1 the points roughly double with each grade, so one perfect result beats several decent ones.

Each rank down counts a little less

RankWeight 1 / log2(rank + 1)Weight 1 / rank
11.001.00
20.630.50
30.500.33
40.430.25
50.390.20
100.290.10

A result further down is worth less, because the user is less likely to ever look at it. The discount says how much less. DCG divides each gain by log⁡2(rank+1)\log_2(\text{rank} + 1), so each rank keeps a weight of one over that: the left column.

The weight falls fast at first, then flattens. Rank 2 keeps 63% of its gain, and rank 10 still keeps 29%.

That's on purpose. Järvelin and Kekäläinen, who defined these measures in a 2002 paper on cumulated gain, wanted a discount that falls, but not as steeply as dividing by the rank. Users do keep reading. Dividing by the rank, the right column, would leave rank 10 with 10%.

In the editor, write gains(grades): the gain 2^grade - 1 of every grade. Then write weights(n): the weight 1 / log2(rank + 1) that each rank from 1 to n keeps. Both return NumPy arrays.