sklearn.utils.metadata_routing
.MethodMapping¶
- class sklearn.utils.metadata_routing.MethodMapping[source]¶
Stores the mapping between callee and caller methods for a router.
This class is primarily used in a
get_metadata_routing()
of a router object when defining the mapping between a sub-object (a sub-estimator or a scorer) to the router’s methods. It stores a collection ofRoute
namedtuples.Iterating through an instance of this class will yield named
MethodPair(callee, caller)
tuples.New in version 1.3.
Methods
add
(*, callee, caller)Add a method mapping.
from_str
(route)Construct an instance from a string.
- add(*, callee, caller)[source]¶
Add a method mapping.
- Parameters:
- calleestr
Child object’s method name. This method is called in
caller
.- callerstr
Parent estimator’s method name in which the
callee
is called.
- Returns:
- selfMethodMapping
Returns self.
- classmethod from_str(route)[source]¶
Construct an instance from a string.
- Parameters:
- routestr
A string representing the mapping, it can be:
"one-to-one"
: a one to one mapping for all methods."method"
: the name of a single method, such asfit
,transform
,score
, etc.
- Returns:
- objMethodMapping
A
MethodMapping
instance constructed from the given string.