Models

Models are used to make predictions. Let’s look at the basic example of usage:

>>> import pandas as pd
>>> from etna.datasets import TSDataset, generate_ar_df
>>> from etna.transforms import LagTransform
>>> from etna.models import LinearPerSegmentModel
>>>
>>> df = generate_ar_df(periods=100, start_time="2021-01-01", ar_coef=[1/2], n_segments=2)
>>> ts = TSDataset(TSDataset.to_dataset(df), "D")
>>> lag_transform = LagTransform(in_column="target", lags=[3, 4, 5])
>>> ts.fit_transform(transforms=[lag_transform])
>>> future_ts = ts.make_future(3)
>>> model = LinearPerSegmentModel()
>>> model.fit(ts)
LinearPerSegmentModel(fit_intercept = True, normalize = False, )
>>> forecast_ts = model.forecast(future_ts)
segment                 segment_0  ... segment_1
feature    regressor_target_lag_3  ...    target
timestamp                          ...
2021-04-11              -0.090673  ...  0.286764
2021-04-12              -0.665337  ...  0.295589
2021-04-13               0.365363  ...  0.374554
[3 rows x 8 columns]

There is a key note to mention: future_ts and forecast_ts are the same objects. Method forecast only fills ‘target’ columns in future_ts and return reference to it.

>>> forecast_ts is future_ts
True

Details and available models

See the API documentation for further details on available models:

etna.models.autoarima.AutoARIMAModel(**kwargs)

Class for holding auto arima model.

etna.models.base.BaseAdapter()

Base class for models adapter.

etna.models.catboost.CatBoostModelMultiSegment([...])

Class for holding Catboost model for all segments.

etna.models.catboost.CatBoostModelPerSegment([...])

Class for holding per segment Catboost model.

etna.models.nn.deepar.DeepARModel([...])

Wrapper for pytorch_forecasting.models.deepar.DeepAR.

etna.models.linear.ElasticMultiSegmentModel([...])

Class holding sklearn.linear_model.ElasticNet for all segments.

etna.models.linear.ElasticPerSegmentModel([...])

Class holding per segment sklearn.linear_model.ElasticNet.

etna.models.holt_winters.HoltModel([...])

Holt etna model.

etna.models.holt_winters.HoltWintersModel([...])

Holt-Winters' etna model.

etna.models.linear.LinearMultiSegmentModel([...])

Class holding sklearn.linear_model.LinearRegression for all segments.

etna.models.linear.LinearPerSegmentModel([...])

Class holding per segment sklearn.linear_model.LinearRegression.

etna.models.base.Model()

Class for holding specific models - autoregression and simple regressions.

etna.models.moving_average.MovingAverageModel([...])

MovingAverageModel averages previous series values to forecast future one.

etna.models.naive.NaiveModel([lag])

Naive model predicts t-th value of series with its (t - lag) value.

etna.models.base.PerSegmentModel(base_model)

Class for holding specific models for per-segment prediction.

etna.models.prophet.ProphetModel([growth, ...])

Class for holding Prophet model.

etna.models.sarimax.SARIMAXModel([order, ...])

Class for holding Sarimax model.

etna.settings.SETTINGS

etna settings.

etna.settings.SETTINGS

etna settings.

etna.models.seasonal_ma.SeasonalMovingAverageModel([...])

Seasonal moving average.

etna.models.holt_winters.SimpleExpSmoothingModel([...])

Exponential smoothing etna model.

etna.models.sklearn.SklearnMultiSegmentModel(...)

Class for holding Sklearn model for all segments.

etna.models.sklearn.SklearnPerSegmentModel(...)

Class for holding per segment Sklearn model.

etna.models.nn.tft.TFTModel([max_epochs, ...])

Wrapper for pytorch_forecasting.models.temporal_fusion_transformer.TemporalFusionTransformer.