parameters: (rec, prec, use_07_metric=False)
return_statement: return ap
docstring: average precision calculations
      [precision integrated to recall]
      :param rec: recall
      :param prec: precision
      :param use_07_metric: 2007 metric is 11-recall-point based AP
      :return: average precision
docstring_summary: average precision calculations
      [precision integrated to recall]
      :param rec: recall
      :param prec: precision
      :param use_07_metric: 2007 metric is 11-recall-point based AP
      :return: average precision
docstring_tokens: average precision calculations [ precision integrated to recall ] : param rec : recall : param prec : precision : param use_07_metric : 2007 metric is 11 - recall - point based AP : return : average precision
function: def voc_ap(rec, prec, use_07_metric=False):
      """
      average precision calculations
      [precision integrated to recall]
      :param rec: recall
      :param prec: precision
      :param use_07_metric: 2007 metric is 11-recall-point based AP
      :return: average precision
      """
      if use_07_metric:
          ap = 0.
          for t in np.arange(0., 1.1, 0.1):
              if np.sum(rec >= t) == 0:
                  p = 0
              else:
                  p = np.max(prec[rec >= t])
              ap += p / 11.
      else:
          # append sentinel values at both ends
          mrec = np.concatenate(([0.], rec, [1.]))
          mpre = np.concatenate(([0.], prec, [0.]))
  
          # compute precision integration ladder
          for i in range(mpre.size - 1, 0, -1):
              mpre[i - 1] = np.maximum(mpre[i - 1], mpre[i])
  
          # look for recall value changes
          i = np.where(mrec[1:] != mrec[:-1])[0]
  
          # sum (\delta recall) * prec
          ap = np.sum((mrec[i + 1] - mrec[i]) * mpre[i + 1])
      return ap
function_tokens: def voc_ap ( rec , prec , use_07_metric = False ) : if use_07_metric : ap = 0. for t in np . arange ( 0. , 1.1 , 0.1 ) : if np . sum ( rec >= t ) == 0 : p = 0 else : p = np . max ( prec [ rec >= t ] ) ap += p / 11. else : # append sentinel values at both ends mrec = np . concatenate ( ( [ 0. ] , rec , [ 1. ] ) ) mpre = np . concatenate ( ( [ 0. ] , prec , [ 0. ] ) ) # compute precision integration ladder for i in range ( mpre . size - 1 , 0 , - 1 ) : mpre [ i - 1 ] = np . maximum ( mpre [ i - 1 ] , mpre [ i ] ) # look for recall value changes i = np . where ( mrec [ 1 : ] != mrec [ : - 1 ] ) [ 0 ] # sum (\delta recall) * prec ap = np . sum ( ( mrec [ i + 1 ] - mrec [ i ] ) * mpre [ i + 1 ] ) return ap