-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
_make_pipeline.py
53 lines (41 loc) · 1.73 KB
/
_make_pipeline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""Pipeline making utility."""
# copyright: sktime developers, BSD-3-Clause License (see LICENSE file).
__author__ = ["fkiraly"]
def make_pipeline(*steps):
"""Create a pipeline from estimators of any type.
Parameters
----------
steps : tuple of sktime estimators
in same order as used for pipeline construction
Returns
-------
pipe : sktime pipeline containing steps, in order
always a descendant of BaseObject, precise object determined by scitype
equivalent to result of step[0] * step[1] * ... * step[-1]
Examples
--------
Example 1: forecaster pipeline
>>> from sktime.pipeline import make_pipeline
>>> from sktime.transformations.series.exponent import ExponentTransformer
>>> from sktime.forecasting.trend import PolynomialTrendForecaster
>>> pipe = make_pipeline(ExponentTransformer(), PolynomialTrendForecaster())
>>> type(pipe).__name__
'TransformedTargetForecaster'
Example 2: classifier pipeline
>>> from sktime.pipeline import make_pipeline
>>> from sktime.transformations.series.exponent import ExponentTransformer
>>> from sktime.classification.distance_based import KNeighborsTimeSeriesClassifier
>>> pipe = make_pipeline(ExponentTransformer(), KNeighborsTimeSeriesClassifier())
>>> type(pipe).__name__
'ClassifierPipeline'
Example 3: transformer pipeline
>>> from sktime.pipeline import make_pipeline
>>> from sktime.transformations.series.exponent import ExponentTransformer
>>> pipe = make_pipeline(ExponentTransformer(), ExponentTransformer())
>>> type(pipe).__name__
'TransformerPipeline'
"""
pipe = steps[0]
for i in range(1, len(steps)):
pipe = pipe * steps[i]
return pipe