You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Precision Recall numbers computed by Scikits are not interpolated (non-standard) #4577
Smooth out the kinks and reduce noise contribution to the score
In any practical application, if your PR curve ever went up, then you would strictly prefer to set your threshold there rather than at the original place (achieving both more precision and recall). Hence, people prefer to interpolate the curve, which better integrates out the threshold parameter and gives a more sensible estimate of the real performance.
The concern is that people using the scikit version will see incorrectly reported LOWER performance, than what they might see reported in other papers.
"Non-standard" might depend on the particular field of application. I think it would be worth having an interpolation mode. Could you also comment on #4223?
RE "Non-standard" granted. More precisely, the community-agreed-on gold standard at least in the chunk of Machine Learning and Computer Vision that I work in is the Pascal VOC evaluation code.
The Pascal VOC code is in Matlab, and works as follows. First, in VOCevalaction.m we have:
% compute precision/recall
[so,si]=sort(-out); % out are class confidences
tp=gt(si)>0; % true positives
fp=gt(si)<0; % false posities
fp=cumsum(fp);
tp=cumsum(tp);
rec=tp/sum(gt>0); % recalls
prec=tp./(fp+tp); % precisions
and then they call ap=VOCap(rec,prec);, which we can descend into:
functionap= VOCap(rec,prec)
mrec=[0 ; rec ; 1];
mpre=[0 ; prec ; 0];
for i=numel(mpre)-1:-1:1
mpre(i)=max(mpre(i),mpre(i+1));
end
i=find(mrec(2:end)~=mrec(1:end-1))+1;
ap=sum((mrec(i)-mrec(i-1)).*mpre(i));
In particular note the padding with 0 and 1, and the interpolation (loop with max). The last part integrates the precision over the recalls.
Are we sure that this is correct way to interpolate the pr-curve?
I thought that the interpolation has to be done first in the roc-space then translated into as there is a one-to-one mapping between those curves. This is highlighted in this paper.
Having multiple strategies is probably a good idea. I think VOC and vl_feat are pretty good references, but that is because I'm from the computer vision community. Other communities might have different conventions, and interpolating AUC in the precision/recall space does seem a bit odd.
On the off-chance that @karpathy is reading this: the IR book doesn't use interpolation from what I understand. vl_feat uses non-interpolated average precision by the default form the code you linked to.
The Pascal VOC code uses "interpolated" AP, while their paper said they use 11 point. We should probably add options for those two, but I don't think we should use either by default.
I'm pleased to see that average_precision_score no longer linearly interpolates between operating points, but I found the updated documentation confusing. The referenced Stanford IR book and VOC paper implement interpolated versions that differ from the sklearn implementation. Adding the average precision formula as @brendano suggested or removing these references would make it easier to see what the function computes without looking at the source.
You're right that @brendano's comment about clear documentation still
stands.
I wasn't heavily involved in this change, but I think there was a decision
that the Pascal VOC metric had too many problems to be a default, even
though we may want to provide it (PR welcome).
A PR removing the VOC reference, fixing the Wikipedia link to a particular
revision, and describing the metric both in the docstring and in
doc/modules/model_evaluation.rst would be very welcome.
Activity
jnothman commentedon Apr 12, 2015
"Non-standard" might depend on the particular field of application. I think it would be worth having an interpolation mode. Could you also comment on #4223?
karpathy commentedon Apr 12, 2015
RE "Non-standard" granted. More precisely, the community-agreed-on gold standard at least in the chunk of Machine Learning and Computer Vision that I work in is the Pascal VOC evaluation code.
The Pascal VOC code is in Matlab, and works as follows. First, in
VOCevalaction.mwe have:and then they call
ap=VOCap(rec,prec);, which we can descend into:In particular note the padding with 0 and 1, and the interpolation (loop with max). The last part integrates the precision over the recalls.
glouppe commentedon Apr 12, 2015
+1 for documenting and/or adding this variant. This is the kind of hidden pitfalls that users should be made more aware of.
amueller commentedon Apr 13, 2015
+1 that probably makes the numbers in my papers better ^^
arjoly commentedon Jul 8, 2015
Are we sure that this is correct way to interpolate the pr-curve?
I thought that the interpolation has to be done first in the roc-space then translated into as there is a one-to-one mapping between those curves. This is highlighted in this paper.
chiragnagpal commentedon Jul 9, 2015
We could have multiple values for the interpolate parameter, that way we can add newer interpolation techniques ?
arjoly commentedon Jul 10, 2015
ping @amueller, @glouppe @jnothman
amueller commentedon Jul 11, 2015
Having multiple strategies is probably a good idea. I think VOC and vl_feat are pretty good references, but that is because I'm from the computer vision community. Other communities might have different conventions, and interpolating AUC in the precision/recall space does seem a bit odd.
amueller commentedon Jul 11, 2015
[I haven't really put any thought into it though]
amueller commentedon Jul 12, 2015
The IR book also seems to interpolate the precision / recall curve. So I think that should be the right thing do to? http://nlp.stanford.edu/IR-book/html/htmledition/evaluation-of-ranked-retrieval-results-1.html
agramfort commentedon Jul 14, 2015
fair enough
9 remaining items
amueller commentedon Jun 10, 2017
@GaelVaroquaux I don't think this was fixed by your PR, as it neither implemented the "interpolated" nor the "11 point interpolated" version.
amueller commentedon Jun 10, 2017
On the off-chance that @karpathy is reading this: the IR book doesn't use interpolation from what I understand. vl_feat uses non-interpolated average precision by the default form the code you linked to.
The Pascal VOC code uses "interpolated" AP, while their paper said they use 11 point. We should probably add options for those two, but I don't think we should use either by default.
GaelVaroquaux commentedon Jun 10, 2017
amueller commentedon Jul 21, 2017
The nips paper linked above is quite nice and argues again that the VOC measure makes no sense ^^
agitter commentedon Aug 17, 2017
I'm pleased to see that
average_precision_scoreno longer linearly interpolates between operating points, but I found the updated documentation confusing. The referenced Stanford IR book and VOC paper implement interpolated versions that differ from the sklearn implementation. Adding the average precision formula as @brendano suggested or removing these references would make it easier to see what the function computes without looking at the source.jnothman commentedon Aug 17, 2017
adrinjalali commentedon Apr 18, 2024
#9583 solves the last issues here IIUC.