Calculator Inputs
Formula Used
DCG@k = Σ[(2^relᵢ − 1) / log₂(i + 1)] IDCG@k = DCG@k for the ideal relevance ordering NDCG@k = DCG@k / IDCG@k
The calculator can replace exponential gain with linear, binary, or custom gains. It can also change the logarithm base or remove rank discounting. When IDCG equals zero, the displayed NDCG becomes zero.
How to Use
- Select single-query or multiple-query calculation mode.
- Enter relevance grades in their current ranked order.
- Add predicted scores when automatic ranking is required.
- Enter an ideal order or enable automatic ideal sorting.
- Choose gain, discount, tie, filtering, and precision options.
- Set k, then select Calculate NDCG.
- Review tables, charts, query averages, and export controls.
Example Data
| Rank | Document | Predicted Score | Relevance Grade |
|---|---|---|---|
| 1 | Document A | 0.95 | 3 |
| 2 | Document B | 0.82 | 2 |
| 3 | Document C | 0.76 | 3 |
| 4 | Document D | 0.40 | 0 |
| 5 | Document E | 0.25 | 1 |
| 6 | Document F | 0.10 | 2 |
Understanding NDCG
DCG rewards relevant items appearing near the beginning of a ranking. IDCG represents the best possible ordering for those relevance grades. NDCG compares actual gain with that ideal gain.
NDCG commonly ranges from zero to one with nonnegative relevance grades. A score near one indicates strong ordering quality. Lower values reveal misplaced highly relevant results.
Precision ignores graded relevance and rank discount after the cutoff. MRR focuses on the first relevant item only. MAP averages precision values at relevant ranks.
Frequently Asked Questions
What does NDCG measure?
It measures ranked retrieval quality using graded relevance. Higher-ranked relevant items contribute more value. The score is normalised against an ideal ordering.
What is a good NDCG score?
Higher scores usually indicate better ranking quality. Acceptable values depend on datasets and business goals. Compare models using identical evaluation settings.
Why can NDCG equal zero?
All gains may be zero at the evaluated ranks. IDCG may also equal zero. This calculator avoids division by zero safely.
Can NDCG exceed one?
Standard nonnegative settings should not exceed one. Custom ideals or negative gains can change that. Review the ideal order and gain mapping.
Should I use linear or exponential gain?
Linear gain treats relevance differences evenly. Exponential gain emphasises highly relevant items strongly. Use the convention required by your benchmark.
How does cutoff k affect results?
The cutoff limits evaluation to top-ranked items. Smaller values focus on early ranking quality. Larger values evaluate more of the result list.
What happens with tied predicted scores?
You can preserve order or apply tie rules. Expected averaging estimates equal treatment within tied groups. Use consistent rules when comparing models.
How are multiple queries averaged?
Macro averaging gives each query equal influence. Weighted averaging uses the supplied query weights. Both values appear in the results summary.
Can I upload evaluation data?
Yes, upload a CSV file with required columns. Query and relevance columns are mandatory. Other supported columns add labels, scores, ideals, and weights.