Repository navigation
Description
Warning
This issue is not yet ready for a PR. If you are interested in contributing to scikit-learn, please have a look at our contributing guidelines, and in particular the sections for new contributors and the "Needs triage" label.
Maintainer note: I am planning out my own work here. If you're not in the scikit-learn organisation, please refrain from opening a PR.
There are several steps to take to de-tangle the design of the metadata routing module in sklearn/utils/_metadata_requests.py and the utilities and tests around that module. The current design often intertwines several functionalities, so it will take several iterations to take them apart. The goal is to make metadata routing simpler and easier to maintain by the 1.10 release in November 2026.
I would like to lead a series of PRs that result in a simpler design. Each PR should leave metadata routing in a working, tested state; the full simplification is visible only across the series.
This issue tracks the planned steps. I will update and adjust as I go.
Goal
Simpler, easier-to-maintain metadata routing by 1.10 (Nov 2026), or anytime in the future.
Possible measures (to check for feasibility)
- API Developer API for customising metadata requests in consumers #34314 (
__sklearn_get_metadata_request__, docs, tests) (new feature, rather than simplification but unblocks MNT Refactor and deprecateget_metadata_routingmethod in_MetadataRequester#31695) - use new developer API in _BaseScorer: API Developer API for customising metadata requests in consumers #34314 (comment)
- MNT Refactor and deprecate
get_metadata_routingmethod in_MetadataRequester#31695 - Split
_get_metadata_requestinto two functions; clone stored_metadata_requestvs build defaults (see #34314 comment) - Split
__sklearn_get_metadata_request__into two functions (see API Developer API for customising metadata requests in consumers #34314 (comment)) - Naming cleanup: align parameter names (
method,kwargs,props,parent, …) across the module - clean up what "default requests" means in the variable names and internal docs (this term currently can mean many different things)
- define what metadata is within scikit-learn positively (list of things metadata can be), instead of negatively (collecting all from the signatures and excluding some by filtering, UNUSED flag, ...)
- remove the "always ignore the first param" rule
- With auto-requests to come, we deal with a complicated 4-step mechanism to set routing requests in consumers:
- signature-sniffing for setting requests to
None - overriding with class-level
__metadata_request__*, - overrriding with auto-requests in runtime (but only allowing for
Truevalues), - overriding with user-set requests
We should check what we can do to simplify that.
- signature-sniffing for setting requests to
- Check if we can get rid of the distinction between
SIMPLE_METHODSandCOMPOSITE_METHODSand threat them equally, see https://github.com/scikit-learn/scikit-learn/pull/31413/changes#r3853537529. We did this in several past PRs already, but for a larger scope, we would need to create requests methods for all METHODS inMetadataRequester.__init__and follow through in many places of the code, especiallyMetadataRequester.__getattr__. - MultiOutput* and RANSACRegressor still use
sample_weightin their fit signatures and we can deprectate them now: ENH Auto-requestingsample_weighton pure consumers #34966 (comment)
Comments and feedback welcome here, @adrinjalali and @OmarManzoor. :)
Also CC @scikit-learn/core-devs in case that's of interest to someone else.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn Progress
Activity