Transformer
FourierFeatures
Fourier Features for time series seasonality.
Quickstart
python
from sktime.transformations.fourier import FourierFeatures
estimator = FourierFeatures(sp_list: list [float ], fourier_terms_list: list [int ], freq: str | None=None, keep_original_columns: bool | None=False)Parameters(4)
- sp_listList[float and/or str]
List of seasonal periods. Can be defined with the following options:
- float: Periodicity defined as number of timesteps since the beginning of the data seen in
fit. - string: Periodicity defined as a column name in X that contains the \(t/sp\) values.
- string: Periodicity defined as a pandas period alias: https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#period-aliases
- float: Periodicity defined as number of timesteps since the beginning of the data seen in
- fourier_terms_listList[int]
- List of number of fourier terms (\(K\)) per corresponding (\(sp\)); each \(K\) matches to one \(sp\) of the sp_list. For example, if sp_list = [7, “Y”] and fourier_terms_list = [3, 9], the seasonality of 7 timesteps will have 3 sin_sp_k and 3 cos_sp_k fourier terms and the yearly seasonality “Y” will have 9 sin_sp_k and 9 cos_sp_k fourier terms.
- freqstr, optional, default = None
Only used when X has a pd.DatetimeIndex without a specified frequency. Specifies the frequency of the index of your data. The string should match a pandas offset alias:
https://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases
- keep_original_columnsboolean, optional, default=False
Keep original columns in X passed to
.transform()
Examples
>>> from sktime.transformations.fourier import FourierFeatures
>>> from sktime.datasets import load_airline
>>> y = load_airline ()
>>> transformer = FourierFeatures (sp_list = [12, "Y" ], fourier_terms_list = [4, 1 ])
>>> y_hat = transformer. fit_transform (y)References
- [1 ] Hyndsight - Forecasting with long seasonal periods: https://robjhyndman.com/hyndsight/longseasonality/ [2 ] Hyndman, R.J., & Athanasopoulos, G. (2021) Forecasting: principles and practice, 3rd edition, OTexts: Melbourne, Australia. OTexts.com/fpp3. Accessed on August 14th 2022. [3 ] https://pkg.robjhyndman.com/forecast/reference/fourier.html