def average_precision_score(y_true, y_score, average='macro', sample_weight=None):
 def _binary_average_precision(y_true, y_score, sample_weight=None):
  (precision, recall, thresholds) = precision_recall_curve(y_true, y_score, sample_weight=sample_weight)
  return auc(recall, precision)
 return _average_binary_score(_binary_average_precision, y_true, y_score, average, sample_weight=sample_weight)

def average_precision_score ( y_true , y_score , average = 'macro' , sample_weight = None ) : def _binary_average_precision ( y_true , y_score , sample_weight = None ) : ( precision , recall , thresholds ) = precision_recall_curve ( y_true , y_score , sample_weight = sample_weight ) return auc ( recall , precision ) return _average_binary_score ( _binary_average_precision , y_true , y_score , average , sample_weight = sample_weight )
compute average precision from prediction scores this score corresponds to the area under the precision-recall curve .