Object
Pipeline
Implementation of a Graphpipeline.
Quickstart
python
from sktime.pipeline.pipeline import Pipeline
estimator = Pipeline(steps=None)Parameters(1)
- param stepsA list of dicts that specify the steps of the pipeline. Further
steps can be added by using add_step method. The dict requires the following keys:
- skobject:
sktimeobject, the skobject that should be added to thepipeline
- skobject:
Examples
>>> from sktime.classification.distance_based import KNeighborsTimeSeriesClassifier
>>> from sktime.datasets import load_arrow_head, load_longley
>>> from sktime.split import temporal_train_test_split
>>> from sktime.forecasting.naive import NaiveForecaster
>>> from sktime.pipeline import Pipeline
>>> from sktime.transformations.compose import Id
>>> from sktime.transformations.boxcox import BoxCoxTransformer
>>> from sktime.transformations.exponent import ExponentTransformer Example 1: Simple sequential pipeline of transformers using the generalized non-sequential pipeline implementation
>>> y, X = load_longley ()
>>> general_pipeline = Pipeline ()
>>> for step in [
... { "skobject": ExponentTransformer (), "name": "exp", "edges": { "X": "X" }},
... { "skobject": BoxCoxTransformer (), "name": "box", "edges": { "X": "exp" }},
... ]:
... general_pipeline = general_pipeline. add_step (** step)
>>> general_pipeline. fit (X = X)
>>> result_general = general_pipeline. transform (X) Example 2: Classification sequential pipeline using the generalized non-sequential pipeline implementation
>>> X, y = load_arrow_head (split = "train", return_X_y = True)
>>> general_pipeline = Pipeline ()
>>> for step in [
... { "skobject": ExponentTransformer (), "name": "exp", "edges": { "X": "X" }},
... { "skobject": KNeighborsTimeSeriesClassifier (),
... "name": "knnclassifier",
... "edges": { "X": "exp", "y": "y" }}]:
... general_pipeline = general_pipeline. add_step (** step)
>>> general_pipeline. fit (X = X, y = y)
>>> result_general = general_pipeline. predict (X) Example 3: Forecasting pipeline with exogenous features using the generalized non-sequential pipeline implementation
>>> y, X = load_longley ()
>>> y_train, y_test, X_train, X_test = temporal_train_test_split (y, X)
>>> general_pipeline = Pipeline ()
>>> for step in [
... { "skobject": ExponentTransformer (), "name": "exp", "edges": { "X": "X" }},
... { "skobject": NaiveForecaster (),
... "name": "SARIMAX",
... "edges": { "X": "exp", "y": "y" }}]:
... general_pipeline = general_pipeline. add_step (** step)
>>> general_pipeline. fit (y = y_train, X = X_train, fh = [1, 2, 3, 4 ])
>>> result_general = general_pipeline. predict (X = X_test) Acknowledgements This graphical pipeline is inspired by pyWATTS that is developed by the Institute for Automation and Applied Informatics (IAI) at Karlsruhe Institute of Technology. The implementation is supported by IAI and the author benHeid is funded by HelmholtzAI. Furthermore, we also want to credit @ViktorKaz for his independent pipeline design that is similar to this one.References
- [1 ] @article{heidrich2021pywatts, title={pyWATTS: Python workflow automation tool for time series}, author={Heidrich, Benedikt and Bartschat, Andreas and Turowski, Marian and Neumann, Oliver and Phipps, Kaleb and Meisenbacher, Stefan and Schmieder, Kai and Ludwig, Nicole and Mikut, Ralf and Hagenmeyer, Veit}, journal={arXiv preprint arXiv:2106.10157}, year={2021} }