PluginParamsForecaster
Plugs parameters from a parameter estimator into a forecaster.
In fit, first fits param_est to data passed:
yoffitis passed as the first arg toparam_est.fitXoffitis passed as the second arg, ifparam_est.fithas a second argfhoffitis passed asfh, if any remaining arg ofparam_est.fitisfh
Then, does forecaster.set_params with desired/selected parameters. Parameters of the fitted param_est are passed on to forecaster, from/to pairs are as specified by the params parameter of self, see below.
Then, fits forecaster to the data passed in fit.
After that, behaves identically to forecaster with those parameters set. update behaviour is controlled by the update_params parameter.
Example: param_est seasonality test to determine sp parameter; forecaster a forecaster with an sp parameter, e.g., ExponentialSmoothing.
Schnellstart
from sktime.param_est.plugin import PluginParamsForecaster
estimator = PluginParamsForecaster(param_est, forecaster, params=None, update_params=False)Parameter(4)
- param_estsktime estimator object with a fit method, inheriting from BaseEstimator
e.g., estimator inheriting from BaseParamFitter or forecaster this is a “blueprint” estimator, state does not change when
fitis called- forecastersktime forecaster, i.e., estimator inheriting from BaseForecaster
this is a “blueprint” estimator, state does not change when
fitis called- paramsNone, str, list of str, dict with str values/keys, optional, default=None
determines which parameters from
param_estare plugged into forecaster where None: all parameters of param_est are plugged into forecaster only parameters present in bothforecasterandparam_estare plugged in list of str: parameters in the list are plugged into parameters of the same name only parameters present in bothforecasterandparam_estare 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 inparam_estand values inforecasterare plugged in- update_paramsbool, optional, default=False
whether fitted parameters by param_est_ are to be updated in self.update
Beispiele
>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.naive import NaiveForecaster
>>> from sktime.param_est.plugin import PluginParamsForecaster
>>> from sktime.param_est.seasonality import SeasonalityACF
>>> from sktime.transformations.difference import Differencer
>>>
>>> y = load_airline ()
>>>
>>> # sp_est is a seasonality estimator
>>> # ACF assumes stationarity so we concat with differencing first
>>> sp_est = Differencer () * SeasonalityACF ()
>>>
>>> # fcst is a forecaster with a "sp" parameter which we want to tune
>>> fcst = NaiveForecaster ()
>>>
>>> # sp_auto is auto-tuned via PluginParamsForecaster
>>> sp_auto = PluginParamsForecaster (sp_est, fcst)
>>>
>>> # fit sp_auto to data, predict, and inspect the tuned sp parameter
>>> sp_auto. fit (y, fh = [1, 2, 3 ]) PluginParamsForecaster(
... )
>>> y_pred = sp_auto. predict ()
>>> sp_auto. forecaster_. get_params ()["sp" ] 12
>>> # shorthand ways to specify sp_auto, via dunder, does the same
>>> sp_auto = sp_est * fcst
>>> # or entire pipeline in one go
>>> sp_auto = Differencer () * SeasonalityACF () * NaiveForecaster () using dictionary to plug “foo” parameter into “sp”
>>> from sktime.param_est.fixed import FixedParams
>>> sp_plugin = PluginParamsForecaster (
... FixedParams ({ "foo": 12 }), NaiveForecaster (), params = { "sp": "foo" }
... )