Search code examples
scikit-learnprecision-recall

sklearn difference between average_precision_score vs precision_score


In the documentation it describes average_precision_score as area under the precision recall curve. I am having trouble understanding what does the area signify?

How is this metric different from just raw precision score.


Solution

  • The precision-recall curve plots precision and recall for different probability thresholds p. For p=0, everything is classified as 1 so recall will be 100% and precision will be the proportion of 1's in your test dataset. For p=1, nothing is classified as 1, so recall will be 0% and precision will be 0. For p=0.5, that's what precision_score tells you, however, you probably won't want to use this threshold in you're final model, you'll choose a different threshold depending on the number of false positives you're willing to tolerate. So the average precision score gives you the average precision of all the different threshold choices.