Back to models
Transformer

PluginParamsTransformer

Plugs parameters from a parameter estimator into a transformer.

In fit, first fits param_est to data passed:

  • X of fit is passed as the first arg to param_est.fit

  • y of fit is passed as the second arg to param_est.fit, if param_est.fit has a second arg

Then, does transformer.set_params with desired/selected parameters. Parameters of the fitted param_est are passed on to transformer, from/to pairs are as specified by the params parameter of self, see below.

Then, fits transformer to the data passed in fit.

After that, behaves identically to transformer with those parameters set.

Example: param_est seasonality test to determine sp parameter; transformer a transformer with an sp parameter, e.g., Deseasonalizer.

Quickstart

python
from sktime.param_est.plugin import PluginParamsTransformer

estimator = PluginParamsTransformer(param_est, transformer, params=None, update_params=False)

Parameters(3)

param_estsktime estimator object with a fit method, inheriting from BaseEstimator

e.g., estimator inheriting from BaseParamFitter or transformer this is a “blueprint” estimator, state does not change when fit is called

transformersktime transformer, i.e., estimator inheriting from BaseTransformer

this is a “blueprint” estimator, state does not change when fit is called

paramsNone, str, list of str, dict with str values/keys, optional, default=None

determines which parameters from param_est are plugged into trafo and where None: all parameters of param_est are plugged into transformer only parameters present in both transformer and param_est are plugged in list of str: parameters in the list are plugged into parameters of the same name only parameters present in both transformer and param_est are plugged in str: considered as a one-element list of str with the string as single element dict: parameter with name of value is plugged into parameter with name of key only keys present in param_est and values in transformer are plugged in

Examples

>>> from sktime.datasets import load_airline
>>> from sktime.param_est.plugin import PluginParamsTransformer
>>> from sktime.param_est.seasonality import SeasonalityACF
>>> from sktime.transformations.detrend import Deseasonalizer
>>> from sktime.transformations.difference import Differencer
>>> 
>>> X = load_airline ()
>>> 
>>> # sp_est is a seasonality estimator
>>> # ACF assumes stationarity so we concat with differencing first
>>> sp_est = Differencer () * SeasonalityACF ()
>>> # trafo is a forecaster with a "sp" parameter which we want to tune
>>> trafo = Deseasonalizer ()
>>> sp_auto = PluginParamsTransformer (sp_est, trafo)
>>> 
>>> # fit sp_auto to data, transform, and inspect the tuned sp parameter
>>> sp_auto. fit (X) PluginParamsTransformer(
... )
>>> Xt = sp_auto. transform (X)
>>> sp_auto. transformer_. get_params ()["sp" ] 12
>>> # shorthand ways to specify sp_auto, via dunder, does the same
>>> sp_auto = sp_est * trafo
>>> # or entire pipeline in one go
>>> sp_auto = Differencer () * SeasonalityACF () * Deseasonalizer () using dictionary to plug “foo” parameter into “sp”
>>> from sktime.param_est.fixed import FixedParams
>>> sp_plugin = PluginParamsTransformer (
... FixedParams ({ "foo": 12 }), Deseasonalizer (), params = { "sp": "foo" }
... )