DifferencingTransform

class DifferencingTransform(in_column: str, period: int = 1, order: int = 1, inplace: bool = True, out_column: Optional[str] = None)[source]

Bases: etna.transforms.base.ReversibleTransform

Calculate a time series differences.

During fit this transform can work with NaNs at the beginning of the segment, but fails when meets NaN inside the segment. During transform and inverse_transform there is no special treatment of NaNs.

Notes

To understand how transform works we recommend: Stationarity and Differencing

Create instance of DifferencingTransform.

Parameters
  • in_column (str) – name of processed column

  • period (int) – number of steps back to calculate the difference with, it should be >= 1

  • order (int) – number of differences to make, it should be >= 1

  • inplace (bool) –

    • if True, apply transformation inplace to in_column,

    • if False, add transformed column to dataset

  • out_column (Optional[str]) –

    • if set, name of added column, the final name will be ‘{out_column}’;

    • if isn’t set, name will be based on self.__repr__()

Raises
  • ValueError: – if period is not integer >= 1

  • ValueError: – if order is not integer >= 1

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.

fit(ts: etna.datasets.tsdataset.TSDataset) etna.transforms.math.differencing.DifferencingTransform[source]

Fit the transform.

Parameters

ts (etna.datasets.tsdataset.TSDataset) –

Return type

etna.transforms.math.differencing.DifferencingTransform

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 order parameter. Other parameters are expected to be set by the user.

Returns

Grid to tune.

Return type

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