sklearn.metrics.average_precision_score formula
The average precision score calculate in the sklearn function follows the formula shown below and in the attached image.
AP = Σ(Rn - Rn-1)Pn *The index value of the sumation is n. Please refer to the attached image for a clear version of the formula
I am struggling to fully understand the math behind this function. I am particularly curious about how the nth thresholds in the formula are calculated. Are the number of thresholds equivalent to the number of samples?