class_docstr: Normalized Cumulative Reciprocal Rank.
  
  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.
class_docstr_tok: ["Normalized","Cumulative","Reciprocal","Rank",".","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","."]
docstr: Compute Normalized Cumulative Reciprocal Rank score.
  
  Parameters
  ----------
  gt_pos: Numpy array
      Vector of positive items.
  
  pd_rank: Numpy array
      Item ranking prediction.
  
  **kwargs: For compatibility
  
  Returns
  -------
  ncrr: A scalar
      Normalized Cumulative Reciprocal Rank score.
docstr_tok: ["Compute","Normalized","Cumulative","Reciprocal","Rank","score",".","Parameters","--","--","--","--","--","gt_pos",":","Numpy","array","Vector","of","positive","items",".","pd_rank",":","Numpy","array","Item","ranking","prediction",".","*","*","kwargs",":","For","compatibility","Returns","--","--","--","-","ncrr",":","A","scalar","Normalized","Cumulative","Reciprocal","Rank","score","."]
code: def compute(self, gt_pos, pd_rank, **kwargs):
      """Compute Normalized Cumulative Reciprocal Rank score.
  
      Parameters
      ----------
      gt_pos: Numpy array
          Vector of positive items.
  
      pd_rank: Numpy array
          Item ranking prediction.
  
      **kwargs: For compatibility
  
      Returns
      -------
      ncrr: A scalar
          Normalized Cumulative Reciprocal Rank score.
  
      """
      if self.k > 0:
          truncated_pd_rank = pd_rank[: self.k]
      else:
          truncated_pd_rank = pd_rank
  
      # Compute CRR
      rec_rank = np.where(np.in1d(truncated_pd_rank, gt_pos))[0]
      if len(rec_rank) == 0:
          return 0.0
      rec_rank = (
          rec_rank + 1
      )  # +1 because indices starts from 0 in python
      crr = np.sum(1.0 / rec_rank)
  
      # Compute Ideal CRR
      max_nb_pos = min(len(gt_pos), len(truncated_pd_rank))
      ideal_rank = np.arange(max_nb_pos)
      ideal_rank = (
          ideal_rank + 1
      )  # +1 because indices starts from 0 in python
      icrr = np.sum(1.0 / ideal_rank)
  
      # Compute nDCG
      ncrr_i = crr / icrr
  
      return ncrr_i
  
imports: import numpy
  from scipy.stats import rankdata
label_desc: Use image node_id 2 for calling the NCRR obj's underlying member method code with example usage: obj.compute(gt_pos, pd_rank) and returns: ncrr_i, int