class_docstr: Mean Average Precision (MAP).
  
  References
  ----------
  https://en.wikipedia.org/wiki/Evaluation_measures_(information_retrieval)#Mean_average_precision
class_docstr_tok: ["Mean","Average","Precision","(","MAP",")",".","References","--","--","--","--","--","https",":","\/\/en.wikipedia.org\/wiki\/Evaluation_measures_","(","information_retrieval",")","#","Mean_average_precision"]
docstr: Compute Average Precision.
  
  Parameters
  ----------
  item_indices: Numpy array
      Items being considered for evaluation.
  
  pd_scores: Numpy array
      Prediction scores for items.
  
  gt_pos: Numpy array
      Vector of positive items.
  
  **kwargs: For compatibility
  
  Returns
  -------
  res: A scalar
      AP score.
docstr_tok: ["Compute","Average","Precision",".","Parameters","--","--","--","--","--","item_indices",":","Numpy","array","Items","being","considered","for","evaluation",".","pd_scores",":","Numpy","array","Prediction","scores","for","items",".","gt_pos",":","Numpy","array","Vector","of","positive","items",".","*","*","kwargs",":","For","compatibility","Returns","--","--","--","-","res",":","A","scalar","AP","score","."]
code: def compute(self, item_indices, pd_scores, gt_pos, **kwargs):
      """Compute Average Precision.
  
      Parameters
      ----------
      item_indices: Numpy array
          Items being considered for evaluation.
  
      pd_scores: Numpy array
          Prediction scores for items.
  
      gt_pos: Numpy array
          Vector of positive items.
  
      **kwargs: For compatibility
  
      Returns
      -------
      res: A scalar
          AP score.
  
      """
      relevant = np.in1d(item_indices, gt_pos)
      rank = rankdata(-pd_scores, "max")[relevant]
      L = rankdata(-pd_scores[relevant], "max")
      ans = (L / rank).mean()
  
      return ans
  
imports: import numpy
  from scipy.stats import rankdata
label_desc: Use image node_id 2 for calling the MAP obj's underlying member method code with example usage: obj.compute(item_indices, pd_scores, gt_pos) and returns: ans