0
$\begingroup$

I have a search engine that returns results with a normalized score on the scale 0.0 to 1.0. Higher score means higher relevancy to the input query.

The ranked output scores look like this, e.g. [1.0, 0.5, 0.1] vs [0.6, 0.5, 0.4] for k=3.

Assuming that these scores are indeed correct, I want to measure the quality of the results for a given query. The intuition is that if the collection contains very relevant results for a query, the aggregated score for the top k results should be high, whereas the score should be low if the collection has fewer good results.

Following that intuition, good results on the top ranks should be emphasized, whereas lower ranks are less important. DCG seems to be a good candidate as it weighs in the rank: formula

However, when looking at common implementations of (n)DCG, the output rankings are always compared against the true scores, for instance in scikit-learn.

Comparing against the true relevancy clearly makes sense for evaluating an information retrieval system against a manually labeled dataset. However, how does this fit into the DCG formula above? The formula only takes a single ranking into account.

So my questions are:

  • How is DCG used to compare an output ranking against a "true" ranking?
  • Does the DCG score as outlined above, for a single ranking, make sense to indicate the quality of the results for a query?
  • Bonus question: can I use e.g. the (n)DCG implementation of scikit-learn without true scores?
$\endgroup$

1 Answer 1

0
$\begingroup$

Consider we have 3 articles with true relevance scores as [10, 7, 2], and our search engine gave them predicted scores as [0.4, 0.7, 0.2]. In this case, we are ranking the $2^{nd}$ article first, followed by the $1^{st}$ and then the $3^{rd}$ at last. In other words, the true relevance scores (each representing one article) are re-ordered by the search engine into [7, 10, 2].

The following answer will be based on this [7, 10, 2] result.

How is DCG used to compare an output ranking against a "true" ranking?

by $DCG \over idealDCG$ reference

For example, normalized DCG of [7, 10, 2] is DCG of [7, 10, 2] divided by DCG of [10, 7, 2]

Does the DCG score as outlined above, for a single ranking, make sense to indicate the quality of the results for a query?

Given that you said

The intuition is that if the collection contains very relevant results for a query, the aggregated score for the top k results should be high, whereas the score should be low if the collection has fewer good results.

I think you don't care the ordering, so my answer is No. You use DCG when you specifically care about the ordering. Note that the denominator of the DCG penalize the score ranked later, which means you have a higher DCG if you rank your results by the scores.

High DCG: [10, 7, 2] Low DCG: [7, 10, 2] Lowest DCG: [2, 7, 10]

Certainly the absolute score values also impact the DCG such that DCG of [10, 7, 2] is better than DCG of [3, 2, 1], but DCG of [2, 7, 10] is also worse than [10, 7, 2]. In this case, is DCG still your choice?

Bonus question: can I use e.g. the (n)DCG implementation of scikit-learn without true scores?

Yes for DCG. You can pass the same value for both y_true and y_score and this is equivalent to saying that your search engine always predicts the ordering correctly. But this is not the right way to use it.

Summary: DCG is designed for ordering.

$\endgroup$
12
  • $\begingroup$ Thanks for the answer! After looking at the sklearn implementations of (n)DCG, I am still not clear about the comparison part. In sklearn, both DCG and nDCG take a y_true and a y_score argument, whereas your description reads like nDCG was the use case for comparing a DCG score against a "gold standard". $\endgroup$
    – Carsten
    Jan 24, 2022 at 14:29
  • $\begingroup$ To get a DCG of a sequence, you need two pieces of information. #1 the order #2 the true score. y_score gives you #1, y_true gives you #2. y_score is assigned by your search engine, it talks about the order ONLY: the higher the score, the higher the order should be. y_true is the true relevance (not predicted by your search engine). Therefore you need both for DCG. For nDCG, the only new thing it needs to calculate is the ideal-DCG, ofcourse it also requires the two pieces of information, but y_true alone is enough, therefore, nDCG still just requires the same y_true and y_score. $\endgroup$ Jan 24, 2022 at 14:59
  • $\begingroup$ @Carsten, I have modified my answer, and I hope this will be clearer. $\endgroup$ Jan 24, 2022 at 15:35
  • 1
    $\begingroup$ Search engine's score only determines the $i$ for each of the articles. $\endgroup$ Jan 25, 2022 at 9:22
  • 1
    $\begingroup$ Ok, got it now. This assumes a fixed list of scores in which only the ranking between ideal/true and actual scores can differ. $\endgroup$
    – Carsten
    Jan 25, 2022 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.