-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG] Adds _MultimetricScorer for Optimized Scoring #14484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for this @thomasjpfan! Is there any reason not to just generically support If so, I think this becomes conceptually simpler for users (the existing list and dict specifications for scoring become shorthands for such a callable), and doesn't involve introducing a custom type. |
A user would require to build their callable to be smart about calling
This is internally used by I have been considering making |
Just had a discussion with @thomasjpfan with some ideas of how to simplify this. What I find strange about the current design is that our scorers are used just to provide meta-data and I think I would like to represent that meta-data more explicitly. |
A user would require to build their callable to be smart about calling
predict, predict_proba and decision_function. This does not allow a user to
build effective multimetric scorers out of individual scikit-learn scorers.
But it allows them to easily avoid repeated computation in something like
precision_recall_fscore_support... Essentially to efficiently reuse a
single confusion matrix computation.
|
Good point. Allowing users to be able to pass a callable that returns a dictionary would be pretty useful.
We can get away with this if the following did not exist: scikit-learn/sklearn/model_selection/_validation.py Lines 511 to 516 in e23f58d
With all this feedback, this PR will be in flux, thus WIP. |
Please ping me when you need reviews! |
e0734e4
to
114e31d
Compare
This is ready for a review.
I do have plans to support custom callables that return dictionaries from the user. This was not included in this PR to narrow the scope of this PR to |
@thomasjpfan do you need a thorough review or just feedback on the API? For the former I could use a user guide, some examples and some comments / docstrings ;) |
There are no public api changes. I added docstrings for the private |
Closed and reappeared at #14593 |
Reference Issues/PRs
Fixes #10802
Alternative to #10979
What does this implement/fix? Explain your changes.
This PR creates a
_MultimetricScorer
that subclasses dict which is used to reduce the number of calls topredict
,predict_proba
, anddecision_function
.The public interface of objects and functions using
scoring
are unchanged.The cache is only used when it is beneficial to use, as defined in
_MultimetricScorer._use_cache
.Any other comments?
I do have plans to support custom callables that return dictionaries from the user. This was not included in this PR to narrow the scope of this PR to
_MultimetricScorer
.