Rank Order Accuracy using Discounted Cumulative Gain

Suppose you have some system that predicts the ordering (ranking) of items and you want to compute a measure of prediction accuracy. It’s a bit of a tricky problem. One approach is to use what’s called Discounted Cumulative Gain (DCG).

In my example below, there are six items to rank. The correct ordering is (1, 2, 3, 4, 5, 6) and the predicted ordering is (2, 1, 3, 4, 6 5) which is pretty close. Using DCG, the prediction accuracy is 0.8745.

First you compute DCG for the correct (ideal) ordering. We assume that 1st place has “relevance” 6, 2nd place has relevance 5, and so on. Then DCG is sum[ 2^rel-1 / log2(i+1) ] = 94.5903.

Next you compute the DCG for the predicted ordering using the relevance values. Here that value is 82.7188.

The final accuracy metric is the DCG of the predicted ranking divided by the DCG of the ideal ranking = 82.7188 / 94.5903 = 0.8745. This is called the normalized DCG, or nDCG.



Beauty contests are an example of an applied ranking problem. Here are seven participants in the 2018 Miss Universe contest. From left: Miss Canada, Miss Poland, Miss Philippines (she won the event), Miss Switzerland, Miss Columbia, Miss Bolivia, Miss Kyrgyzstan. Beauty is subjective so I don’t think DCG applies here.

This entry was posted in Miscellaneous. Bookmark the permalink.

3 Responses to Rank Order Accuracy using Discounted Cumulative Gain

  1. Fritz's avatar Fritz says:

    Hi James – I always enjoy your posts when I have time to read them. In this case – can you give an example of where you would use DCG? I cannot quite understand – to calculate the prediction accuracy, you need the correct ranking score, so why not just rank them correctly? It seems like a catch 22 or am I missing something?

    • Yes, you are correct that in order to compute a ranking accuracy metric (or any other kind of accuracy metric for that matter), you need to know the correct result.

      DCG is often used when in information retrieval scenarios like Web search. You devise a system, then test it in a system where you knw the correct ranking of relevant documents that should be returned by the search.

Comments are closed.