File Exchange

image thumbnail

Normalized Discounted Cumulative Gain (NDCG)

version (2.77 KB) by Jan Motl
Returns the Normalized Discounted Cumulative Gain

1 Download

Updated 31 Dec 2017

View License

A straightforward implementation of NDCG, a measure of ranking quality, which closely follows the definition from

Cite As

Jan Motl (2020). Normalized Discounted Cumulative Gain (NDCG) (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (2)

Jan Motl

@ahmed The function accepts `pred_relevance` vector that can be shorter than `y` vector. If you want nDCG@10, simply pass to the function `pred_relevance` that is truncated to the top 10 items.

The example in the function illustrates calculation of nDCG@6 for 8 items in vector `y`. The example is described into the details at Wikipedia article about DCG.


how to Implementation nDCG@10 ?


Adds illustrative image with the used equation

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux