average_precision_score from sklearn uses formula:
ap = sum( (recall[k+1] - recall[k]) * precision[k+1] )
But trapezoidal rule implies:
ap = sum( (recall[k+1] - recall[k]) * (precision[k+1] - precision[k]) / 2 )
This is typical Precision-Recall curve:
We can see, that sklearn average_precision_score would over-estimate AUPRC, and trapezoidal rule is more exact.
However, one argument against trapezoidal rule is
"This implementation is not interpolated and is different from computing the area under the precision-recall curve with the trapezoidal rule, which uses linear interpolation and can be too optimistic"
So why not use trapezoidal rule? Is it optimistic or pessimistic?