Back to models
Forecaster

ForecastingPipeline

Pipeline for forecasting with exogenous data.

Quickstart

python
from sktime.forecasting.compose import ForecastingPipeline

estimator = ForecastingPipeline(steps)

Parameters(1)

stepslist of sktime transformers and forecasters, or

list of tuples (str, estimator) of sktime transformers or forecasters. The list must contain exactly one forecaster. These are “blueprint” transformers resp forecasters, forecaster/transformer states do not change when fit is called.

Examples

>>> from sktime.datasets import load_longley
>>> from sktime.forecasting.naive import NaiveForecaster
>>> from sktime.forecasting.compose import ForecastingPipeline
>>> from sktime.transformations.impute import Imputer
>>> from sktime.forecasting.base import ForecastingHorizon
>>> from sktime.split import temporal_train_test_split
>>> from sklearn.preprocessing import MinMaxScaler
>>> y, X = load_longley ()
>>> y_train, _, X_train, X_test = temporal_train_test_split (y, X)
>>> fh = ForecastingHorizon (X_test. index, is_relative = False) Example 1: string/estimator pairs
>>> pipe = ForecastingPipeline (steps = [
... ("imputer", Imputer (method = "mean")),
... ("minmaxscaler", MinMaxScaler ()),
... ("forecaster", NaiveForecaster (strategy = "drift")),
... ])
>>> pipe. fit (y_train, X_train) ForecastingPipeline(
... )
>>> y_pred = pipe. predict (fh = fh, X = X_test) Example 2: without strings
>>> pipe = ForecastingPipeline ([
... Imputer (method = "mean"),
... MinMaxScaler (),
... NaiveForecaster (strategy = "drift"),
... ]) Example 3: using the dunder method Note: * (= apply to y) has precedence over ** (= apply to X)
>>> forecaster = NaiveForecaster (strategy = "drift")
>>> imputer = Imputer (method = "mean")
>>> pipe = (imputer * MinMaxScaler ()) ** forecaster Example 3b: using the dunder method, alternative
>>> pipe = imputer ** MinMaxScaler () ** forecaster