# Forecasting Electricity Prices: A Machine Learning Approach

^{1}

^{2}

^{*}

## Abstract

**:**

## 1. Introduction

_{2}coupons from the largest EU energy market, we show that the proposed model provides more accurate predictions of future electricity prices compared to extant prediction methods.

## 2. Challenges of Electricity Price Forecasting

## 3. Method

_{1}, T

_{2}: R

^{n}→ R, the geometric semantic crossover returns the real function T

_{XO}= (T

_{1}· T

_{R}) + ((1 − T

_{R}) · T

_{2}), where T

_{R}is a random function such that T

_{R}: R

^{n}→ [0; 1].

_{R}when producing values in [0; 1], we make use of the sigmoid function TR = 1 / (1 + e

^{-Trand}), where T

_{rand}is a random tree with no constraints on the output values.

^{n}→ R, the geometric semantic mutation with mutation step ms returns the real function T

_{M}= T + ms · (T

_{R1}− T

_{R2}), where T

_{R1}and T

_{R2}are random real functions. Henceforth, we refer to the GP algorithm that uses GSOs as Geometric Semantic Genetic Programming (GSGP).

Algorithm 1: The GP algorithm. |

1: Population ß InitializePopulation(population_size, problem_variables) |

2: EvaluatePopulation(Population) |

3: S_best ß GetBestSolution(Population) |

4: num_iterations ß 0 |

5: While (num_iteration < num_generations) |

6: Children_pop ß Ø |

7: Children_pop ß Children_pop U S_best |

8: While (Size(Children_pop) < population_size) |

9: Operator ß SelectGeneticOperator(Crossover_Rate, Mutation_Rate) |

10: If (Operator == CrossoverOperator) |

11: Parent_1 ß SelectParent(Population) |

12: Parent_2 ß SelectParent(Population) |

13: Child = GSC(Parent_1,Parent_2) |

14: Children_pop = Children_pop U Child |

15: ElseIf (Operator == MutationOperator) |

16: Parent_1 ß SelectParent(Population) |

17: Child = LSGSM(Parent_1) |

18: Children_pop = Children_pop U child |

19: Else |

20: Parent_1 ß SelectParent(Population) |

21: Children_pop = Children_pop U parent_1 |

22: End |

23: End |

24: EvaluatePopulation(Children_pop) |

25: S_bset ß GetBestSolution(Children_pop) |

27: Population ß Children_pop |

28: num_iteration ß num_iteration + 1 |

29: End |

30: Return (S_best) |

## 4. Experimental Phase

#### 4.1. Data

_{0}), the crude oil spot price in USD per barrel for EU was used [49]. Apart from alternative energy sources, the EEX EU Emission Allowances have also been taken into consideration (variable X

_{1}) as the spot EU emissions allowance in price per EUR/tCO

_{2}[50]. Variables X

_{2}through X

_{15}relate to the weather conditions and include air temperature, air density, ground temperature, air pressure, relative humidity, wind speed, maximum intraday air temperature, minimum intraday air temperature, minimum intraday air temperature at ground level, maximum intraday wind speed, next-day precipitation of rain to cover a horizontal ground surface, next day precipitation of snow to cover a horizontal ground surface, sunshine duration, and snow depth. The data for the weather conditions in Munich, Germany were obtained from the online data source “Deutscher Wetterdienst” [51]. All the variables were normalized and are dimensionless. Thus, it is possible to combine all variables without considering their different units of measurement. Table 1 provides a list of all variables used in this study.

#### 4.2. Experimental Settings and Results for GP-Based Systems

^{−11}for the training MAE and 8.6632 × 10

^{−7}for the test MAE) confirm that LSGS is able to outperform GSGP by producing solutions with a significantly smaller MAE than the latter system.

#### 4.3. Comparison with Other State-of-the-Art Machine Learning Techniques

#### 4.4. Interpretability of the Models

## 5. Discussion

_{0}, x

_{1}, x

_{4}, x

_{6}, and x

_{7}are the main variables used by the system to forecast the spot energy price. Our model shows that the spot electricity price depends on the crude oil spot price (x

_{0}), the settlement price EUR/t CO

_{2}(x

_{1}), ground temperature (x

_{4}), relative humidity (x

_{6}), and wind speed (x

_{7}). Interestingly, variables x

_{0}, x

_{1}, and x

_{4}are used in the primary factor of all the models obtained at the end of the experimental phase. On the other hand, the variables from x

_{8}to x

_{13}are never used.

## 6. Conclusions

## Author Contributions

## Funding

## Conflicts of Interest

## List of Acronyms

AI | Artificial Intelligence |

GP | Genetic Programming |

GSC | Geometric Semantic Crossover |

GSGP | Geometric Semantic Genetic Programming |

GSM | Geometric Semantic Mutation |

GSOs | Geometric Semantic Operators |

ISO | Isotonic Regression |

LIN | Linear Regression |

LSGP | Geometric Semantic Genetic Programming with Local Search |

LSGSM | Geometric Semantic Mutation with Local Search |

MAE | Mean Absolute Error |

NN | Multilayer Perceptron trained with Backpropagation |

OLS | Ordinary Least Square regression |

RBF | Radial Basis Function Network |

SQ | Least Square Regression |

STGP | Standard Genetic Programming |

SVM | Support Vector Machine (with polynomial kernel) |

SVM2 | Support Vector Machine (with polynomial kernel of second degree) |

## References

- Pinto, T.; Barreto, J.; Praça, I.; Sousa, T.M.; Vale, Z.; Pires, E.S. Six thinking hats: A novel metalearner for intelligent decision support in electricity markets. Decis. Support Syst.
**2015**, 79, 1–11. [Google Scholar] [CrossRef] - Gareta, R.; Romeo, L.M.; Gil, A. Forecasting of electricity prices with neural networks. Energy Convers. Manag.
**2006**, 47, 1770–1778. [Google Scholar] [CrossRef] - Amjady, N.; Hemmati, M. Energy price forecasting—Problems and proposals for such predictions. IEEE Power Energy Mag.
**2006**, 4, 20–29. [Google Scholar] [CrossRef] - Bastian, J.; Zhu, J.; Banunarayanan, V.; Mukerji, R. Forecasting energy prices in a competitive market. IEEE Comput. Appl. Power
**1999**, 12, 40–45. [Google Scholar] [CrossRef] - Aggarwal, S.K.; Saini, L.M.; Kumar, A. Electricity price forecasting in deregulated markets: A review and evaluation. Int. J. Electr. Power Energy Syst.
**2009**, 31, 13–22. [Google Scholar] - Weron, R. Electricity price forecasting: A review of the state-of-the-art with a look into the future. Int. J. Forecast.
**2014**, 30, 1030–1081. [Google Scholar] [CrossRef] [Green Version] - Huang, W.; Nakamori, Y.; Wang, S.-Y. Forecasting stock market movement direction with support vector machine. Comput. Oper. Res.
**2005**, 32, 2513–2522. [Google Scholar] - Aneiros, G.; Vilar, J.; Raña, P. Short-term forecast of daily curves of electricity demand and price. Int. J. Electr. Power Energy Syst.
**2016**, 80, 96–108. [Google Scholar] - Hassler, M. Heuristic decision rules for short-term trading of renewable energy with co-located energy storage. Comput. Oper. Res.
**2017**, 83, 199–213. [Google Scholar] - Wang, X.; Tang, L. A machine-learning based memetic algorithm for the multi-objective permutation flowshop scheduling problem. Comput. Oper. Res
**2017**, 79, 60–77. [Google Scholar] - Crespo Cuaresma, J.; Hlouskova, J.; Kossmeier, S.; Obersteiner, M. Forecasting electricity spot-prices using linear univariate time-series models. Appl. Energy
**2004**, 77, 87–106. [Google Scholar] [CrossRef] - Nowotarski, J.; Raviv, E.; Trück, S.; Weron, R. An empirical comparison of alternative schemes for combining electricity spot price forecasts. Energy Econ.
**2014**, 46, 395–412. [Google Scholar] [CrossRef] - Nowotarski, J.; Weron, R. Computing electricity spot price prediction intervals using quantile regression and forecast averaging. Comput. Stat.
**2014**, 30, 791–803. [Google Scholar] [CrossRef] [Green Version] - Weron, R.; Misiorek, A. Forecasting spot electricity prices: A comparison of parametric and semiparametric time series models. Int. J. Forecast.
**2008**, 24, 744–763. [Google Scholar] [CrossRef] [Green Version] - Conejo, A.J.; Plazas, M.A.; Espinola, R.; Molina, A.B. Day-ahead electricity price forecasting using the wavelet transform and ARIMA models. IEEE Trans. Power Syst.
**2005**, 20, 1035–1042. [Google Scholar] [CrossRef] - Li, G.; Liu, C.C.; Mattson, C.; Lawarrée, J. Day-Ahead Electricity Price Forecasting in a Grid Environment. IEEE Trans. Power Syst.
**2007**, 22, 266–274. [Google Scholar] [CrossRef] - Li, X.R.; Yu, C.W.; Ren, S.Y.; Chiu, C.H.; Meng, K. Day-ahead electricity price forecasting based on panel cointegration and particle filter. Electr. Power Syst. Res.
**2013**, 95, 66–76. [Google Scholar] [CrossRef] - Singhal, D.; Swarup, K.S. Electricity price forecasting using artificial neural networks. Int. J. Electr. Power Energy Syst.
**2011**, 33, 550–555. [Google Scholar] - Yamin, H.Y.; Shahidehpour, S.M.; Li, Z. Adaptive short-term electricity price forecasting using artificial neural networks in the restructured power markets. Int. J. Electr. Power Energy Syst.
**2004**, 26, 571–581. [Google Scholar] - Azadeh, A.; Moghaddam, M.; Mahdi, M.; Seyedmahmoudi, S.H. Optimum Long-Term Electricity Price Forecasting in Noisy and Complex Environments. Energy Sources Part B Econ. Plan. Policy
**2013**, 8, 235–244. [Google Scholar] [CrossRef] - Papadimitriou, T.; Gogas, P.; Stathakis, E. Forecasting energy markets using support vector machines. Energy Econ.
**2014**, 44, 135–142. [Google Scholar] [CrossRef] - Pao, H.-T. Forecasting electricity market pricing using artificial neural networks. Energy Convers. Manag.
**2007**, 48, 907–912. [Google Scholar] [CrossRef] - Huisman, R. The influence of temperature on spike probability in day-ahead power prices. Energy Econ.
**2008**, 30, 2697–2704. [Google Scholar] [CrossRef] [Green Version] - Hong, T.; Pinson, P.; Fan, S.; Zareipour, H.; Troccoli, A.; Hyndman, R.J. Probabilistic energy forecasting: Global Energy Forecasting Competition 2014 and beyond. Int. J. Forecast.
**2016**, 32, 896–913. [Google Scholar] [CrossRef] [Green Version] - Kialashaki, A.; Reisel, J.R. Forecasting United States' industrial sector energy demand using artificial neural networks. Int. J. Energy Stat.
**2014**, 2, 207–226. [Google Scholar] [CrossRef] - Koza, J.R. Introduction to genetic programming tutorial: From the basics to human-competitive results. In Proceedings of the 12th Annual Conference Companion on Genetic and Evolutionary Computation; ACM: Portland, OR, USA, 2010; pp. 2137–2262. [Google Scholar]
- Preece, A. Asking ‘Why’ in AI: Explainability of intelligent systems—Perspectives and challenges. Intell. Syst. Account. Financ. Manag.
**2018**, 25, 63–72. [Google Scholar] [CrossRef] [Green Version] - Bose, I.; Mahapatra, R.K. Business data mining—A machine learning perspective. Inf. Manag.
**2001**, 39, 211–225. [Google Scholar] - Caruana, R.; Lou, Y.; Gehrke, J.; Koch, P.; Sturm, M.; Elhadad, N. Intelligible Models for HealthCare: Predicting Pneumonia Risk and Hospital 30-day Readmission. In Proceedings of the 21th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining; Association for Computing Machinery: Sydney, NSW, Australia, 2015; pp. 1721–1730. [Google Scholar]
- Adadi, A.; Berrada, M. Peeking Inside the Black-Box: A Survey on Explainable Artificial Intelligence (XAI). IEEE Access
**2018**, 6, 52138–52160. [Google Scholar] [CrossRef] - Ribeiro, M.T.; Singh, S.; Guestrin, C. “Why Should I Trust You?”: Explaining the Predictions of Any Classifier. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining; Association for Computing Machinery: San Francisco, CA, USA, 2016; pp. 1135–1144. [Google Scholar]
- Gunning, D.; Aha, D. DARPA’s Explainable Artificial Intelligence (XAI) Program. AI Mag.
**2019**, 40, 44–58. [Google Scholar] [CrossRef] - Besozzi, D.; Manzoni, L.; Nobile, M.S.; Spolaor, S.; Castelli, M.; Vanneschi, L.; Cazzaniga, P.; Ruberto, S.; Rundo, L.; Tangherloni, A. Computational Intelligence for Life Sciences. Fundam. Inform.
**2020**, 171, 57–80. [Google Scholar] [CrossRef] [Green Version] - Koza, J.R. Genetic Programming: On the Programming of Computers by Means of Natural Selection; MIT Press: Cambridge, MA, USA, 1992; p. 680. [Google Scholar]
- Vanneschi, L.; Castelli, M.; Silva, S. A survey of semantic methods in genetic programming. Genet. Program. Evolvable Mach.
**2014**, 15, 195–214. [Google Scholar] [CrossRef] - Moraglio, A.; Krawiec, K.; Johnson, C. Geometric Semantic Genetic Programming. In Proceedings of PPSN XII Parallel Problem Solving from Nature; Springer: Berlin/Heidelberg, Germany, 2012; pp. 21–31. [Google Scholar]
- Castelli, M.; Vanneschi, L.; De Felice, M. Forecasting short-term electricity consumption using a semantics-based genetic programming framework: The South Italy case. Energy Econ.
**2015**, 47, 37–41. [Google Scholar] [CrossRef] - Borenstein, Y.; Poli, R. Information landscapes. In Proceedings of the 7th Annual Conference on Genetic and Evolutionary Computation; ACM: Washington, DC, USA, 2005; pp. 1515–1522. [Google Scholar]
- Castelli, M.; Vanneschi, L.; Silva, S. Prediction of high performance concrete strength using Genetic Programming with geometric semantic genetic operators. Expert Systems Appl.
**2013**, 40, 6856–6862. [Google Scholar] [CrossRef] - Castelli, M.; Trujillo, L.; Vanneschi, L.; Silva, S.; Z-Flores, E.; Legrand, P. Geometric Semantic Genetic Programming with Local Search. In Proceedings of the 2015 Annual Conference on Genetic and Evolutionary Computation; ACM: Madrid, Spain, 2015; pp. 999–1006. [Google Scholar]
- Grosan, C.; Abraham, A. Hybrid Evolutionary Algorithms: Methodologies, Architectures, and Reviews. In Hybrid Evolutionary Algorithms; Abraham, A., Grosan, C., Ishibuchi, H., Eds.; Springer: Berlin/Heidelberg, Germany, 2007; pp. 1–17. [Google Scholar]
- Trujillo, L.; Emigdio, Z.; Juárez-Smith, P.S.; Legrand, P.; Silva, S.; Castelli, M.; Vanneschi, L.; Schütze, O.; Muñoz, L. Local search is underused in genetic programming, in Genetic Programming Theory and Practice XIV.; Springer: Berlin/Heidelberg, Germany, 2018; pp. 119–137. [Google Scholar]
- Boersen, A.; Scholtens, B. The relationship between European electricity markets and emission allowance futures prices in phase II of the EU (European Union) emission trading scheme. Energy
**2014**, 74, 585–594. [Google Scholar] [CrossRef] - de Menezes, L.M.; Houllier, M.A.; Tamvakis, M. Time-varying convergence in European electricity spot markets and their association with carbon and fuel prices. Energy Policy
**2016**, 88, 613–627. [Google Scholar] [CrossRef] - Kanamura, T. Role of carbon swap trading and energy prices in price correlations and volatilities between carbon markets. Energy Econ.
**2016**, 54, 204–212. [Google Scholar] [CrossRef] - Zachmann, G. A stochastic fuel switching model for electricity prices. Energy Econ.
**2013**, 35, 5–13. [Google Scholar] [CrossRef] - Feijoo, F.; Silva, W.; Das, T.K. A computationally efficient electricity price forecasting model for real time energy markets. Energy Convers. Manag.
**2016**, 113, 27–35. [Google Scholar] [CrossRef] - Gaillard, P.; Goude, Y.; Nedellec, R. Additive models and robust aggregation for GEFCom2014 probabilistic electric load and electricity price forecasting. Int. J. Forecast.
**2016**, 32, 1038–1050. [Google Scholar] [CrossRef] - EIA. Spot Prices; U.S. Energy Information Administration: Washington, DC, USA, 2015.
- EEX. Spot Market Data; European Energy Exchange AG: Leipzig, Germany, 2015. [Google Scholar]
- DWD. Wetter und Klima; Deutscher Wetterdienst: Offenbach am Main, Germany, 2015. [Google Scholar]
- Weisberg, S. Applied Linear Regression; John Wiley & Sons: Hoboken, NJ, USA, 2005; Volume 528. [Google Scholar]
- Seber, G.A.; Lee, A.J. Linear Regression Analysis; John Wiley & Sons: Hoboken, NJ, USA, 2012; Volume 936. [Google Scholar]
- Hoffmann, L. Multivariate Isotonic Regression and its Algorithms; Wichita State University: Wichita, KS, USA, 2009. [Google Scholar]
- Haykin, S. Neural Networks: A Comprehensive Foundation; Prentice Hall: Upper Saddle River, NJ, USA, 1999. [Google Scholar]
- Schölkopf, B.; Smola, A.J. Learning with Kernels: Support Vector Machines, Regularization, Optimization, and Beyond; MIT Press: Cambridge, MA, USA, 2002. [Google Scholar]
- Hall, M.; Frank, E.; Holmes, G.; Pfahringer, B.; Reutemann, P.; Witten, I.H. The WEKA data mining software. ACM SIGKDD Explor. Newsl.
**2009**, 11, 10. [Google Scholar] [CrossRef]

**Figure 1.**Comparison between the execution time of different GP systems. GSGP stands for Geometric Semantic Genetic Programming, the GP system that uses the GSC and GSM operators; LSGP is the GSGP version in which the GSM operator is combined with the local search operator; STGP refers to the traditional GP algorithm that makes use of standard syntax-based genetic operators.

**Figure 2.**Training Mean Absolute Error (MAE). The plots show the median over 100 runs. The training MAE is expressed in Euros. The light gray line represents Geometric Semantic Genetic Programming, while the black line represents Geometric Semantic Genetic Programming with Local Search.

**Figure 3.**Test MAE. The plots show the median over 100 runs. The Test MAE is expressed in Euros. The light gray line represents Geometric Semantic Genetic Programming, while the black line represents Geometric Semantic Genetic Programming with Local Search.

**Figure 4.**Boxplots of the training MAE calculated over 100 runs. On each box, the central mark is the median, the edges of the box are the 25th and 75th percentiles, and the whiskers extend to the most extreme data points not considered outliers. The MAE is expressed in Euros. LIN stands for linear regression, SQ stands for ordinary least square regression, ISO stands for isotonic regression, RBF stands for radial basis function network, NN stands for multilayer perceptron trained with backpropagation, and SVM stands for support vector machine with a polynomial kernel (of second degree for SVM2).

**Figure 5.**Boxplots of the test MAE calculated over 100 runs. On each box, the central mark is the median, the edges of the box are the 25th and 75th percentiles, and the whiskers extend to the most extreme data points not considered outliers. The MAE is expressed in Euros. LIN stands for linear regression, SQ stands for ordinary least square regression, ISO stands for isotonic regression, RBF stands for radial basis function network, NN stands for multilayer perceptron trained with backpropagation, and SVM stands for support vector machine with a polynomial kernel (of second degree for SVM2).

**Table 1.**Model variables available in the considered dataset. Observations collected on a daily basis; the task is to predict the target variable in the next 24 h.

Variable | Description |
---|---|

X_{0} | Crude oil spot price (Euro) |

X_{1} | Settlement price EUR/t CO_{2} (Euro) |

X_{2} | Air temperature (degrees Celsius) |

X_{3} | Air density (Kg/m^{3}) |

X_{4} | Ground temperature (degrees Celsius) |

X_{5} | Air pressure (Pascal) |

X_{6} | Relative humidity (expressed as a percentage) |

X_{7} | Wind speed (meters/second) |

X_{8} | Maximum intraday air temperature (degrees Celsius) |

X_{9} | Minimum intraday air temperature (degrees Celsius) |

X_{10} | Minimum intraday air temperature at ground level (degrees Celsius) |

X_{11} | Maximum intraday wind speed (meters/second) |

X_{12} | Next-day rain precipitation forecast to cover a horizontal ground surface (millimeters) |

X_{13} | Next-day snow precipitation forecast to cover a horizontal ground surface (centimeters) |

X_{14} | Sunshine duration (hours) |

X_{15} | Snow depth (centimeters) |

TARGET | Electricity price in EUR in the following day (24 hour prediction) |

**Table 2.**Median and standard deviation of the running time (in seconds) for the two GP based systems.

Running Time(s) | ||
---|---|---|

Median | Standard Deviation | |

GSGP | 35.73 | 0.59 |

LSGP | 36.18 | 0.81 |

**Table 3.**P-values returned by the Mann–Whitney test under the alternative hypothesis that the samples do not have equal medians. In particular, the test compared the median MAE obtained by the considered techniques over the 100 runs we performed.

**Bold**denotes values indicating a statistical difference among the considered techniques.

Training | |||||||

LSGP | LIN | SQ | ISO | RBF | NN | SVM | SVM2 |

1.21 × 10^{−}^{12} | 1.21 × 10^{−}^{12} | 1.21 × 10^{−}^{12} | 1.21 × 10^{−}^{12} | 1.21 × 10^{−}^{12} | 1.21 × 10^{−}^{12} | 3.83 × 10^{−}^{10} | |

Test | |||||||

LSGP | LIN | SQ | ISO | RBF | NN | SVM | SVM2 |

4.72 × 10^{−}^{8} | 4.72 × 10^{−}^{8} | 4.72 × 10^{−}^{8} | 4.72 × 10^{−}^{8} | 4.72 × 10^{−}^{8} | 4.72 × 10^{−}^{8} | 2.59 × 10^{−}^{17} |

© 2020 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Castelli, M.; Groznik, A.; Popovič, A.
Forecasting Electricity Prices: A Machine Learning Approach. *Algorithms* **2020**, *13*, 119.
https://doi.org/10.3390/a13050119

**AMA Style**

Castelli M, Groznik A, Popovič A.
Forecasting Electricity Prices: A Machine Learning Approach. *Algorithms*. 2020; 13(5):119.
https://doi.org/10.3390/a13050119

**Chicago/Turabian Style**

Castelli, Mauro, Aleš Groznik, and Aleš Popovič.
2020. "Forecasting Electricity Prices: A Machine Learning Approach" *Algorithms* 13, no. 5: 119.
https://doi.org/10.3390/a13050119