class_docstr: Calculate mean AP for object detection task
  
  Parameters:
  ---------
  iou_thresh : float
      IOU overlap threshold for TP
  class_names : list of str
      optional, if provided, will print out AP for each class
class_docstr_tok: ["Calculate","mean","AP","for","object","detection","task","Parameters",":","--","--","--","--","-","iou_thresh",":","float","IOU","overlap","threshold","for","TP","class_names",":","list","of","str","optional",",","if","provided",",","will","print","out","AP","for","each","class"]
docstr: calculate average precision
  
  Params:
  ----------
  rec : numpy.array
      cumulated recall
  prec : numpy.array
      cumulated precision
  Returns:
  ----------
  ap as float
docstr_tok: ["calculate","average","precision","Params",":","--","--","--","--","--","rec",":","numpy.array","cumulated","recall","prec",":","numpy.array","cumulated","precision","Returns",":","--","--","--","--","--","ap","as","float"]
code: def _average_precision(self, rec, prec):
      """
      calculate average precision
  
      Params:
      ----------
      rec : numpy.array
          cumulated recall
      prec : numpy.array
          cumulated precision
      Returns:
      ----------
      ap as float
      """
      if rec is None or prec is None:
          return np.nan
  
      # append sentinel values at both ends
      mrec = np.concatenate(([0.0], rec, [1.0]))
      mpre = np.concatenate(([0.0], np.nan_to_num(prec), [0.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
  
file_path: gluon-cv/gluoncv/utils/metrics/voc_detection.py
imports: from __future__ import division
  from collections import defaultdict
  import numpy
  import mxnet
  from ..bbox import bbox_iou
label_desc: Use image node_id 7 for calling the VOCMApMetric obj's underlying member method code with example usage: obj._average_precision(rec, prec) and returns: ap, np