How we Compute NDCG in Daraz (E-Commerce)

NDCG evaluates ranking quality through three principles: relevance hierarchy, position weighting, and query independence. Selected as “the most simple and widely used measure in ranking evaluation.”

Relevance weights from user funnel

ActionScore
Purchase5
Add to Cart2
Click1

Implementation assumptions

  1. Top-10 only — lower positions yield negligible impact
  2. Clicked-only instances — focus on searches with at least one product interaction
  3. A/B-test ready — supports comparison across multiple ranking algorithms

Calculation

  • DCG: weighted relevance sum with position-based discount factors
  • IDCG: same calculation on perfectly-ranked items based on actual user behavior
  • NDCG = DCG / IDCG

Implementation: Python UDFs for individual search instance calculation + SQL aggregation across datasets.

People