@@ -317,23 +317,24 @@ class NDCG(_RankingMetric):
317317 Estimates relevance of recommendations taking in account their order.
318318
319319 .. math::
320- NDCG@k = DCG@k / IDCG@k
321- where :math:`DCG @k = \sum_{i=1}^{k} rel(i) / log_{}(i+1)` -
322- Discounted Cumulative Gain at k, main part of `NDCG@k` .
320+ NDCG@k=\frac{1}{|U|}\sum_{u \in U}\frac{DCG_u@k}{IDCG_u@k}
321+ where :math:`DCG_u @k = \sum_{i=1}^{k} \frac{ rel(i)}{ log_{}(i+1)} ` -
322+ Discounted Cumulative Gain at k for user u .
323323
324- The closer it is to the top the more weight it assigns to relevant items.
325324 Here:
326325 - `rel(i)` is an indicator function, it equals to ``1``
327326 if an item at rank `i` is relevant, ``0`` otherwise;
328327 - `log` - logarithm at any given base, usually ``2``.
329-
330- and :math:`IDCG@k = \sum_{i=1}^{k} (1 / log(i + 1))` -
331- `Ideal DCG@k`, maximum possible value of `DCG@k`, used as
332- normalization coefficient to ensure that `NDCG@k` values
333- lie in ``[0, 1]``.
328+ The relevant items are to the top the, more gain is achieved.
329+
330+ In the denominator of NDCG@k is `Ideal DCG@k`, maximum possible value of `DCG@k`, used as
331+ normalization coefficient to ensure that `NDCG@k` valueslie in ``[0, 1]``.
332+ When `divide_by_achievable` is set to ``False`` (default) it is the same value for all users
333+ ans is equal to:
334+ :math:`IDCG_u@k = \sum_{i=1}^{k} \frac{1}{log(i + 1)}`
334335 When `divide_by_achievable` is set to ``True``, the formula for IDCG depends
335- on number of each user test positives. IDCG for each user is computed as
336- :math:`\frac{1}{\ sum_{i=1}^{\min (|R(u)|, K)} \frac{1}{\log_{}(i+1)} }`
336+ on number of each user relevant items in the test set. The formula is:
337+ :math:`IDCG_u@k = \ sum_{i=1}^{\min (|R(u)|, k)} \frac{1}{log(i + 1) }`
337338
338339 Parameters
339340 ----------
0 commit comments