Back to models
Forecaster

PluginParamsForecaster

Categorical in XInsamplePred int insampleExogenousMultivariate

Plugs parameters from a parameter estimator into a forecaster.

In fit, first fits param_est to data passed:

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

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

  • fh of fit is passed as fh, if any remaining arg of param_est.fit is fh

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.

Quickstart

python
from sktime.param_est.plugin import PluginParamsForecaster

estimator = PluginParamsForecaster(param_est, forecaster, params=None, update_params=False)

Parameters(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 fit is called

forecastersktime forecaster, i.e., estimator inheriting from BaseForecaster

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 forecaster where None: all parameters of param_est are plugged into forecaster only parameters present in both forecaster 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 forecaster 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 forecaster are plugged in

update_paramsbool, optional, default=False

whether fitted parameters by param_est_ are to be updated in self.update

Examples

>>> 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" }
... )