Skip to content

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

adrinjalali
Copy link
Member

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 a MetadataRequest but not MetadataRouter).

This fixes the issue, and improves the implementation in RidgeCV which was arguably not perfect.

cc @StefanieSenger @ogrisel @antoinebaker

Copy link

github-actions bot commented Aug 8, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: efdb799. Link to the linter CI: here

Copy link
Member

@StefanieSenger StefanieSenger left a 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
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Comment on lines +2521 to +2523
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.
Copy link
Member

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?

Copy link
Member Author

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.

adrinjalali and others added 2 commits August 12, 2025 15:57
Co-authored-by: Stefanie Senger <91849487+StefanieSenger@users.noreply.github.com>
Co-authored-by: Stefanie Senger <91849487+StefanieSenger@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: To Review
Development

Successfully merging this pull request may close these issues.

Pipeline score asks to explicitly request sample_weight
2 participants