piekarsky / Short-Term-Electricity-Price-Forecasting-at-the-Polish-Day-Ahead-Market

Modeling time series of electricity spot prices using Deep Learning.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Short Term Electricity Price Forecasting at the Polish Day-Ahead-Market

Table of Contents

Overview

This repository contains the experimental source code for short term (24 hour advance) electricity price forecasting at the Polish SPOT (Day-Ahead-Market) market including RNN, LSTM, GRU, MLP and Prophet models.
Models using both the delayed exogenous variable and the endogenous variables from the forecast period and their delayed values for forecasting.

About the dataset

Data includes over 26200 hourly observations of electricity prices (PLN/MWh) from January 2018 to December 2020 at the Polish Day-Ahead-Market. Course of this modeled time series of electricity prices is shown in the figure below.

The analysis of the time series of electricity prices confirmed the one described in the literature auto-regressive nature of this process. The figure below illustrates autocorrelation function of the modeled time series, on which it can be seen that the price of electricity at a given hour is significantly affected by the value of the electricity price from the past corresponding to a delay of multiples of 24 hours.

A specific feature of electricity prices resulting from the daily, weekly and annual rhythm is the variability of its level over time. The annual cycle follows from differences in energy demand in different seasons of the year, which makes that energy demand is higher in winter and lower in winter summer months. Electricity prices within the weekly cycle varies with energy demand on weekdays and weekends. The figure below illustrates the weekly course of electricity prices. There are visible differences in the course of electricity prices on Saturdays and Sundays compared to other days of the week, where the course of electricity prices is similar.

The daily volatility of electricity prices is influenced by the increased demand for energy, which occurs between 6 a.m. and 9 p.m. and translates into a higher price of electricity in this time (figure below). Short-term fluctuations in electricity prices can result from weather factors that determine the scale of energy production in wind energy sources.

Modeling electricity prices

Features used to generate forecasts include autocorrelated lagged electricity prices, energy demand, generation energy from wind sources, time of the day and holidays. Data with energy demand and generation energy from wind sources are published once a day for the coming 24 hour period (published sufficiently in advance to be used in the model).

Minimum delay values can be known and used in the model represent the electricity price 24 hours ago. The model uses delayed electricity price lags ranging between 7 days (being multiples of 24 hours) and 14 days, as well respective values ​​of energy demand and generation of energy from wind sources.

For time of the day and holidays dummy coding was used. The dummy variable 1 was set for the period between 6 a.m. and 9 p.m., where it is visible higher electricity prices, otherwise 0. Due to the fact that the time series of electricity prices in the analyzed period did not show annual seasonality, the variables defining the annual cycle were omitted.

The data from January 2018 to December 2020 have been splitted as follows:
– training set: data from January 2018 to June 2020
– validation set: data from July to September 2020
– test set: data from October to December 2020
Splitting the dataset in this way is close to the ratio of 85-7.5-7.5.

Results

According to the table below, RNN outperformed the other models.

Model MAE [PLN/MWh] ↓ RMSE [PLN/MWh] ↓ MAPE [%] ↓ R Squared [-] ↑
Prophet 16.9 21.8 7.54 0.86
MLP 16.61 21.23 7.32 0.87
RNN (Vanilla) 16.15 20.84 6.94 0.87
LSTM 17.15 22.5 7.26 0.85
GRU 17 22.12 7.32 0.86

In the figures below shows the actual and predicted electricity price at the Day Ahead Market in the sample period from test set. Forecasts have been generated by the model based on the Vanilla RNN, which was characterized by the highest accuracy of electricity price predictions in the test period.

The course of the actual and predicted electricity price generated by the Vanilla RNN in October 2020.

The course of the actual and predicted electricity price generated by the Vanilla RNN in November 2020.

The course of the actual and predicted electricity price generated by the Vanilla RNN in December 2020.

The course of the actual and predicted electricity price generated by the Vanilla RNN in the 48th week of 2020.

Run the Codes

If you want to train RNN

python main.py --model 'rnn'

If you want to train GRU with 2 hidden layers and a learning rate of 0.05

python main.py --model 'gru' --num_layers 2 --lr 0.05

Development Environment

- Windows 10 Home
- Python 3.7.3
- torch 1.8.1
- NVIDIA GFORCE RTX 2060

About

Modeling time series of electricity spot prices using Deep Learning.

License:GNU General Public License v3.0


Languages

Language:Jupyter Notebook 96.6%Language:Python 3.4%