InferenceAI

Enter at least two characters to search.

Start free

Discounted Cumulative Gain

mediumEvaluation20 min25 XP

Given relevance grades, return DCG@k using gain / log2(rank+1), rounded to six decimals.

Examples

EXAMPLE WALKTHROUGHfirst

A guided view of the published example, not a trace of your code.

INPUT[[3,2,1],1]
TASKdcg_at_k()
EXPECTED OUTPUT3

Start with the input values shown in this example.

Example 1 of 2

Input: relevances = [3,2,1], k = 1

Output: 3

Explanation: first

Input: relevances = [1,1], k = 2

Output: 1.63093

Explanation: two ranks

Hint 1

Ranks are one-based; the denominator is log2(rank + 1).

Topics

PythonEvaluation