AutoRegressivePipeline

class AutoRegressivePipeline(model: Union[etna.models.base.NonPredictionIntervalContextIgnorantAbstractModel, etna.models.base.NonPredictionIntervalContextRequiredAbstractModel, etna.models.base.PredictionIntervalContextIgnorantAbstractModel, etna.models.base.PredictionIntervalContextRequiredAbstractModel], horizon: int, transforms: Sequence[etna.transforms.base.Transform] = (), step: int = 1)[source]

Bases: etna.pipeline.mixins.ModelPipelinePredictMixin, etna.pipeline.mixins.ModelPipelineParamsToTuneMixin, etna.pipeline.mixins.SaveModelPipelineMixin, etna.pipeline.base.BasePipeline

Pipeline that make regressive models autoregressive.

Examples

>>> from etna.datasets import generate_periodic_df
>>> from etna.datasets import TSDataset
>>> from etna.models import LinearPerSegmentModel
>>> from etna.transforms import LagTransform
>>> classic_df = generate_periodic_df(
...     periods=100,
...     start_time="2020-01-01",
...     n_segments=4,
...     period=7,
...     sigma=3
... )
>>> df = TSDataset.to_dataset(df=classic_df)
>>> ts = TSDataset(df, freq="D")
>>> horizon = 7
>>> transforms = [
...     LagTransform(in_column="target", lags=list(range(1, horizon+1)))
... ]
>>> model = LinearPerSegmentModel()
>>> pipeline = AutoRegressivePipeline(model, horizon, transforms, step=1)
>>> _ = pipeline.fit(ts=ts)
>>> forecast = pipeline.forecast()
>>> pd.options.display.float_format = '{:,.2f}'.format
>>> forecast[:, :, "target"]
segment    segment_0 segment_1 segment_2 segment_3
feature       target    target    target    target
timestamp
2020-04-10      9.00      9.00      4.00      6.00
2020-04-11      5.00      2.00      7.00      9.00
2020-04-12      0.00      4.00      7.00      9.00
2020-04-13      0.00      5.00      9.00      7.00
2020-04-14      1.00      2.00      1.00      6.00
2020-04-15      5.00      7.00      4.00      7.00
2020-04-16      8.00      6.00      2.00      0.00

Create instance of AutoRegressivePipeline with given parameters.

Parameters
Inherited-members

Methods

backtest(ts, metrics[, n_folds, mode, ...])

Run backtest with the pipeline.

fit(ts)

Fit the AutoRegressivePipeline.

forecast([ts, prediction_interval, ...])

Make a forecast of the next points of a dataset.

load(path[, ts])

Load an object.

params_to_tune()

Get hyperparameter grid to tune.

predict(ts[, start_timestamp, ...])

Make in-sample predictions on dataset in a given range.

save(path)

Save the object.

set_params(**params)

Return new object instance with modified parameters.

to_dict()

Collect all information about etna object in dict.

Attributes

fit(ts: etna.datasets.tsdataset.TSDataset) etna.pipeline.autoregressive_pipeline.AutoRegressivePipeline[source]

Fit the AutoRegressivePipeline.

Fit and apply given transforms to the data, then fit the model on the transformed data.

Parameters

ts (etna.datasets.tsdataset.TSDataset) – Dataset with timeseries data

Returns

Fitted Pipeline instance

Return type

etna.pipeline.autoregressive_pipeline.AutoRegressivePipeline