Normalised Discounted Cumulative Gain Calculator

Evaluate ranked predictions using flexible gain and discount methods, automatic ideal ordering, detailed contributions, query averages, charts, validation, and exportable machine learning results instantly.

Calculator Inputs

Use zero to evaluate the full ranking.
Use commas, spaces, semicolons, or one value per line.
Optional. Items are ranked from highest to lowest score.
Optional labels may be comma-separated or line-separated.
Optional. Leave blank to derive the ideal ranking automatically.
Format: Query Name | relevance list | predicted scores | weight. Predicted scores and weight are optional.
Optional. Match query names exactly.
Columns: query, item, relevance, predicted, ideal, weight. Query and relevance are required.
Example: 0:0,1:1,2:3,3:7

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

  1. Select single-query or multiple-query calculation mode.
  2. Enter relevance grades in their current ranked order.
  3. Add predicted scores when automatic ranking is required.
  4. Enter an ideal order or enable automatic ideal sorting.
  5. Choose gain, discount, tie, filtering, and precision options.
  6. Set k, then select Calculate NDCG.
  7. Review tables, charts, query averages, and export controls.

Example Data

Rank Document Predicted Score Relevance Grade
1Document A0.953
2Document B0.822
3Document C0.763
4Document D0.400
5Document E0.251
6Document F0.102

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.

Related Calculators

User Similarity CalculatorItem Similarity CalculatorCollaborative Filtering CalculatorMean Reciprocal Rank CalculatorPrecision at K CalculatorRecall at K Calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.