pyabc.transition
Transitions kernels
Transition or perturbation strategies to propose new parameters based on the current population. Usually this translates to randomly selecting a parameter in the current generation and then perturbing it, but in general arbitrary transition kernels are possible.
These can be passed to pyabc.smc.ABCSMC via the transitions
keyword argument.
- class pyabc.transition.AggregatedTransition(mapping: dict[str | tuple[str, ...], Transition])[source]
Bases:
TransitionDifferent transitions for different subsets of the parameters.
The transitions are applied independently of each other, i.e. the transition density factorizes. Correlations betweeen parameters must be handled inside a single transition, if needed.
- Parameters:
mapping – The mapping of parameters (as tuples of str or single str) to the transition kernel to be used for those parameters.
- fit(X: DataFrame, w: ndarray) None[source]
Fit the density estimator (perturber) to the sampled data. Concrete implementations might do something like fitting a KDE.
The parameters given as
Xandware automatically stored inself.Xandself.w.- Parameters:
X – The parameters.
w – The corresponding weights
- pdf(x: Parameter | Series | DataFrame) float | ndarray[source]
Evaluate the probability density function (PDF) at x.
- Parameters:
x – Parameter. If x is a Parameter or Series, then x should have the columns from X passed to the fit method as indices. If x is a DataFrame, then x should have the same columns as X passed before to the fit method. The order of the columns is not important
- Returns:
density – Probability density at x.
- Return type:
- rvs(size: int = None) Parameter | DataFrame
Sample from the density.
- Parameters:
size – Number of independent samples to draw. If None, a single Parameter from rvs_single() is returned, if it is an integer >= 1, a pandas.DataFrame with the corresponding number of rows is returned.
- Returns:
samples
- Return type:
The parameter sample(s).
Note
This method can be overridden for efficient implementations. The default is to call rvs_single repeatedly (which might not be the most efficient way).
- rvs_single() Parameter[source]
Random variable sample (rvs).
Sample from the fitted distribution.
- Returns:
A sample from the fitted model.
- Return type:
sample
- set_fit_request(*, w: bool | None | str = '$UNCHANGED$') AggregatedTransition
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- set_score_request(*, w: bool | None | str = '$UNCHANGED$') AggregatedTransition
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- class pyabc.transition.DiscreteJumpTransition(domain: ndarray, p_stay: float = 0.7)[source]
Bases:
DiscreteTransitionTransition with positive random jump probability for discrete parameters. Adapts base draw probabilities to the last generation’s histogram and then jumps to an arbitrary other parameter with a positive jump probability to ensure that the prior is absolutely continuous w.r.t. the proposal.
- Parameters:
domain – See the PerturbationKernel.
p_stay – See the PerturbationKernel.
note:: (..) – This transition can only deal with a single parameter. Use an AggregatedTransition to combine multiple parameters.
- pdf(x: Parameter | Series | DataFrame) float | ndarray[source]
Compute the probability mass function at x.
- rvs(size: int = None) Parameter | DataFrame
Sample from the density.
- Parameters:
size – Number of independent samples to draw. If None, a single Parameter from rvs_single() is returned, if it is an integer >= 1, a pandas.DataFrame with the corresponding number of rows is returned.
- Returns:
samples
- Return type:
The parameter sample(s).
Note
This method can be overridden for efficient implementations. The default is to call rvs_single repeatedly (which might not be the most efficient way).
- set_fit_request(*, w: bool | None | str = '$UNCHANGED$') DiscreteJumpTransition
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- set_score_request(*, w: bool | None | str = '$UNCHANGED$') DiscreteJumpTransition
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- class pyabc.transition.DiscreteRandomWalkTransition(n_steps: int = 1, p_l: float = 0.3333333333333333, p_r: float = 0.3333333333333333, p_c: float = 0.3333333333333333)[source]
Bases:
DiscreteTransitionThis transition is based on a discrete random walk. This may be useful for discrete ordinal parameter distributions that can be described as lying on the grid of integers.
Note
This transition does not adapt to the problem structure and thus has potentially slow convergence. Further, the transition does not satisfy proposal >> prior, so that it is indeed not valid as an importance sampling distribution. This can be overcome by selecting the number of steps as a random variable.
- Parameters:
n_steps (int, optional (default = 1)) – Number of random walk steps to take.
- __init__(n_steps: int = 1, p_l: float = 0.3333333333333333, p_r: float = 0.3333333333333333, p_c: float = 0.3333333333333333)[source]
- fit(X: DataFrame, w: ndarray)[source]
Fit the density estimator (perturber) to the sampled data. Concrete implementations might do something like fitting a KDE.
The parameters given as
Xandware automatically stored inself.Xandself.w.- Parameters:
X – The parameters.
w – The corresponding weights
- pdf(x: Parameter | Series | DataFrame) float | ndarray[source]
Evaluate the probability mass function (PMF) at x.
- rvs(size: int = None) Parameter | DataFrame
Sample from the density.
- Parameters:
size – Number of independent samples to draw. If None, a single Parameter from rvs_single() is returned, if it is an integer >= 1, a pandas.DataFrame with the corresponding number of rows is returned.
- Returns:
samples
- Return type:
The parameter sample(s).
Note
This method can be overridden for efficient implementations. The default is to call rvs_single repeatedly (which might not be the most efficient way).
- rvs_single() Parameter[source]
Random variable sample (rvs).
Sample from the fitted distribution.
- Returns:
A sample from the fitted model.
- Return type:
sample
- set_fit_request(*, w: bool | None | str = '$UNCHANGED$') DiscreteRandomWalkTransition
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- set_score_request(*, w: bool | None | str = '$UNCHANGED$') DiscreteRandomWalkTransition
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- class pyabc.transition.DiscreteTransition[source]
Bases:
TransitionThis is a base class for discrete transition kernels.
- abstractmethod fit(X: DataFrame, w: ndarray) None
Fit the density estimator (perturber) to the sampled data. Concrete implementations might do something like fitting a KDE.
The parameters given as
Xandware automatically stored inself.Xandself.w.- Parameters:
X – The parameters.
w – The corresponding weights
- abstractmethod pdf(x: Parameter | Series | DataFrame) float | ndarray
Evaluate the probability density function (PDF) at x.
- Parameters:
x – Parameter. If x is a Parameter or Series, then x should have the columns from X passed to the fit method as indices. If x is a DataFrame, then x should have the same columns as X passed before to the fit method. The order of the columns is not important
- Returns:
density – Probability density at x.
- Return type:
- rvs(size: int = None) Parameter | DataFrame
Sample from the density.
- Parameters:
size – Number of independent samples to draw. If None, a single Parameter from rvs_single() is returned, if it is an integer >= 1, a pandas.DataFrame with the corresponding number of rows is returned.
- Returns:
samples
- Return type:
The parameter sample(s).
Note
This method can be overridden for efficient implementations. The default is to call rvs_single repeatedly (which might not be the most efficient way).
- abstractmethod rvs_single() Parameter
Random variable sample (rvs).
Sample from the fitted distribution.
- Returns:
A sample from the fitted model.
- Return type:
sample
- set_fit_request(*, w: bool | None | str = '$UNCHANGED$') DiscreteTransition
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- set_score_request(*, w: bool | None | str = '$UNCHANGED$') DiscreteTransition
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- class pyabc.transition.GridSearchCV(estimator=None, param_grid=None, scoring=None, n_jobs=1, refit=True, cv=5, verbose=0, pre_dispatch='2*n_jobs', error_score='raise', return_train_score=True)[source]
Bases:
GridSearchCVDo a grid search to automatically select the best parameters for transition classes such as the
pyabc.transition.MultivariateNormalTransition.This is essentially a thin wrapper around ‘sklearn.model_selection.GridSearchCV’. It translates the scikit-learn interface to the interface used in pyABC. It implements hence a thin adapter pattern.
The parameters are just as for sklearn.model_selection.GridSearchCV. Major default values:
estimator = MultivariateNormalTransition()
param_grid = {‘scaling’: np.linspace(0.05, 1.0, 5)}
cv = 5
- __init__(estimator=None, param_grid=None, scoring=None, n_jobs=1, refit=True, cv=5, verbose=0, pre_dispatch='2*n_jobs', error_score='raise', return_train_score=True)[source]
- set_fit_request(*, groups: bool | None | str = '$UNCHANGED$') GridSearchCV
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- class pyabc.transition.LocalTransition(k=None, k_fraction=0.25, scaling=1)[source]
Bases:
TransitionLocal KDE fit. Takes into account only the k nearest neighbors, similar to [Filippi].
- Parameters:
- EPS
Scaling of the identity matrix to be added to the covariance in case the covariances are not invertible.
- Type:
[Filippi]Filippi, Sarah, Chris P. Barnes, Julien Cornebise, and Michael P.H. Stumpf. “On Optimality of Kernels for Approximate Bayesian Computation Using Sequential Monte Carlo.” Statistical Applications in Genetics and Molecular Biology 12, no. 1 (2013): 87–107. doi:10.1515/sagmb-2012-0069.
- fit(X, w=None)[source]
Fit the density estimator (perturber) to the sampled data. Concrete implementations might do something like fitting a KDE.
The parameters given as
Xandware automatically stored inself.Xandself.w.- Parameters:
X – The parameters.
w – The corresponding weights
- pdf(x: Parameter | Series | DataFrame)[source]
Evaluate the probability density function (PDF) at x.
- Parameters:
x – Parameter. If x is a Parameter or Series, then x should have the columns from X passed to the fit method as indices. If x is a DataFrame, then x should have the same columns as X passed before to the fit method. The order of the columns is not important
- Returns:
density – Probability density at x.
- Return type:
- rvs(size: int = None) Parameter | DataFrame
Sample from the density.
- Parameters:
size – Number of independent samples to draw. If None, a single Parameter from rvs_single() is returned, if it is an integer >= 1, a pandas.DataFrame with the corresponding number of rows is returned.
- Returns:
samples
- Return type:
The parameter sample(s).
Note
This method can be overridden for efficient implementations. The default is to call rvs_single repeatedly (which might not be the most efficient way).
- rvs_single() Parameter[source]
Random variable sample (rvs).
Sample from the fitted distribution.
- Returns:
A sample from the fitted model.
- Return type:
sample
- set_fit_request(*, w: bool | None | str = '$UNCHANGED$') LocalTransition
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- set_score_request(*, w: bool | None | str = '$UNCHANGED$') LocalTransition
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- class pyabc.transition.ModelPerturbationKernel(nr_of_models: int, probability_to_stay: float | None = None)[source]
Bases:
objectModel perturbation kernel.
- nr_of_models
Number of models
- probability_to_stay
If
None, probability to stay is set to 1/nr_of_models. Otherwise, the supplied value is used.
- class pyabc.transition.MultivariateNormalTransition(scaling: float = 1, bandwidth_selector: ~collections.abc.Callable[[int, int], float] = <function silverman_rule_of_thumb>)[source]
Bases:
TransitionTransition via a multivariate Gaussian KDE estimate.
- Parameters:
scaling (float) – Scaling is a factor which additionally multiplies the covariance with. Since Silverman and Scott usually have too large bandwidths, it should make most sense to have 0 < scaling <= 1
bandwidth_selector (optional) – Defaults to silverman_rule_of_thumb. The bandwidth selector is a function of the form f(n_samples: float, dimension: int), where n_samples denotes the (effective) samples size (and is therefore) a float and dimension is the parameter dimension.
- __init__(scaling: float = 1, bandwidth_selector: ~collections.abc.Callable[[int, int], float] = <function silverman_rule_of_thumb>)[source]
- fit(X: DataFrame, w: ndarray) None[source]
Fit the density estimator (perturber) to the sampled data. Concrete implementations might do something like fitting a KDE.
The parameters given as
Xandware automatically stored inself.Xandself.w.- Parameters:
X – The parameters.
w – The corresponding weights
- pdf(x: Parameter | Series | DataFrame) float | ndarray[source]
Evaluate the probability density function (PDF) at x.
- Parameters:
x – Parameter. If x is a Parameter or Series, then x should have the columns from X passed to the fit method as indices. If x is a DataFrame, then x should have the same columns as X passed before to the fit method. The order of the columns is not important
- Returns:
density – Probability density at x.
- Return type:
- rvs(size: int = None) Parameter | DataFrame[source]
Sample from the density.
- Parameters:
size – Number of independent samples to draw. If None, a single Parameter from rvs_single() is returned, if it is an integer >= 1, a pandas.DataFrame with the corresponding number of rows is returned.
- Returns:
samples
- Return type:
The parameter sample(s).
Note
This method can be overridden for efficient implementations. The default is to call rvs_single repeatedly (which might not be the most efficient way).
- rvs_single() Parameter[source]
Random variable sample (rvs).
Sample from the fitted distribution.
- Returns:
A sample from the fitted model.
- Return type:
sample
- set_fit_request(*, w: bool | None | str = '$UNCHANGED$') MultivariateNormalTransition
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- set_score_request(*, w: bool | None | str = '$UNCHANGED$') MultivariateNormalTransition
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- class pyabc.transition.PerturbationKernel(domain: ndarray, p_stay: float = 0.7)[source]
Bases:
objectParameter perturbation kernel for a discrete set of parameters.
- Parameters:
domain – All possible parameter values.
p_stay – The probability to stay at a given parameter value.
- class pyabc.transition.Transition[source]
Bases:
BaseEstimatorAbstract Transition base class. Derive all Transitions from this class
Note
This class does a little bit of meta-programming.
The fit, pdf and rvs methods are automatically wrapped to handle the special case of no parameters.
Hence, you can safely assume that you encounter at least one parameter. All the defined transitions will then automatically generalize to the case of no parameter.
- abstractmethod fit(X: DataFrame, w: ndarray) None[source]
Fit the density estimator (perturber) to the sampled data. Concrete implementations might do something like fitting a KDE.
The parameters given as
Xandware automatically stored inself.Xandself.w.- Parameters:
X – The parameters.
w – The corresponding weights
- mean_cv(n_samples: None | int = None) float[source]
Estimate the uncertainty on the KDE.
- Parameters:
n_samples (int, optional) – Estimate the CV for
n_samplessamples. If this parameter is not given, the sample size of the last fit is used.- Returns:
mean_cv – The estimated average coefficient of variation.
- Return type:
Note
A call to this method, as a side effect, also sets the attributes
test_points_,test_weights_andvariation_at_test_points_. These are the individual points, weights and variations used to calculate the mean.
- abstractmethod pdf(x: Parameter | Series | DataFrame) float | ndarray[source]
Evaluate the probability density function (PDF) at x.
- Parameters:
x – Parameter. If x is a Parameter or Series, then x should have the columns from X passed to the fit method as indices. If x is a DataFrame, then x should have the same columns as X passed before to the fit method. The order of the columns is not important
- Returns:
density – Probability density at x.
- Return type:
- rvs(size: int = None) Parameter | DataFrame[source]
Sample from the density.
- Parameters:
size – Number of independent samples to draw. If None, a single Parameter from rvs_single() is returned, if it is an integer >= 1, a pandas.DataFrame with the corresponding number of rows is returned.
- Returns:
samples
- Return type:
The parameter sample(s).
Note
This method can be overridden for efficient implementations. The default is to call rvs_single repeatedly (which might not be the most efficient way).
- abstractmethod rvs_single() Parameter[source]
Random variable sample (rvs).
Sample from the fitted distribution.
- Returns:
A sample from the fitted model.
- Return type:
sample
- set_fit_request(*, w: bool | None | str = '$UNCHANGED$') Transition
Configure whether metadata should be requested to be passed to the
fitmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- set_score_request(*, w: bool | None | str = '$UNCHANGED$') Transition
Configure whether metadata should be requested to be passed to the
scoremethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.