class_docstr: This class is to calculate mean average precision.
    
docstr: Construct a calculator to calculate the (macro) average precision.
  
  Args:
    num_class: A positive Integer specifying the number of classes.
    top_n_array: A list of positive integers specifying the top n for each
    class. The top n in each class will be used to calculate its average
    precision at n.
    The size of the array must be num_class.
  
  Raises:
    ValueError: An error occurred when num_class is not a positive integer;
    or the top_n_array is not a list of positive integers.
docstr_tok: ["Construct","a","calculator","to","calculate","the","(","macro",")","average","precision",".","Args",":","num_class",":","A","positive","Integer","specifying","the","number","of","classes",".","top_n_array",":","A","list","of","positive","integers","specifying","the","top","n","for","each","class",".","The","top","n","in","each","class","will","be","used","to","calculate","its","average","precision","at","n.","The","size","of","the","array","must","be","num_class",".","Raises",":","ValueError",":","An","error","occurred","when","num_class","is","not","a","positive","integer",";","or","the","top_n_array","is","not","a","list","of","positive","integers","."]
code: def __init__(self, num_class):
      """Construct a calculator to calculate the (macro) average precision.
  
      Args:
        num_class: A positive Integer specifying the number of classes.
        top_n_array: A list of positive integers specifying the top n for each
        class. The top n in each class will be used to calculate its average
        precision at n.
        The size of the array must be num_class.
  
      Raises:
        ValueError: An error occurred when num_class is not a positive integer;
        or the top_n_array is not a list of positive integers.
      """
      if not isinstance(num_class, int) or num_class <= 1:
          raise ValueError("num_class must be a positive integer.")
  
      self._ap_calculators = []  # member of AveragePrecisionCalculator
      self._num_class = num_class  # total number of classes
      for i in range(num_class):
          self._ap_calculators.append(
              average_precision_calculator.AveragePrecisionCalculator()
          )
  
file_path: PaddleHub/modules/video/classification/videotag_tsn_lstm/resource/metrics/youtube8m/mean_average_precision_calculator.py
imports: import numpy
  from .None import average_precision_calculator
label_desc: Use image node_id 1 to create a new MeanAveragePrecisionCalculator object from inherited base classes: object with example: obj = MeanAveragePrecisionCalculator(num_class)