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
label_ranking_average_precision_score: sample_weighting isn't applied to items with zero true labels #13412
label_ranking_average_precision_score offers a sample_weighting argument to allow nonuniform contribution of individual samples to the reported metric. Separately, individual samples whose labels are the same for all classes (all true or all false) are treated as a special case (precision == 1, line 732). However, this special case bypasses the application of sample_weight (line 740). So, in the case where there is both non-default sample_weighting and samples with, for instance, zero labels, the reported metric is wrong.
In the file sklearn/metrics/ranking.py. I added the following lines.
*negate the score we added above (typo in comment)
but it is NOT passing the checks that involve some unittests. Given that this is a bug, shouldn't it FAIL some unittests after fixing the bug? or am I interpreting the 'x' mark below COMPLETELY wrong?
Since I see a 'x' mark, I haven't submitted a pull request.
Can I submit a pull request for a bug despite the 'x' mark?
I don't think this is quite the fix we want. The edge case is not that the sample weight is zero (I just used that in the example to make the impact easy to see). The problem is to account for any kind of non-default sample weight in the case of constant labels for all classes.
Bookmarking this. As a first timer, this is super helpful. From this, I understand which file I'm supposed to be writing test cases in and the fact that it should be robust. It really helps also drive the point home about writing code in such a way that very minimal changes need to be made to EXTEND the code. I can see how 4 lines of code help achieve this because of the REST of the code is written overall.
I should develop the patience the will power to work out the math formula for this listed in the documentation. Had I done that, I would've written more meaningful code.
I'll spend some time and try to go over why your lines make sense.
Thanks a ton for pinging this here and giving me a notification.
Activity
jnothman commentedon Mar 10, 2019
Thanks for the bug report. A pull request with a fix is welcome
AbhishekBabuji commentedon Mar 10, 2019
Will take this
AbhishekBabuji commentedon Mar 10, 2019
In the file
sklearn/metrics/ranking.py. I added the following lines.*negate the score we added above (typo in comment)
but it is NOT passing the checks that involve some unittests. Given that this is a bug, shouldn't it FAIL some unittests after fixing the bug? or am I interpreting the 'x' mark below COMPLETELY wrong?
Since I see a 'x' mark, I haven't submitted a pull request.
Can I submit a pull request for a bug despite the 'x' mark?
jnothman commentedon Mar 11, 2019
dpwe commentedon Mar 11, 2019
I don't think this is quite the fix we want. The edge case is not that the sample weight is zero (I just used that in the example to make the impact easy to see). The problem is to account for any kind of non-default sample weight in the case of constant labels for all classes.
I'll work on a solution and some tests.
Fix to scikit-learn#13412
dpwe commentedon Mar 14, 2019
See #13447
AbhishekBabuji commentedon Mar 14, 2019
Bookmarking this. As a first timer, this is super helpful. From this, I understand which file I'm supposed to be writing test cases in and the fact that it should be robust. It really helps also drive the point home about writing code in such a way that very minimal changes need to be made to EXTEND the code. I can see how 4 lines of code help achieve this because of the REST of the code is written overall.
I should develop the patience the will power to work out the math formula for this listed in the documentation. Had I done that, I would've written more meaningful code.
I'll spend some time and try to go over why your lines make sense.
Thanks a ton for pinging this here and giving me a notification.