assemble_pipelines¶
- assemble_pipelines(models: Union[etna.models.base.NonPredictionIntervalContextIgnorantAbstractModel, etna.models.base.NonPredictionIntervalContextRequiredAbstractModel, etna.models.base.PredictionIntervalContextIgnorantAbstractModel, etna.models.base.PredictionIntervalContextRequiredAbstractModel, Sequence[Union[etna.models.base.NonPredictionIntervalContextIgnorantAbstractModel, etna.models.base.NonPredictionIntervalContextRequiredAbstractModel, etna.models.base.PredictionIntervalContextIgnorantAbstractModel, etna.models.base.PredictionIntervalContextRequiredAbstractModel]]], transforms: Sequence[Union[etna.transforms.base.Transform, Sequence[Optional[etna.transforms.base.Transform]]]], horizons: Union[int, Sequence[int]]) List[etna.pipeline.pipeline.Pipeline] [source]¶
Create pipelines with broadcasting from models, transforms and horizons.
After broadcasting we have:
models:
\[M_1, \dots, M_n\]transforms:
\[(T_{1,1}, \dots, T_{1,n}), ... (T_{k,1}, \dots, T_{k,n})\]horizons:
\[H_1, \dots, H_n\]We expect that in input shape of size n can be reduced to size 1 or even become a scalar value. During broadcasting we copy this value n times.
- Parameters
models (Union[etna.models.base.NonPredictionIntervalContextIgnorantAbstractModel, etna.models.base.NonPredictionIntervalContextRequiredAbstractModel, etna.models.base.PredictionIntervalContextIgnorantAbstractModel, etna.models.base.PredictionIntervalContextRequiredAbstractModel, Sequence[Union[etna.models.base.NonPredictionIntervalContextIgnorantAbstractModel, etna.models.base.NonPredictionIntervalContextRequiredAbstractModel, etna.models.base.PredictionIntervalContextIgnorantAbstractModel, etna.models.base.PredictionIntervalContextRequiredAbstractModel]]]) – Instance of Sequence of models
transforms (Sequence[Union[etna.transforms.base.Transform, Sequence[Optional[etna.transforms.base.Transform]]]]) – Sequence of the transforms
horizons (Union[int, Sequence[int]]) – Sequence of horizons
- Returns
list of pipelines
- Raises
ValueError: – If the length of models sequence not equals to length of horizons sequence.
- Return type
Examples
>>> from etna.pipeline import assemble_pipelines >>> from etna.models import LinearPerSegmentModel, NaiveModel >>> from etna.transforms import DateFlagsTransform, AddConstTransform, LagTransform >>> assemble_pipelines(models=LinearPerSegmentModel(), transforms=[LagTransform(in_column='target', lags=[1]), AddConstTransform(in_column='target', value=1)], horizons=[1,2,3]) [Pipeline(model = LinearPerSegmentModel(fit_intercept = True, ), transforms = [LagTransform(in_column = 'target', lags = [1], out_column = None, ), AddConstTransform(in_column = 'target', value = 1, inplace = True, out_column = None, )], horizon = 1, ), Pipeline(model = LinearPerSegmentModel(fit_intercept = True, ), transforms = [LagTransform(in_column = 'target', lags = [1], out_column = None, ), AddConstTransform(in_column = 'target', value = 1, inplace = True, out_column = None, )], horizon = 2, ), Pipeline(model = LinearPerSegmentModel(fit_intercept = True, ), transforms = [LagTransform(in_column = 'target', lags = [1], out_column = None, ), AddConstTransform(in_column = 'target', value = 1, inplace = True, out_column = None, )], horizon = 3, )] >>> assemble_pipelines(models=[LinearPerSegmentModel(), NaiveModel()], transforms=[LagTransform(in_column='target', lags=[1]), [AddConstTransform(in_column='target', value=1), DateFlagsTransform()]], horizons=[1,2]) [Pipeline(model = LinearPerSegmentModel(fit_intercept = True, ), transforms = [LagTransform(in_column = 'target', lags = [1], out_column = None, ), AddConstTransform(in_column = 'target', value = 1, inplace = True, out_column = None, )], horizon = 1, ), Pipeline(model = NaiveModel(lag = 1, ), transforms = [LagTransform(in_column = 'target', lags = [1], out_column = None, ), DateFlagsTransform(day_number_in_week = True, day_number_in_month = True, day_number_in_year = False, week_number_in_month = False, week_number_in_year = False, month_number_in_year = False, season_number = False, year_number = False, is_weekend = True, special_days_in_week = (), special_days_in_month = (), out_column = None, )], horizon = 2, )]