Repository navigation
Adds gain scoring metrics - #24121
bradleyfowler123 wants to merge 13 commits into
Conversation
154679d to
c0d3e76
Compare
|
@bradleyfowler123 Thanks for this PR and your willingness to contribute. Please note that #21391 (comment) was a suggestion only and not a consensus. |
|
Hi @lorentzenchr, thanks for your comment. Yes I was aware the referenced comment was just a suggestion, I only linked it on the PR for completeness. May I ask what your reservations for adding these metrics are? The paper presents some pretty compelling, mathematically grounded reasons and I've seen them used industry more than once. I can see a real advantage to sci-kit learn in offering these metrics because awareness surrounding them continues to increase and their usage is becoming more widespread. |
Generally this is not due to methods being unviable, but rather because even the best features incur necessary maintenance overhead for the rest of the library's lifespan. A good passage discussing this is in the FAQ. The paper itself warrants consideration since it meets our first-pass inclusion criteria but a discussion is still important :) |
|
We have a lot of requests for new metrics. That's why I opened the issue #21718. IIUC, this PR introduces metrics that are just monotonic mappings of already available metrics: something a user could easily do her/himself. Adding 1000+ loc seems way too much for such a functionality that does not really enable anything new (only better). That's why I'm -1 That being said, I see that the proposed functionality makes sense. |
|
A discussion would be good @lorentzenchr I see your point about mapping to gain space being just a simple function however I disagree that it's easy for a user to do. The reason why is because the mapping needs to happen at a lower level to be just as useful as the traditional metrics. To show you why with just a single example; how does one make use of sci-kit learn's capability to average metrics with |
|
However I do see the trade off you are trying to weigh up. I did try and use the existing functionality as much as possible so hopefully there isn't too much overhead added to maintenance. Either way, let me know if I can do anything to help out / discuss further with it. |
|
Probably too late to chime in, but I would support addition of such metrics to sklearn! |
|
@adrinjalali Do you have an opinion for this one? |
|
I'm happy to add these functionalities, but as hinted in my comment here (#21391 (comment)), I rather introduce only one (or two) methods/classes. One to do the plotting, which would take a metric and do the plot based on the threshold, another one I find introducing all the methods proposed here a bit cluttering the metric module. I'm happy to have all of them as examples in the docs. The code from the users' perspective would then be like gain_score(f1)(y_true, y_pred)
# or
make_scorer(gain_score(f1))(estimator, X, y)cc @glemaitre |
|
I like the proposal of @adrinjalali. However, we need to make sure that this "gain" end-up in the PR curve because this is where it makes sense. I don't know if adding a keyword there is enough. |
|
What is the status of this commit? Could you also implement |
|
I've added the code from this PR into crypdick/precision-recall-gain and handled a few more edge cases. cc @bradleyfowler123 |
What does this implement/fix? Explain your changes.
This PR adds Precision Gain, Recall Gain and Fscore Gain metrics to scikit-learn.
The metrics are described in this paper by Peter Flach and Meelis Kull at the University of Bristol, UK.
In short, these improved metrics have desirable properties such as meaningful linear interpolation of PR curves and a universal baseline across tasks.
I've added test coverage for the gain metrics and utilized existing scikit-learn Precision/Recall functionality where-ever possible.
The new methods, which can be imported
from sklearn.metricsare:Reference Issues/PRs
Request for this feature was referenced in #21391 (comment) by @glemaitre