code: def _dcg(scores, discount=np.log2):
      """
      Compute the Discounted Cumulative Gain of a series of recommended items with rating scores.
      These should be relevance scores; they can be :math:`{0,1}` for binary relevance data.
  
      This is not a true top-N metric, but is a utility function for other metrics.
  
      Args:
          scores(array-like):
              The utility scores of a list of recommendations, in recommendation order.
          discount(ufunc):
              the rank discount function.  Each item's score will be divided the discount of its rank,
              if the discount is greater than 1.
  
      Returns:
          double: the DCG of the scored items.
      """
      scores = np.nan_to_num(scores)
      ranks = np.arange(1, len(scores) + 1)
      disc = discount(ranks)
      np.maximum(disc, 1, out=disc)
      np.reciprocal(disc, out=disc)
      return np.dot(scores, disc)
  
file_path: lkpy/lenskit/metrics/topn.py
imports: import logging
  import warnings
  import numpy
  import pandas
label_desc: Use image node_id 10 for calling a global function with example usage: _dcg(scores, discount) and returns: np