Models#
Module with models for time-series forecasting.
Basic usage#
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(df, freq="D")
>>> lag_transform = LagTransform(in_column="target", lags=[3, 4, 5])
>>> ts.fit_transform(transforms=[lag_transform])
>>> future_ts = ts.make_future(future_steps=3, transforms=[lag_transform])
>>> model = LinearPerSegmentModel()
>>> model.fit(ts)
LinearPerSegmentModel(fit_intercept = True, )
>>> forecast_ts = model.forecast(future_ts)
>>> forecast_ts is future_ts
True
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.
API details#
Base:
Interface for models that don't support prediction intervals and don't need context for prediction. |
|
Interface for models that don't support prediction intervals and need context for prediction. |
|
Interface for models that support prediction intervals and don't need context for prediction. |
|
Interface for models that support prediction intervals and need context for prediction. |
Naive models:
|
Seasonal moving average. |
|
MovingAverageModel averages previous series values to forecast future one. |
|
Naive model predicts t-th value of series with its (t - lag) value. |
|
Moving average model that uses exact previous dates to predict. |
Statistical models:
|
Class for holding auto arima model. |
|
Class for holding SARIMAX model. |
|
Holt-Winters' etna model. |
|
Holt etna model. |
|
Exponential smoothing etna model. |
|
Class for holding Prophet model. |
|
Class for holding segment interval TBATS model. |
|
Class for holding segment interval BATS model. |
|
Class for holding |
|
Class for holding |
|
Class for holding |
|
Class for holding |
|
Class for holding |
ML-models:
|
Class for holding Catboost model for all segments. |
|
Class for holding per segment Catboost model. |
|
Class holding |
|
Class holding per segment |
|
Class holding |
|
Class holding per segment |
|
Class for holding Sklearn model for all segments. |
|
Class for holding per segment Sklearn model. |
Native neural network models:
|
RNN based model on LSTM cell. |
|
MLPModel. |
|
DeepState model. |
|
Generic N-BEATS model. |
|
Interpretable N-BEATS model. |
|
PatchTS model using PyTorch layers. |
|
DeepAR based model on LSTM cell. |
|
TFT model. |
Utilities for DeepStateModel
|
Class to compose several State Space Models. |
Class for Level State Space Model. |
|
Class for Level-Trend State Space Model. |
|
|
Class for Seasonality State Space Model. |
Class for Daily Seasonality State Space Model. |
|
|
Class for Seasonality State Space Model. |
Class for Yearly Seasonality State Space Model. |
Neural network models based on pytorch_forecasting
:
|
Wrapper for |
|
Wrapper for |
Utilities for neural network models based on pytorch_forecasting
:
Builder for PytorchForecasting dataset. |