code: def recall(truth, recommend, k=None):
      
      if len(truth) == 0:
          if len(recommend) == 0:
              return 1.
          return 0.
  
      if k is None:
          k = len(recommend)
      return count_true_positive(truth, recommend[:k]) / float(truth.size)
docs: Recall@k.
  
      Args:
          truth (numpy 1d array): Set of truth samples.
          recommend (numpy 1d array): Ordered set of recommended samples.
          k (int): Top-k items in `recommend` will be recommended.
  
      Returns:
          float: Recall@k.