STLTransform

class STLTransform(in_column: str, period: int, model: Union[str, statsmodels.tsa.base.tsa_model.TimeSeriesModel] = 'arima', robust: bool = False, model_kwargs: Optional[Dict[str, Any]] = None, stl_kwargs: Optional[Dict[str, Any]] = None)[source]

Bases: etna.transforms.base.ReversiblePerSegmentWrapper

Transform that uses statsmodels.tsa.seasonal.STL to subtract season and trend from the data.

Warning

This transform can suffer from look-ahead bias. For transforming data at some timestamp it uses information from the whole train part.

Init STLTransform.

Parameters
  • in_column (str) – name of processed column

  • period (int) – size of seasonality

  • model (Union[str, statsmodels.tsa.base.tsa_model.TimeSeriesModel]) –

    model to predict trend, default options are:

    1. ”arima”: ARIMA(data, 1, 1, 0) (default)

    2. ”holt”: ETSModel(data, trend='add')

    Custom model should be a subclass of statsmodels.tsa.base.tsa_model.TimeSeriesModel and have method get_prediction (not just predict)

  • robust (bool) – flag indicating whether to use robust version of STL

  • model_kwargs (Optional[Dict[str, Any]]) – parameters for the model like in statsmodels.tsa.seasonal.STLForecast

  • stl_kwargs (Optional[Dict[str, Any]]) – additional parameters for statsmodels.tsa.seasonal.STLForecast

Inherited-members

Methods

fit(ts)

Fit the transform.

fit_transform(ts)

Fit and transform TSDataset.

get_regressors_info()

Return the list with regressors created by the transform.

inverse_transform(ts)

Inverse transform TSDataset.

load(path)

Load an object.

params_to_tune()

Get default grid for tuning hyperparameters.

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.

transform(ts)

Transform TSDataset inplace.

get_regressors_info() List[str][source]

Return the list with regressors created by the transform.

Return type

List[str]

params_to_tune() Dict[str, etna.distributions.distributions.BaseDistribution][source]

Get default grid for tuning hyperparameters.

This grid tunes parameters: model, robust. Other parameters are expected to be set by the user.

Returns

Grid to tune.

Return type

Dict[str, etna.distributions.distributions.BaseDistribution]