code: def reciprocal_rank(truth, recommend):
      
      for n in range(recommend.size):
          if recommend[n] in truth:
              return 1. / (n + 1)
      return 0.
docs: Reciprocal Rank (RR).
  
      Args:
          truth (numpy 1d array): Set of truth samples.
          recommend (numpy 1d array): Ordered set of recommended samples.
  
      Returns:
          float: RR.