Handling seasonality – seasonal dummies and Fourier series
In this recipe, we’ll describe how to deal with seasonality in time series using seasonal dummy variables and a Fourier series.
Getting ready
Seasonality represents repeatable patterns that recur over a given period, such as every year. Seasonality is an important piece of time series, and it is important to capture it. The consensus in the literature is that neural networks cannot capture seasonal effects optimally. The best way to model seasonality is by feature engineering or data transformation. One way to handle seasonality is to add extra information that captures the periodicity of patterns. This can be done with seasonal dummies or a Fourier series.
We start by preparing the data using the series_to_supervised
()
function:
train, test = train_test_split(series, test_size=0.2, shuffle=False) scaler = MinMaxScaler(feature_range=(-1, 1)) train_norm = scaler.fit_transform( ...