-
-
Notifications
You must be signed in to change notification settings - Fork 26.1k
FIX make sure _PassthroughScorer works with meta-estimators #31898
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix and the explanations yesterday, @adrinjalali!
I have looked through the PR and left some suggestions.
except AttributeError: | ||
pass | ||
|
||
self._metadata_request = requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If _PassthroughScorer
doesn't act as a _MetadataRequester
anymore, then we don't need it to inherit from it. It then also doesn't need to overwrite its set_score_request
method and the tests to test the new error message are not needed either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have a look and see if this would break things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried it. It seems to all work.
This uses `self._get_scorer_instance()` implemented in child objects to get the | ||
raw scorer instance of the estimator, which will be ignored if `self.scoring` is | ||
not None. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a more straightforward way to call get_scorer("r2")
and get_scorer("accuracy")
? I wonder why we jump to the child object's _get_scorer_instance
only to refer to what is defined in RegressorMixin
and ClassifierMixin
afterwards. Can this directly be defined in RegressorMixin
and ClassifierMixin
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no way for us right now to access the scorer from those mixins. I thought of adding it there, but then it would only be used here. So not sure it's worth it to be added there.
Co-authored-by: Stefanie Senger <91849487+StefanieSenger@users.noreply.github.com>
Co-authored-by: Stefanie Senger <91849487+StefanieSenger@users.noreply.github.com>
Fixes #30937
The issue was that
_PassthroughScorer
tries to be smart with metadata-routing info it stores, which only works with simply consumers and not meta estimators (or rather, works when given aMetadataRequest
but notMetadataRouter
).This fixes the issue, and improves the implementation in
RidgeCV
which was arguably not perfect.cc @StefanieSenger @ogrisel @antoinebaker