class_docstr: Average precision metric.
docstr: Calculate average precision (area under PR curve).
  
  Example:
      >>> y_true = [0, 1]
      >>> y_pred = [0.1, 0.6]
      >>> round(AveragePrecision()(y_true, y_pred), 2)
      0.75
      >>> round(AveragePrecision()([], []), 2)
      0.0
  
  :param y_true: The ground true label of each document.
  :param y_pred: The predicted scores of each document.
  :return: Average precision.
docstr_tok: ["Calculate","average","precision","(","area","under","PR","curve",")",".","Example",":",">",">",">","y_true","=","[","0",",","1","]",">",">",">","y_pred","=","[","0.1",",","0.6","]",">",">",">","round","(","AveragePrecision","(",")","(","y_true",",","y_pred",")",",","2",")","0.75",">",">",">","round","(","AveragePrecision","(",")","(","[","]",",","[","]",")",",","2",")","0.0",":","param","y_true",":","The","ground","true","label","of","each","document",".",":","param","y_pred",":","The","predicted","scores","of","each","document",".",":","return",":","Average","precision","."]
code: def __call__(self, y_true: np.array, y_pred: np.array) -> float:
      """
      Calculate average precision (area under PR curve).
  
      Example:
          >>> y_true = [0, 1]
          >>> y_pred = [0.1, 0.6]
          >>> round(AveragePrecision()(y_true, y_pred), 2)
          0.75
          >>> round(AveragePrecision()([], []), 2)
          0.0
  
      :param y_true: The ground true label of each document.
      :param y_pred: The predicted scores of each document.
      :return: Average precision.
      """
      precision_metrics = [Precision(k + 1) for k in range(len(y_pred))]
      out = [metric(y_true, y_pred) for metric in precision_metrics]
      if not out:
          return 0.0
      return np.asscalar(np.mean(out))
  
imports: import numpy
  from matchzoo.engine import base_metric
  from .None import Precision
label_desc: Use image node_id 3 for calling the AveragePrecision obj's underlying member method code with example usage: obj.__call__(y_true, y_pred) and returns: np, int