class_docstr: Normalized Discount Cumulative Gain.
  
  Parameters
  ----------
  k: int or list, optional, default: -1 (all)
      The number of items in the top@k list.
      If None, all items will be considered.
  
  References
  ----------
  https://en.wikipedia.org/wiki/Discounted_cumulative_gain
class_docstr_tok: ["Normalized","Discount","Cumulative","Gain",".","Parameters","--","--","--","--","--","k",":","int","or","list",",","optional",",","default",":","-1","(","all",")","The","number","of","items","in","the","top","@","k","list",".","If","None",",","all","items","will","be","considered",".","References","--","--","--","--","--","https",":","\/\/en.wikipedia.org\/wiki\/Discounted_cumulative_gain"]
docstr: Compute Discounted Cumulative Gain score.
  
  Parameters
  ----------
  gt_pos: Numpy array
      Vector of positive items.
  
  pd_rank: Numpy array
      Item ranking prediction.
  
  k: int, optional, default: -1 (all)
      The number of items in the top@k list.
      If None, all items will be considered.
  
  Returns
  -------
  dcg: A scalar
      Discounted Cumulative Gain score.
docstr_tok: ["Compute","Discounted","Cumulative","Gain","score",".","Parameters","--","--","--","--","--","gt_pos",":","Numpy","array","Vector","of","positive","items",".","pd_rank",":","Numpy","array","Item","ranking","prediction",".","k",":","int",",","optional",",","default",":","-1","(","all",")","The","number","of","items","in","the","top","@","k","list",".","If","None",",","all","items","will","be","considered",".","Returns","--","--","--","-","dcg",":","A","scalar","Discounted","Cumulative","Gain","score","."]
code: def dcg_score(gt_pos, pd_rank, k=-1):
      """Compute Discounted Cumulative Gain score.
  
      Parameters
      ----------
      gt_pos: Numpy array
          Vector of positive items.
  
      pd_rank: Numpy array
          Item ranking prediction.
  
      k: int, optional, default: -1 (all)
          The number of items in the top@k list.
          If None, all items will be considered.
  
      Returns
      -------
      dcg: A scalar
          Discounted Cumulative Gain score.
  
      """
      if k > 0:
          truncated_pd_rank = pd_rank[:k]
      else:
          truncated_pd_rank = pd_rank
  
      ranked_scores = np.in1d(truncated_pd_rank, gt_pos).astype(int)
      gain = 2**ranked_scores - 1
      discounts = np.log2(np.arange(len(ranked_scores)) + 2)
  
      return np.sum(gain / discounts)
  
imports: import numpy
  from scipy.stats import rankdata
label_desc: Use image node_id 2 for calling the NDCG obj's underlying member method code with example usage: obj.dcg_score(gt_pos, pd_rank, k) and returns: np