10/31
Part 3 of 6 · A worked exampleLearn and do

A worked example

Six listings come back for a search, judged 0 to 3. In the order your ranker showed them, the grades are [2, 3, 0, 1, 2, 3]. Score the top 5.

shown = [2, 3, 0, 1, 2, 3]
print(f"{dcg_at_k(shown, 5):.2f}")
print(f"{dcg_at_k(sorted(shown, reverse=True), 5):.2f}")
print(f"{ndcg_at_k(shown, 5):.2f}")
Predict

The ranker showed grades [2, 3, 0, 1, 2, 3]. What is NDCG@5?

Pick one to see what it prints.
Pick an answer above to see the rest
Predict

Build the ideal from the top 5 only, so the grade 3 at rank 6 never counts. What does NDCG@5 become?

Pick one to see what it prints.
Pick an answer above to see the rest
Predict

Swap ranks 1 and 2, so the grade 3 comes first: [3, 2, 0, 1, 2, 3]. What is NDCG@5?

Pick one to see what it prints.
Pick an answer above to see the rest