1 Introduction
As one of the elements of the electricity market, electricity price plays a decisive role in the allocation of resources in the electricity market. Accurately forecasting short-term electricity price changes is the basis for all parties in the electricity market to participate in the electricity market, which can improve the economic benefits of electricity market participants and assist them in making scientific transaction decisions
[1]. Therefore, improving the accuracy of electricity price forecasting is a common concern of all parties.
In recent years, many scholars have carried out a lot of research on electricity price forecasting. The methods of electricity price forecasting mainly include time series modeling methods and machine learning methods.
The time series method forecasts the future data fluctuation trend by modeling and analyzing historical time series data. However, electricity price is closely related to weather, electricity demand, industrial and commercial intensity, daily activities, and other factors, and has the characteristics of nonlinearity and instability. The time series modeling method cannot fully consider external factors affecting the time series, and the nonlinear relationship between the electricity price and other influencing factors cannot be effectively fitted
[2-4]. However, the machine learning method has important advantages in dealing with nonlinear problems. Therefore, this paper intends to choose machine learning methods for short-term electricity price forecasting.
Machine learning methods include artificial neural network (ANN)
[5-7], long short-term memory (LSTM)
[8, 9], support vector machine (SVM)
[10-12], random forest (RF)
[13, 14], etc. The neural network method forecasts the future development by finding hidden trends and laws from a large amount of historical data. ADE-LSTM model was used to forecast electricity prices in New South Wales, Germany, Austria and France, and achieved good forecasting results
[15]. But most neural network algorithms have the shortcomings of being easy to over-learn and falling into local optimum. The SVM and RF methods can avoid the shortcomings of the traditional neural network algorithm to set the initial value arbitrarily, and overcome the shortcomings of easily falling into the local optimal. Yan, et al. proposed a medium-term electricity market clearing price forecasting model based on multiple support vector machines, and verified the model using PJM interconnection data
[16]. Sun, et al. used RF algorithm to study the hourly power load forecast, showing that RF has a good ability to deal with non-linear and instability problems
[17]. Compared with other traditional algorithms, like SVM, the RF regression algorithm is more efficient, and it can handle high-dimensional data without feature selection, even it has strong generalization ability, at the same time RF model is less prone to overfitting.
The forecasting accuracy is greatly affected by the model's parameters and it is difficult to tune parameters to guarantee the stability of the forecasting accuracy. Therefore, it is necessary to use an optimization algorithm to select the optimal parameters globally, which can overcome the limitations of artificially selecting parameters and improve the forecasting accuracy of the model. Artificial intelligence optimization algorithms such as genetic algorithm (GA)
[18, 19], grey wolf optimizer (GWO)
[20, 21], particle swarm optimization (PSO)
[22, 23] are widely used in the selection of forecasting model parameters research. And the results show that parameter optimization can improve the accuracy of the forecasting model. Among them, genetic algorithms and particle swarm optimization have the disadvantages of premature convergence and poor convergence for high-dimensional complex problems, and cannot guarantee convergence to the best advantage. The GWO algorithm is a modern optimization algorithm. It has an adaptively adjustable convergence factor and information feedback mechanism, which can achieve a balance between local optimization and global search. Therefore, it has good performance in terms of accuracy and convergence speed for parameter selection problems.
Electricity price is greatly influenced by many other factors, and the data dimension is high. Moreover, to overcome the problem of non-linearity in time series forecasting, and the problem of over-fitting, local optimization, difficulty in parameter selection and low operational efficiency of some machine learning algorithms. Therefore, this paper proposes a GWO-optimized RF electricity price forecasting model, combined with historical data and weather information of a place in the US PJM power market to forecast short-term real-time electricity prices in different seasons. The analysis results show that the forecasting method proposed in this paper has high accuracy.
2 Algorithm Principle
2.1 RF Algorithm
RF is a machine learning algorithm proposed by Leo Breiman in 2001 combining Bagging integrated learning theory and random subspace method
[24]. The RF regression algorithm can effectively fit the correlation of variables in the training samples. When the forecasting results generated by the model trained by the training sample set generated by multiple sets of resampling, random errors will cancel each other out, and the situation of overfitting will be alleviated, and it can handle the problem of continuous or discrete attributes, at the same time, it has the advantages of anti-noise and prevention of overfitting. Due to the superior performance of RF, the algorithm has been widely used in the fields of bioinformatics, economics and finance, computer vision, data mining, and metric learning, and it is also suitable for short-term electricity price forecasting.
The basic principle of the RF regression algorithm is that a set of original data is resampled to obtain sets of data, and each set of data generates a regression tree model . RF regression is a model combination named consisting of this set of regression tree models. Among them, are independent and identically distributed random variables, under the given of each group, each regression tree will produce a result. Finally, average the results to get the final result .
The specific algorithm flow of RF regression is as follows:
1) Assuming that the data set size is , the RF algorithm has trees and uses bootstrap resampling to randomly generate m sample subsets of size in the data set .
2) Supposing that the feature dimension of each input is , specify a constant , and randomly extract feature value subsets from features. In the sample subset, these features are used to split the nodes and construct the regression tree.
3) Repeat 1) and 2) to construct regression trees. Each tree grows freely to form a random forest.
4) Take the average of the forecasted results of trees as the final result. There are two parameters and in the random forest to determine its forecasting accuracy. Therefore, this paper intends to use GWO to find the optimal and values to obtain a more accurate RF electricity price forecasting model to improve the accuracy of electricity price forecasting.
2.2 GWO Algorithm
The GWO
[25] is to simulate the social level and predation mechanism of the wolf pack, use the grey wolf to track and approach the prey through odor, determine the location of the prey and surround the prey, and finally reduce the encirclement to prey, to achieve the purpose of optimization. The social class of wolves is divided into Alpha Wolf, Beta Wolf, Sigma Wolf, and Omega Wolf. Among them, the Alpha Wolf is responsible for leading the wolves, the Beta Wolf is responsible for assisting the alpha wolf in decision-making, and the Sigma Wolf follows the instructions of the Alpha Wolf and the Beta Wolf and can command the Omega Grey Wolf. In GWO, Alpha Wolf, Beta Wolf and Sigma Wolf respectively represent the historical optimal solution, suboptimal solution and third optimal solution, and Omega Wolf represents the remaining solutions. During the iteration of the algorithm, Alpha Wolf, Beta Wolf and Sigma Wolf are responsible for locating the optimal solution and guiding other grey wolves to come closer, and finally achieve the purpose of capturing the optimal solution.
The grey wolf is under the command and control of the alpha wolf, the beta wolf and the sigma wolf to participate in the capture of prey. The location of grey wolf surrounding prey is updated as follows:
is the distance between prey and grey wolf, and are coordination coefficient vectors, is the prey position vector, is the grey wolf individual position vector, and is the current iteration number.
The elements in a linearly decrease from 2 to 0 during the iteration process; both and represent random number vectors.
Alpha Wolf leads Beta Wolf, Sigma Wolf, and other grey wolves to attack and capture their prey. In the whole group, Alpha Wolf, Beta Wolf, and Sigma Wolf are the closest to the prey, so the position of these three wolves can be used to calculate the position of other grey wolves moving to the prey. The calculation formula is as follows:
, , and are the distances between the other grey wolves, Alpha Wolves, Beta Wolves, and Sigma Wolves, respectively.
The formula (12) determines the direction of the grey wolf individual to the prey
Update the individual position of the grey wolf.
This article optimizes the RF regression model through GWO to make it have better a forecasting effect.
3 Electricity Price Forecasting Steps of RF Regression Model Based on GWO
The method of electricity price forecasting in this paper is divided into nine steps, namely:
Step 1 Input the original sample set to generate the RF training set and verification set.
Step 2 Initialize the value range of the RF tree number and the eigenvalue parameter , and set the relevant parameters of the GWO algorithm.
Step 3 Randomly generate grey wolf groups, each position vector of grey wolf group includes and .
Step 4 RF learns the training set based on the initial and , and calculates the fitness value of each grey wolf.
Step 5 Divide the grey wolf group into Alpha Wolf, Beta Wolf, Sigma Wolf and Omega Wolf according to fitness.
Step 6 Update the position of each individual in the wolf pack through the grey wolf group's attack and capture of the target.
Step 7 Calculate the fitness of each grey wolf in the new position, and compare it with the optimal fitness of the previous iteration. If the new fitness is better, the individual grey wolf will replace the optimal fitness of the group. If the new fitness is not better, the original optimal fitness is retained as the optimal fitness of the group.
Step 8 When the number of iterations exceeds the set maximum number of iterations, the GWO optimization process is ended, and the global optimal position of the grey wolf is output, and then the optimal values of the parameters and in RF are obtained.
Step 9 Use the obtained optimal parameters and to establish an RF electricity price forecasting model, forecast the verification set, and analyze the forecasting results.
4 Empirical Experience
4.1 Data Description
The different demands of users for electricity in different seasons will affect the changes in electricity prices and make it seasonal. To verify the effectiveness of the GWO-RF model in forecasting electricity prices under different seasonal fluctuation laws, this paper selects the data of spring (March), summer (June), autumn (September), and winter (December) in 2010 in one place of the US PJM market as simulation data. The original data includes hourly electricity price, day-ahead electricity price, load, weather, and date-related data. Forecast short-term electricity prices one hour ahead, 480 data from the first 20 days of each month are used as the training set, and 120 data from the 21st to the 25th of each month are used as the test set.
Figure 1 Forecasting step diagram |
Full size|PPT slide
4.2 Measurement of Forecasting Performance
Based on the actual demand forecasted by short-term electricity prices, this paper selects root mean square error (RMSE), mean absolute percentage error (MAPE) and mean absolute error (MAE) as evaluation indicators. Its expression is
In the formula, represents the number of test samples, is the forecasted value of the -th sample, and indicates the true value of the sample. The smaller the RMSE, MAPE and MAE, the smaller the error between the actual electricity value and the forecasted value. So in empirical analysis, the smaller of these three evaluation indicators, the better.
4.3 Analysis of Forecasting Results
This article uses BP neural network, RF and GWO-RF forecasting models for comparison. According to the data of the four seasons, the short-term electricity price forecasting models of the four seasons are established respectively. The forecasting errors of the three models in the four seasons are shown in Table 1.
Table 1 Result of four seasons electricity price forecast error |
Seasons | Error index | Model |
BP | RF | GWO-RF |
Spring | RMSE($/MWh) | 4.47 | 3.75 | 2.29 |
MAPE/% MAE($/MWh) | 7.10 2.74 | 6.87 2.55 | 5.11 1.77 |
Summer | RMSE($/MWh) | 8.12 | 7.87 | 6.90 |
MAPE/% MAE($/MWh) | 8.04 5.34 | 7.34 5.06 | 6.08 4.25 |
Autumn | RMSE($/MWh) | 23.19 | 15.98 | 10.97 |
MAPE/% MAE($/MWh) | 18.94 12.79 | 12.36 10.13 | 12.33 7.04 |
Winter | RMSE($/MWh) | 5.47 | 4.13 | 2.96 |
MAPE/% MAE($/MWh) | 11.27 4.31 | 7.94 3.16 | 5.80 2.29 |
It can be seen from Table 1 that these three evaluation indicators of the GWO-RF model in the four seasons of the year are smaller than other models, followed by the ordinary RF model. In spring, these three models all performed well, the RMSE, MAPE and MAE of the GWO-RF model were only 2.29, 5.11 and 1.77, the RF model was 3.75, 6.87 and 2.55, and the BP model had the worst effects, which was 4.47, 7.10 and 2.74 respectively. In autumn when the three models performed poorly, the RMSE, MAPE and MAE of the GWO-RF model were 10.97, 12.33 and 7.04, the RF model was 15.98, 12.36 and 10.13, and the BP model was 23.19, 18.94 and 12.79.
Among the four seasons, the forecasting effect of spring, summer and winter is better, and autumn is worse. This may be related to the different influencing factors of the four seasons in the region on the uncertainties of electricity price fluctuations, which require follow-up detailed studies for analysis.
It can be seen from Figure 2 that the overall forecasting of the three models in spring is good. Compared with the other two models, the GWO-RF model is more accurate in forecasting the maximum and minimum real electricity price curve in the future, and it can also well forecast the real-time electricity price change trend in spring. As shown in Figure 3, according to the absolute and relative error box plots, it can be seen that the forecasting effect of the GWO-RF model is superior to the BP and RF models. The number of outliers and the maximum error value of the BP and RF models is larger than the GWO-RF model. It can be seen from the box that the height of the GWO-RF model is the lowest, which again proves that the forecasting results of the GWO-RF forecasting model are good, and the errors and fluctuations are relatively small. It can be seen from Figure 4 that the prediction accuracy of GWO-RF is higher than that of the other two models, and the prediction stability is better. In the predicted five days, the daily MAPE of BP and RF changed greatly, and the stability of the model was poor. However, the MAPE of GWO-RF changed the smallest and the model was the most stable. The prediction performance is better on the 21st, 23rd and 24th, and the prediction error is relatively low.
Figure 2 Comparison of forecasted and true values of three models in spring |
Full size|PPT slide
Figure 3 Box plots of forecasting errors of three models in spring |
Full size|PPT slide
Figure 4 Comparison of MAPE of three models in spring |
Full size|PPT slide
From Figure 5 and Figure 6, we can see that the three models can roughly forecast the trend of real electricity price changes in summer. And the forecasted value curve of the GWO-RF model is closer to the true value of electricity price, followed by the GWO-RF model. According to the absolute error and relative error, we can see that the box height of the random forest forecasting model is the lowest, and the extreme value, median and mean of the forecasting error are lower than GWO-RF and BP, followed by the GWO-RF forecasting model. In Figure 7, it can be seen from the change trend of MAPE that in summer, the prediction performance of the three models is relatively stable, but the prediction error is relatively large on the 24th, and the value of MAPE exceeds 0.1. GWO-RF performance on the 25th The best. In the first four days, MAPE also tended to increase over time.
Figure 5 Comparison of forecasted and true values of three models in summer |
Full size|PPT slide
Figure 6 Box plots of forecasting errors of three models in summer |
Full size|PPT slide
Figure 7 Comparison of MAPE of three models in summer |
Full size|PPT slide
As can be seen from Figure 8 and Figure 9 that the forecasted values of the three models cannot be very close to the real electricity price in autumn. These models have a good forecasting effect on September 22, but it cannot fit the true value curve at other times. The BP model has the worst forecasting effect and performs poorly at multiple points on the forecasting day. In general, the GWO-RF model is still the best performing electricity price forecasting model in the autumn forecasting experiment, and the forecasting effect of the RF model is slightly worse than the GWO-RF model. As can be seen from the forecasting error box plot, the box height of GWO-RF is lower and the BP is the highest, indicating that the forecasting error of the GWO-RF model is smaller than other models. Among the forecasting errors of the BP model, the outliers are the most and the values are relatively large and the overall forecasting error is relatively high. The maximum absolute error of GWO-RF is close to 20, and the maximum relative error is close to 0.4. Compared with the other three seasons, the overall forecast error in autumn is higher. In Figure 10, the prediction accuracy of the three models is relatively low, and the stability of the prediction is relatively poor. Only the 21st and 22nd, the BP model and GWO-RF have relatively low prediction errors. The MAPE value of these two days is less than 0.1. From an overall point of view, the GWO-RF model still performs better, and the fluctuation range of MAPE is relatively small. The three models also show a trend of increasing forecast errors. According to the performance of the models in spring and summer, it is speculated that it may be affected by the time span of the training set and the test set. The longer the time from the training set, the more the test set may have The information cannot be captured, so the prediction accuracy is low, and some data sets will have large fluctuations.
Figure 8 Comparison of forecasted and true values of three models in autumn |
Full size|PPT slide
Figure 9 Box plots of forecasting errors of three models in autumn |
Full size|PPT slide
Figure 10 Comparison of MAPE of three models in autumn |
Full size|PPT slide
It can be seen from Figure 11 and Figure 12 that the three models can roughly forecast the trend of real-time electricity price changes in winter, and the forecasting of the minimum value of the hourly electricity price sequence needs to be improved. The GWO-RF model obviously has better forecasting effect than the other two models, and has a better fitting effect on the real value of electricity price in winter. The BP model performs worse than the other two models, and its forecasting value has a significantly larger deviation from the true value. As can be seen from the forecasting error box plot, in the three models, the GWO-RF model has fewer outliers in forecasting error, and the extreme value, mean, and median are lower than the other two models, and the forecasting accuracy is higher. From Figure 13, through comparison, it is found that the three models have the best prediction effect on the 23rd, and the stability and prediction accuracy of GWO-RF in the three models are relatively high.
Figure 11 Comparison of forecasted and true values of three models in winter |
Full size|PPT slide
Figure 12 Box plots of forecasting errors of three models in winter |
Full size|PPT slide
Figure 13 Comparison of MAPE of three models in winter |
Full size|PPT slide
According to Figure 14, it can be seen that the stability of the electricity price forecast from 6 pm to 5 am in the spring is relatively poor and the error is large. In summer, the forecast accuracy from 7 am to 8 pm is low, and the volatility of MAPE is relatively large. The stability and accuracy of the forecast throughout the autumn are not high, especially in the period from 11 noon to 9 pm, the forecast stability is the worst and the accuracy is also the lowest. Moreover, the stability and accuracy of electricity price forecasts from 1 am to 8 am in winter are poor. On the whole, summer and autumn are mainly due to the poor accuracy and stability of forecasting at the time of the day, which may be due to the influence of summer and autumn temperatures, leading to large changes in electricity consumption. The instability in spring and winter is mainly concentrated at night. Due to the low night temperature in spring and winter, the electricity consumption will also change accordingly, so the accuracy and stability of the forecast are lacking.
Figure 14 Changes in MAPE at different times of the season |
Full size|PPT slide
5 Conclusions
To improve the accuracy of short-term real-time electricity price forecasting, this paper proposes a GWO-RF short term electricity price forecasting model. Firstly, the principles of RF and GWO algorithms are analyzed, and then the GWO algorithm is used to find the optimal parameters of the RF forecasting model. Finally, the GWO-RF forecasting model is applied to the short-term electricity price forecast of the PJM power market in spring, summer, autumn and winter. The comparison test shows that the forecasting effect of the GWO-RF model in spring, autumn and winter is better, and the forecasting accuracy of the RF model in summer is higher, but the forecasting errors of the three models in autumn are larger. The reason may be that the changes in electricity prices in autumn and summer are susceptible to weather and other factors, and further research is needed to improve the forecast accuracy of electricity prices in autumn and summer. And through comparative experiments, it is proved that the RF algorithm can better forecast the short-term electricity prices, and the GWO algorithm optimizes the RF forecast, and it can effectively improve the accuracy of the RF forecasting model.
{{custom_sec.title}}
{{custom_sec.title}}
{{custom_sec.content}}