Recall and NDCG at k

~15 mincode completion

Implement recall_ndcg_at_k(relevance, k) returning the array [recall, ndcg]. relevance lists every candidate in the order the model ranked them, and may exceed its length.

Where this shows up

~15 min

8 employers weight this skill

3 AI product companies, 2 frontier labs, 1 health and bio company, 1 big tech firm, 1 autonomy company. Top match scores 92.

Python
import numpy as np


def recall_ndcg_at_k(relevance, k):
    """
    Recall@k and NDCG@k for one ranked list.

    Args:
        relevance: graded relevance (0 = irrelevant) of each candidate, in ranked order
        k:         cutoff

    Returns:
        array [recall, ndcg]
    """
    # YOUR CODE HERE
    pass
Loading docs…

The AI Mentor needs an account

It reads your code and the failing tests and nudges you toward the fix without handing you the answer. Free accounts get it on every problem you're working on today.