ToolJoltTools

NDCG Calculator

Normalized Discounted Cumulative Gain — the gold-standard ranking metric with graded relevance and position discounting.

DCG@K
Ideal DCG@K
NDCG@K

NDCG handles GRADED relevance (a perfect result beats a merely-okay one) and discounts by position via log₂, then normalizes so 1.0 is the best possible ordering. It's the default offline metric at every major search/recommendation company.

Formula

DCG@K = Σ (2^relᵢ − 1) / log₂(i+1) · NDCG = DCG / IDCG (DCG of the perfectly-sorted list)
References: Järvelin & Kekäläinen (2002), Cumulated gain-based evaluation of IR techniques; Wang et al. (2013), A Theoretical Analysis of NDCG Ranking Measures

About NDCG Calculator

NDCG is the most complete ranking metric and the offline standard at search and recommendation companies, because it handles two things simpler metrics ignore: graded relevance (a perfect result should outrank a merely-acceptable one) and position discounting (relevance at rank 1 is worth more than at rank 10, via a log₂ discount). It then normalizes by the ideal ordering so scores land in [0,1] and compare across queries. This calculator computes DCG, the ideal DCG, and the normalized NDCG@K from your graded relevance list — the exact computation libraries run.

How to use NDCG Calculator

  1. 1Enter your values into NDCG Calculator — sensible, domain-typical defaults are pre-filled so you see a real result immediately.
  2. 2The result recomputes live using the formula shown on the page; there is no button to press.
  3. 3Adjust any input to compare scenarios, then read the worked example to see the substituted numbers.

Why use NDCG Calculator?

  • Computes NDCG instantly in your browser — no sign-up, no upload, no server round-trip.
  • 100% free and unlimited, with the exact formula shown: DCG@K = Σ (2^relᵢ − 1) / log₂(i+1).
  • Runs entirely client-side, so every value you enter stays private on your device.
  • Live recompute as you type, with a worked example and authoritative references for trust.

Frequently asked questions

Why does NDCG use graded relevance instead of binary?+

Because real relevance isn't yes/no — a perfect match, a decent result and a tangential one are genuinely different, and a ranker that puts the perfect result first should beat one that leads with the decent one. The 2^rel − 1 gain term rewards surfacing the BEST items high, not just any relevant item.

What does the log₂ discount represent?+

User attention decay with position. Dividing each result's gain by log₂(position+1) means rank 1 keeps full value, rank 3 is worth ~0.63, rank 7 ~0.36 — modeling how dramatically click-through and attention drop down the list. It's an empirical choice that matches observed user behavior reasonably well.

Why normalize to get NDCG rather than just using DCG?+

Raw DCG depends on how many relevant items exist and their grades, so it's not comparable across queries — an easy query with many perfect results inflates DCG. Dividing by the ideal DCG (the best achievable ordering) rescales every query to [0,1], where 1.0 means 'perfectly ordered', making averaging across queries meaningful.

NDCG vs MAP — which to use?+

NDCG when relevance is graded (star ratings, 0–3 judgments) and position matters — the richer, more common choice for modern ranking. MAP when relevance is binary and you want a precision-recall-flavored summary. NDCG is generally preferred for learning-to-rank because it directly captures the graded, position-aware quality users experience.

Related tools

Related ML & AI tools

Sponsored