Important This Guide assumes basic knowledge on the NeuralForecast library. For a minimal example visit the Getting Started guide.You can run these experiments using GPU with Google Colab.
df
dataframe contains the target and exogenous variables past
information to train the model. The unique_id
column identifies the
markets, ds
contains the datestamps, and y
the electricity price.
Include both historic and future temporal variables as columns. In this
example, we are adding the system load (system_load
) as historic data.
For future variables, we include a forecast of how much electricity will
be produced (gen_forecast
) and day of week (week_day
). Both the
electricity system demand and offer impact the price significantly,
including these variables to the model greatly improve performance, as
we demonstrate in Olivares et al. (2022).
The distinction between historic and future variables will be made later
as parameters of the model.
unique_id | ds | y | gen_forecast | system_load | week_day | |
---|---|---|---|---|---|---|
0 | FR | 2015-01-01 00:00:00 | 53.48 | 76905.0 | 74812.0 | 3 |
1 | FR | 2015-01-01 01:00:00 | 51.93 | 75492.0 | 71469.0 | 3 |
2 | FR | 2015-01-01 02:00:00 | 48.76 | 74394.0 | 69642.0 | 3 |
3 | FR | 2015-01-01 03:00:00 | 42.27 | 72639.0 | 66704.0 | 3 |
4 | FR | 2015-01-01 04:00:00 | 38.41 | 69347.0 | 65051.0 | 3 |
Tip Calendar variables such as day of week, month, and year are very useful to capture long seasonalities.
static_df
dataframe. In this
example, we are using one-hot encoding of the electricity market. The
static_df
must include one observation (row) for each unique_id
of
the df
dataframe, with the different statics variables as columns.
unique_id | market_0 | market_1 | |
---|---|---|---|
0 | FR | 1 | 0 |
1 | BR | 0 | 1 |
futr_exog_list
,
hist_exog_list
, and stat_exog_list
. We also set horizon
as 24 to
produce the next day hourly forecasts, and set input_size
to use the
last 5 days of data as input.
Tip When including exogenous variables always use a scaler by setting thescaler_type
hyperparameter. The scaler will scale all the temporal features: the target variabley
, historic and future variables.
Important Make sure future and historic variables are correctly placed. Defining historic variables as future variables will lead to data leakage.Next, pass the datasets to the
df
and static_df
inputs of the fit
method.
futr_df
) with the unique_id
, ds
, and future exogenous variables.
There is no need to add the target variable y
and historic variables
as they won’t be used by the model.
unique_id | ds | gen_forecast | week_day | |
---|---|---|---|---|
0 | FR | 2016-11-01 00:00:00 | 49118.0 | 1 |
1 | FR | 2016-11-01 01:00:00 | 47890.0 | 1 |
2 | FR | 2016-11-01 02:00:00 | 47158.0 | 1 |
3 | FR | 2016-11-01 03:00:00 | 45991.0 | 1 |
4 | FR | 2016-11-01 04:00:00 | 45378.0 | 1 |
Important Make sureFinally, use thefutr_df
has informations for the entire forecast horizon. In this example, we are forecasting 24 hours ahead, sofutr_df
must have 24 rows for each time series.
predict
method to forecast the day-ahead prices.
unique_id | ds | NHITS | BiTCN | |
---|---|---|---|---|
0 | BE | 2016-11-01 00:00:00 | 35.297050 | 41.957176 |
1 | BE | 2016-11-01 01:00:00 | 32.350044 | 39.419579 |
2 | BE | 2016-11-01 02:00:00 | 30.091702 | 36.313972 |
3 | BE | 2016-11-01 03:00:00 | 27.317764 | 34.002922 |
4 | BE | 2016-11-01 04:00:00 | 24.316488 | 35.002541 |
df
).static_df
dataframe.futr_df
) to the predict
method.