code: def mpr(truth, recommend):
      
      if len(recommend) == 0 and len(truth) == 0:
          return 0.  # best
      elif len(truth) == 0 or len(truth) == 0:
          return 100.  # worst
  
      accum = 0.
      n_recommend = recommend.size
      for t in truth:
          r = np.where(recommend == t)[0][0] / float(n_recommend)
          accum += r
      return accum * 100. / truth.size
docs: Mean Percentile Rank (MPR).
  
      Args:
          truth (numpy 1d array): Set of truth samples.
          recommend (numpy 1d array): Ordered set of recommended samples.
  
      Returns:
          float: MPR.