FourierTransform

class FourierTransform(period: float, order: Optional[int] = None, mods: Optional[Sequence[int]] = None, out_column: Optional[str] = None)[source]

Bases: etna.transforms.base.IrreversibleTransform, etna.transforms.base.FutureMixin

Adds fourier features to the dataset.

Notes

To understand how transform works we recommend: Fourier series.

  • Parameter period is responsible for the seasonality we want to capture.

  • Parameters order and mods define which harmonics will be used.

Parameter order is a more user-friendly version of mods. For example, order=2 can be represented as mods=[1, 2, 3, 4] if period > 4 and as mods=[1, 2, 3] if 3 <= period <= 4.

Create instance of FourierTransform.

Parameters
  • period (float) –

    the period of the seasonality to capture in frequency units of time series;

    period should be >= 2

  • order (Optional[int]) –

    upper order of Fourier components to include;

    order should be >= 1 and <= ceil(period/2))

  • mods (Optional[Sequence[int]]) –

    alternative and precise way of defining which harmonics will be used, for example mods=[1, 3, 4] means that sin of the first order and sin and cos of the second order will be used;

    mods should be >= 1 and < period

  • out_column (Optional[str]) –

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

    • if don’t set, name will be transform.__repr__(), repr will be made for transform that creates exactly this column

Raises
  • ValueError: – if period < 2

  • ValueError: – if both or none of order, mods is set

  • ValueError: – if order is < 1 or > ceil(period/2)

  • ValueError: – if at least one mod is < 1 or >= period

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.

If self.order is set then 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]