8000 RFC Revisiting meta-routing developer API for defining method mappings · Issue #28467 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

RFC Revisiting meta-routing developer API for defining method mappings #28467

@thomasjpfan

Description

@thomasjpfan

For metadata routing, meta-estimators define method mappings through this API:

router = MetadataRouter(...).add(
	 method_mapping=MethodMapping()
     .add(callee="fit", caller="fit")
     .add(callee="transform", caller="fit")
     .add(callee="transform", caller="predict"),
)

Currently, we have a shortcut to map every available method dynamically:

MetadataRouter(...).add(method_mapping="one-to-one")

And a shortcut to do a single "one-to-one" mapping:

MetadataRouter(...).add(method_mapping="score")

#28422 proposes to remove both theses shortcuts. The proposal makes sense as it forces everything to be explicit and there is only one way to define the method mappings.

On the other hand, I think a majority of the time a meta-estimator does "one-to-one" method mappings. In #28422 (comment), I proposed this API:

# Single string for a single mapping:
MethodMapping().add_one_to_one("score")

# Add a second mapping by using a list:
MethodMapping().add_one_to_one(["score", "predict"])

I'm mostly considering third party meta-estimator developers and how to make it easier for them to adopt the metadata routing API and define these mappings. If add_one_to_one handles a majority of the use cases, I think it's worth introducing even if it a second way to specify the mappings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0