Electricity price prediction method and device, electronic equipment and storage medium

The convolutional neural network-multi-head self-attention model processed electricity price-related data, which solved the problem of uncaptured relationship between weather and temperature data in electricity price prediction, and improved the accuracy and training efficiency of electricity price prediction.

CN120338850APending Publication Date: 2025-07-18SHENZHEN POWER SUPPLY BUREAU
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510429504.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-07
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

In the prior art, the electricity price prediction model cannot effectively capture the correlation between weather data and temperature data, resulting in poor accuracy of electricity price prediction.

Method used

The convolutional neural network-multi-head self-attention model is adopted to extract local features of historical data through the convolutional neural network module, and the multi-head self-attention module is used to process the correlation between different data to generate target electricity price data.

Benefits of technology

The accuracy of electricity price prediction is improved, and the problem of gradient disappearance or explosion is solved by adjusting the matrix and calculation weight of the self-attention module, which enhances the training efficiency and prediction accuracy of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120338850A_ABST
    Figure CN120338850A_ABST
Patent Text Reader

Abstract

The invention discloses an electricity price prediction method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining first historical data, the first historical data comprises historical electricity price data and electricity price related data corresponding to a first historical time period, and the electricity price related data comprises weather data, temperature data and actual load data; and inputting the first historical data into a convolutional neural network-multi-head self-attention model to obtain predicted target electricity price data of a target time period, the target time period being after the first historical time period. By implementing the method provided by the invention, the problem of poor accuracy of electricity price prediction of a traditional model is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of electricity price prediction, and in particular to a method, device, electronic device and storage medium for electricity price prediction. Background Art

[0002] In the prior art, the prediction of electricity price is a complex process affected by multiple factors, and the intersection of demand and supply determines the actual electricity price level. On the demand side, considering basic variables such as predicted demand and weather conditions, such as temperature, season, and daily activities, all have a significant impact on electricity demand. On the supply side, as the modern energy market continues to call for user-side participation in balancing power supply and demand, the scale of distributed resources connected to the power grid is gradually increasing. Considering the intermittency and volatility of the output of distributed resources and the carrying capacity of the distribution network, it has a significant impact on power supply. In this dynamic and interconnected context, the power market currently more often uses a deep learning model combining convolutional neural network (CNN) and long short-term memory network (LSTM) for electricity price prediction.

[0003] The related models in the prior art capture the long-term dependence of electricity price changes over time by processing and predicting time series data. However, the models used in the prior art cannot capture the relationships between the input data during the processing (for example, the existing models in the prior art cannot consider the relationship between weather data and temperature data, which will affect each other). As a result, the traditional models have a poor accuracy in predicting electricity prices. Summary of the Invention

[0004] In view of the above problems, the embodiments of the present application provide a method, device, electronic device and storage medium for electricity price prediction. The solution of the present application is beneficial to solving the problem of poor accuracy of traditional models in predicting electricity prices.

[0005] In a first aspect, the embodiments of the present application provide a method for electricity price prediction. The method includes: obtaining first historical data, where the first historical data includes historical electricity price data corresponding to a first historical period and electricity price-related data, and the electricity price-related data includes weather data, temperature data, and actual load data; inputting the first historical data into a convolutional neural network-multi-head self-attention model to obtain target electricity price data for a target period predicted, and the target period is after the first historical period.

[0006] It can be seen that in the embodiments of the present application, the first historical data is processed by a convolutional neural network-multi-head self-attention model to predict the target electricity price data at the target moment. The self-attention mechanism is used to solve the problem that traditional neural network models cannot establish correlations for multiple related data, thereby improving the accuracy of the final target electricity price data.

[0007] In combination with the first aspect, in a possible embodiment, the convolutional neural network - multi - head self - attention model includes a convolutional neural network module and a multi - head self - attention module. The multi - head self - attention module includes multiple self - attention heads. Inputting the first historical data into the convolutional neural network - multi - head self - attention model to obtain the target electricity price data for the target time period, including: inputting the first historical data into the convolutional neural network module to obtain multiple first one - dimensional vectors, and the first one - dimensional vectors correspond one - to - one with the historical electricity price data, weather data, temperature data, and actual load data in the first historical data; inputting the multiple first one - dimensional vectors into the multi - head self - attention module to obtain multiple first output matrices; where each self - attention head includes a corresponding query matrix, key matrix, and value matrix, and the multiple first output matrices correspond one - to - one with the multiple self - attention heads; determining the target electricity price data for the target time period according to the multiple first output matrices.

[0008] It can be seen that in the embodiment of the present application, after the convolutional neural network module in the convolutional neural network - multi - head self - attention model extracts local features from the first historical data, the multi - head self - attention module processes the first one - dimensional vectors, and the correlation between different data in the input data is considered in the process of predicting the target electricity price data, improving the prediction accuracy of the target electricity price data.

[0009] In combination with the first aspect, in a possible embodiment, the method further includes: generating an initial query matrix, an initial key matrix, and an initial value matrix for each self - attention head in the multiple self - attention heads; generating first training data and first validation data according to the first historical data; inputting the first training data into the convolutional neural network module to obtain multiple second one - dimensional vectors, and the second one - dimensional vectors correspond one - to - one with the historical electricity price data, weather data, temperature data, and actual load data in the first training data; inputting the multiple second one - dimensional vectors into the multi - head self - attention module, so that each self - attention head generates a corresponding second output matrix according to the corresponding initial query matrix, initial key matrix, initial value matrix, and the second one - dimensional vectors; determining the predicted electricity price for the first historical period corresponding to the first validation data according to the second output matrices generated by the multiple self - attention heads; calculating the prediction error index between the predicted electricity price and the historical electricity price data corresponding to the first validation data; judging whether the predicted electricity price meets the stop condition of the multi - head self - attention module according to the prediction error index; if the stop condition of the multi - head self - attention module is not met, adjusting the initial query matrix, initial key matrix, and initial value matrix of the multiple self - attention heads according to the preset dot - product scaling factor and the prediction error index; if the stop condition of the multi - head self - attention module is met, determining the initial query matrix, initial key matrix, and initial value matrix of each self - attention head in the multiple self - attention heads as the query matrix, key matrix, and value matrix of the corresponding self - attention head.

[0010] It can be seen that in the embodiments of the present application, the query matrix, key matrix, and value matrix in the multi-head self-attention module are adjusted through the first historical data, further improving the accuracy of the prediction result. During the adjustment process, the problem of gradient vanishing or explosion is solved through the scaling factor.

[0011] Combined with the first aspect, in a possible embodiment, the method further includes: obtaining a plurality of second historical data, where the second historical data includes historical electricity price data and electricity price-related data corresponding to different second historical periods; determining the correlation degree between the plurality of second historical data and the target electricity price data; and determining the second historical period with a correlation degree greater than the first preset threshold as the first historical period.

[0012] It can be seen that in the embodiments of the present application, by determining the data with a correlation degree higher than the first preset threshold with the target electricity price data from the plurality of second historical data, the number of data that the convolutional neural network-multi-head self-attention model needs to process is reduced, the data quality of the input convolutional neural network-multi-head self-attention model is improved, and thus the training efficiency of the model and the accuracy of model prediction are improved.

[0013] Combined with the first aspect, in a possible embodiment, determining the correlation degree between the plurality of second historical data and the target electricity price data includes: respectively determining the correlation degree between the plurality of second historical data and the historical electricity price data of the target historical period, where the target historical period is the period closest to the target period among the plurality of second historical periods; and determining the correlation degree between the plurality of second historical periods and the historical electricity price data of the target historical period as the correlation degree with the target electricity price data.

[0014] Combined with the first aspect, in a possible embodiment, determining the correlation degree between the plurality of historical periods and the target historical period according to the historical electricity price data-related data of the plurality of historical periods includes: respectively calculating the mutual information values between the plurality of second historical data and the historical electricity price data of the target historical period, where the mutual information value is used to characterize the correlation degree between the corresponding historical data and the historical electricity price data of the target historical period; and determining the correlation degree between the plurality of second historical periods and the target historical period according to the mutual information values.

[0015] In combination with the first aspect, in a possible embodiment, determining the correlation degree between multiple second historical periods and a target historical period according to the mutual information value includes: determining second historical data with a mutual information value higher than a second preset threshold as second training data, and determining the historical electricity price data of the target historical period as second verification data; training a neural network model according to the second training data and the second verification data so that the neural network model can predict the second verification data according to the second training data after training; obtaining the calculation weights of the electricity price-related data of multiple second historical periods with a mutual information value higher than a preset threshold in the neural network model, and the calculation weights are determined during the training process of the neural network model; determining the correlation degree between the corresponding second historical period and the target historical period according to the calculation weights, and the calculation weights are positively correlated with the corresponding correlation degree.

[0016] It can be seen that in the embodiment of the present application, by calculating the mutual information and / or obtaining the weights in the neural network model to calculate the correlation degree between multiple second historical periods and the target electricity price data, it is possible to determine the first historical data with a higher correlation degree with the target electricity price data from multiple second historical periods, thereby reducing the amount of data that the convolutional neural network-multi-head self-attention model needs to process, improving the data quality of the data input into the convolutional neural network-multi-head self-attention model, and further improving the training efficiency of the model and the accuracy of model prediction.

[0017] In a second aspect, an embodiment of the present application provides an electricity price prediction device, and the electricity price prediction device is used to execute the electricity price prediction method. The device includes:

[0018] An acquisition unit, configured to acquire first historical data, where the first historical data includes historical electricity price data and electricity price-related data corresponding to a first historical period, and the electricity price-related data includes weather data, temperature data, and actual load data;

[0019] A prediction unit, configured to input the first historical data into a convolutional neural network-multi-head self-attention model to obtain the target electricity price data of a predicted target period, and the target period is after the first historical period.

[0020] In a third aspect, an embodiment of the present application provides an electronic device, including a processor, a memory, a communication interface, and one or more programs. The one or more programs are stored in the memory and are configured to be executed by the processor, and one or more instructions are suitable for being loaded and executed by the processor to perform part or all of the methods in the first aspect and / or the second aspect.

[0021] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program for electronic data exchange, where the computer program enables a computer to execute part or all of the methods in the first aspect and / or the second aspect.

[0022] In a fifth aspect, the present application provides a computer program product. When a computer reads and executes this computer program product, it causes the computer to execute some or all of the methods in the first aspect and / or the second aspect.

[0023] Understandably, for the beneficial effects of the embodiments of the second aspect to the fifth aspect, reference can be made to the beneficial effects in the method of the first aspect, which will not be elaborated here. Description of the Drawings

[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0025] Figure 1 It is a schematic diagram of the application scenario of a power price prediction method provided by an embodiment of the present application;

[0026] Figure 2 It is a schematic flowchart of a power price prediction method provided by an embodiment of the present application;

[0027] Figure 3 It is a schematic diagram of the simplified structure of a convolutional neural network - multi - head self - attention model provided by an embodiment of the present application;

[0028] Figure 4 It is a schematic flowchart of another power price prediction method provided by an embodiment of the present application;

[0029] Figure 5 It is a schematic diagram of the process of determining the first historical period provided by an embodiment of the present application;

[0030] Figure 6 It is a schematic flowchart of another power price prediction method provided by an embodiment of the present application;

[0031] Figure 7 It is a schematic diagram of the structure of a power price prediction device provided by an embodiment of the present application;

[0032] Figure 8 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Detailed Embodiments

[0033] To enable those skilled in the art to better understand the solution of this application, the following will clearly and completely describe the technical solution in the embodiments of this application with reference to the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of this application.

[0034] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, products or devices.

[0035] Referring to "embodiment" herein means that a specific feature, structure or characteristic described in connection with the embodiment can be included in at least one embodiment of this application. The appearance of this phrase in various positions in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.

[0036] The following describes the embodiments of this application with reference to the accompanying drawings.

[0037] Embodiment 1:

[0038] Please refer to Figure 1 , Figure 1 , which is a schematic diagram of an application scenario of a power price prediction method provided in an embodiment of this application. The application scenario 100 includes a prediction terminal 101 and a data acquisition terminal 102.

[0039] The prediction terminal 101 and the data acquisition terminal 102 here are specifically a computer, a smart phone, a wearable smart device, a vehicle-mounted terminal, etc. The prediction terminal 101 is connected to the data acquisition terminal 102, and the prediction terminal 101 performs power price prediction on the historical data sent by the data acquisition terminal 102. The historical data here includes historical power price data, weather data, temperature data and other data related to power price.

[0040] In an embodiment of the present application, the prediction terminal 101 obtains first historical data, which includes historical electricity price data corresponding to a first historical period and electricity price-related data. The electricity price-related data includes weather data, temperature data, and actual load data. Specifically, the first historical data here is obtained by the data acquisition terminal 102 and then sent to the prediction terminal 101, or is obtained by the prediction terminal 101 itself.

[0041] The prediction terminal 101 inputs the first historical data into a convolutional neural network - multi-head self-attention model to obtain the target electricity price data for the target period. The target period is after the first historical period. The input convolutional neural network - multi-head self-attention model is deployed on the prediction terminal 101. The convolutional neural network - multi-head self-attention model can consider the influence of the correlation between various historical data such as historical electricity price data, weather data, temperature data, and actual load data on the final prediction result during the process of predicting the target electricity price data based on the first historical data.

[0042] It can be seen that in an embodiment of the present application, by processing the first historical data through the convolutional neural network - multi-head self-attention model to predict the target electricity price data at the target moment, the self-attention mechanism is used to solve the problem that traditional neural network models cannot establish correlations for multiple related data, thereby improving the accuracy of the final target electricity price data.

[0043] Figure 2 It is a schematic flowchart of a method for predicting electricity price provided by an embodiment of the present application. As Figure 1 shown, it includes steps S201 - S202:

[0044] S201: Obtain first historical data, where the first historical data includes historical electricity price data corresponding to a first historical period and electricity price-related data, and the electricity price-related data includes weather data, temperature data, and actual load data.

[0045] Specifically, the first historical data here includes historical electricity price data and electricity price-related data at multiple time points within a period of time (such as 15 minutes, 30 minutes, 1 hour) before the current moment. The electricity price-related data here includes at least one of data such as weather data, temperature data, and actual load data.

[0046] The first historical time period here is specifically a continuous time period, such as 8:00 am - 9:00 am, or may also be a set of multiple discontinuous time periods, such as 7:30 am - 8:00 am, 8:30 am, and 9:00 am.

[0047] S202: Input the first historical data into the convolutional neural network - multi - head self - attention model to obtain the predicted target electricity price data for the target time period, where the target time period is after the first historical time period.

[0048] Specifically, the convolutional neural network - multi - head self - attention model here combines the convolutional neural network and the multi - head self - attention processing mechanism, and can consider the influence of the correlation between various historical data such as historical electricity price data, weather data, temperature data, and actual load data on the final prediction result during the process of predicting the target electricity price data based on the first historical data.

[0049] In some possible embodiments, the convolutional neural network - multi - head self - attention model includes a convolutional neural network module and a multi - head self - attention module. The multi - head self - attention module includes multiple self - attention heads. Inputting the first historical data into the convolutional neural network - multi - head self - attention model to obtain the predicted target electricity price data for the target time period includes: inputting the first historical data into the convolutional neural network module to obtain multiple first one - dimensional vectors, where the first one - dimensional vectors correspond one - to - one with the historical electricity price data, weather data, temperature data, and actual load data in the first historical data; inputting the multiple first one - dimensional vectors into the multi - head self - attention module to obtain multiple first output matrices; each self - attention head includes a corresponding query matrix, key matrix, and value matrix, and the multiple first output matrices correspond one - to - one with the multiple self - attention heads; determining the target electricity price data for the target time period based on the multiple first output matrices.

[0050] Specifically, in the embodiments of the present application, the convolutional neural network - multi - head self - attention model includes a convolutional neural network module and a multi - head self - attention module, and the multi - head self - attention module includes multiple self - attention heads. The convolutional neural network module is used to generate multiple first one - dimensional vectors that correspond one - to - one with the historical electricity price data, weather data, temperature data, and actual load data in the first historical data.

[0051] The multiple self - attention heads in the multi - head self - attention module process the multiple first one - dimensional vectors respectively according to their corresponding query matrices, key matrices, and value matrices to obtain multiple first output matrices. Finally, the target electricity price data for the target time period is determined based on the multiple first output matrices here.

[0052] Exemplarily, please refer to Figure 3 , Figure 3 which is a simplified structural schematic diagram of a convolutional neural network - multi - head self - attention model provided by the embodiments of the present application.

[0053] The convolutional neural network module is mainly divided into an input layer, a convolutional layer, an activation function, a pooling layer, a flattening layer, a fully connected layer, and an output layer. The specific process is as follows: First, the first historical data is converted into a feature set, where the feature set includes all the data in the first historical data. The filtered feature set is passed into the input layer of the convolutional neural network module.

[0054] Secondly, multiple convolutional kernels are applied in the convolutional layer to perform convolutional operations on the input feature set to extract local features. The convolutional operation is shown in the following formula (1).

[0055]

[0056] Where: f ∈ {1, 2}, c = m - 3 * (f - 1); x mn represents the input feature vector matrix with a matrix size of m * n; W cn represents the weight matrix of the convolutional kernel with a matrix size of c * n; f represents the index of the input feature matrix; y f,CNN represents the value of the f-th output feature matrix.

[0057] Furthermore, a non-linear activation function is applied to the output of the convolutional layer, and a pooling operation (such as average pooling) is performed on the feature matrix X obtained by the input convolution as shown in the following formulas (2) - (4).

[0058] Pooling layer operation - Average Pooling is a pooling operation that reduces the size of the feature map by taking the average value within a local neighborhood. Its mathematical model description is as follows:

[0059] The input feature matrix is X with a size of M * N, the size of the pooling window is p * p, and the pooling stride is s. Then the size of the pooled output feature matrix Y is M' * N' where:

[0060]

[0061] For each element of the output feature matrix Y:

[0062]

[0063] Where: x i*s+m,j*s+m represents the eigenvalue corresponding to the feature matrix X at the position (i * s + m, j * s + m); y i,j represents the pooled feature vector at the position (i, j).

[0064] Then the flattening layer downsamples the feature matrix Y, uses max pooling to reduce the size and computational complexity of the feature map; finally, the multi-dimensional feature map is flattened into a one-dimensional vector to obtain the multiple first one-dimensional vectors described above.

[0065] At this point, the operation of the convolutional neural network module temporarily stops, and the multi-head self-attention module needs to be processed at this time. The input received by the convolutional neural network module is a lot of vectors of different sizes, and there is a certain relationship between different vectors. However, during actual training, the relationship between these inputs cannot be fully utilized, resulting in extremely poor model training results. To solve the problem that the fully connected neural network cannot establish the correlation between multiple related inputs, the self-attention mechanism is used. The self-attention mechanism actually wants the machine to notice the correlation between different parts of the entire input.

[0066] First, calculate the query matrix, key matrix, and value matrix.

[0067] For each of the multiple self-attention heads i, the calculated query matrix, key matrix, and value matrix are shown in the following equations (5), (6), and (7):

[0068] Q i =X′W Q (5)

[0069] K i =X′W K (6)

[0070] V i =X′W V (7)

[0071] Where: W Q 、W K and W V represent trainable weight matrices with dimensions d*d k , d k is the dimension of the query, key, and value.

[0072] The process of calculating the query, key, and value matrices is shown in the following equation (8):

[0073]

[0074] Where: represents the dot product scaling factor of the query matrix and the key matrix. In addition, in natural language processing, it is often necessary to pad the input to ensure that the input sequence lengths are the same during batch processing. When calculating the attention weights, these padded parts usually need to be ignored, so this can be achieved through masking. The calculation of each first output matrix is shown in the following equation (9):

[0075]

[0076] Among them, the elements of the mask matrix M being negative infinity (-∞) represent the padding positions, and the other positions are 0.

[0077] After obtaining the first output matrix of the outputs of multiple self-attention heads, the outputs of all heads are concatenated as shown in the following formulas (10) and (11):

[0078] MultiHead i (Q, K, V) = Concat(head1, head2,..., head i )W o (10)

[0079] head i = Attention i (Q i , K i , V i )(11)

[0080] Among them: W o represents the linear transformation weight matrix of the output of the multi-head self-attention.

[0081] Finally, the final prediction result is obtained based on the outputs of all heads.

[0082] It can be seen that in the embodiment of the present application, after the convolutional neural network module in the convolutional neural network-multi-head self-attention model extracts local features from the first historical data, the first one-dimensional vector is processed by the multi-head self-attention module, and the correlation between different data in the input data is considered in the process of predicting the target electricity price data, improving the prediction accuracy of the target electricity price data.

[0083] In some possible embodiments, before inputting multiple first one-dimensional vectors into the multi-head self-attention module, it further includes: generating an initial query matrix, an initial key matrix, and an initial value matrix for each self-attention head among the multiple self-attention heads; generating first training data and first validation data according to the first historical data; inputting the first training data into the convolutional neural network module to obtain multiple second one-dimensional vectors, where the second one-dimensional vectors correspond one-to-one to the historical electricity price data, weather data, temperature data, and actual load data in the first training data; inputting the multiple second one-dimensional vectors into the multi-head self-attention module, so that each of the multiple self-attention heads generates a corresponding second output matrix according to the corresponding initial query matrix, initial key matrix, initial value matrix, and the second one-dimensional vectors; determining the predicted electricity price for the first historical period corresponding to the first validation data according to the second output matrices generated by the multiple self-attention heads; calculating the prediction error index between the predicted electricity price and the historical electricity price data corresponding to the first validation data; determining whether the predicted electricity price meets the stop condition of the multi-head self-attention module according to the prediction error index; if the stop condition of the multi-head self-attention module is not met, adjusting the initial query matrix, initial key matrix, and initial value matrix of each self-attention head among the multiple self-attention heads according to the preset dot product scaling factor and the prediction error index; if the stop condition of the multi-head self-attention module is met, determining the initial query matrix, initial key matrix, and initial value matrix of each self-attention head among the multiple self-attention heads as the query matrix, key matrix, and value matrix of the corresponding self-attention head.

[0084] Specifically, in the embodiments of the present application, the multi-head self-attention module is trained with the first historical data to achieve the best prediction effect.

[0085] First, an initial query matrix, an initial key matrix, and an initial value matrix for each self-attention head among the multiple self-attention heads are generated. Here, the initial query matrix, initial key matrix, and initial value matrix are randomly generated or pre-configured locally.

[0086] For the detailed description of subsequently inputting the first training data into the convolutional neural network module to obtain multiple second one-dimensional vectors and then inputting the multiple second one-dimensional vectors into the multi-head self-attention module to obtain multiple second output matrices, please refer to the relevant description of inputting the first training data into the convolutional neural network module to obtain multiple first one-dimensional vectors and then inputting the multiple second one-dimensional vectors into the multi-head self-attention module to obtain multiple first output matrices described above, which will not be elaborated here.

[0087] It should be noted that in this embodiment, the predicted electricity price determined according to the multiple second output matrices is the predicted electricity price for the first historical period corresponding to the first validation data, that is to say, in the embodiments of the present application, the convolutional neural network-multi-head self-attention model predicts the historical electricity price data in the first validation data.

[0088] Therefore, the prediction error index between the predicted electricity price calculated here and the historical electricity price data corresponding to the first verification data can reflect the prediction accuracy of the convolutional neural network-multi-head self-attention model.

[0089] Exemplarily, the prediction error index is evaluated by calculating the mean absolute percentage error (MAPE) and the root mean square error (RMSE) between the predicted electricity price and the historical electricity price data corresponding to the first verification data.

[0090] First, the calculation of the mean absolute percentage error (MAPE) is described as shown in the following formula (12):

[0091]

[0092] Second, the calculation of the root mean square error (RMSE) is described as shown in the following formula (13):

[0093]

[0094] In formulas (12) and (13), HEP(t) real represents the historical electricity price data at time t; HEP(t) predict represents the predicted electricity price at time t; N represents the number of samples, that is, the total number of time steps.

[0095] These two indicators can be used in combination to comprehensively evaluate the performance of the prediction model. MAPE provides a relative scale of the error, while RMSE provides an absolute scale of the error. Through these two indicators, the performance of the prediction model in different aspects can be understood, so as to make targeted improvements and optimizations.

[0096] It is judged whether the predicted electricity price meets the stop condition of the multi-head self-attention module according to the prediction error index. Specifically, it can be judged by calculating the difference between the prediction error index and the preset prediction error index.

[0097] If the difference between the prediction error index and the preset prediction error index is not less than the third preset threshold, it is judged that the predicted electricity price does not meet the stop condition of the multi-head self-attention module. At this time, the initial query matrix, the initial key matrix, and the initial value matrix of multiple self-attention heads are adjusted according to the preset dot product scaling factor and the prediction error index.

[0098] It should be noted that as shown in formula (8), when adjusting the query matrix and the key matrix, some relatively large values may be obtained, which makes the gradient of the softmax function become small, thereby affecting the training effect. To avoid this problem, the dot product result is usually divided by a scaling factor thus solving the problem of gradient disappearance or explosion in the convolutional neural network-multi-head self-attention model.

[0099] If the gap between the predicted error index and the preset predicted error index is less than the third preset threshold, it is determined that the predicted electricity price meets the stop condition of the multi-head self-attention module. Then, the initial query matrix, initial key matrix, and initial value matrix of each self-attention head among the multiple self-attention heads are determined as the query matrix, key matrix, and value matrix of the corresponding self-attention head.

[0100] Furthermore, the adjustment of the initial query matrix, initial key matrix, and initial value matrix of the multiple self-attention heads according to the preset dot product scaling factor and the predicted error index needs to be performed multiple times. If the predicted electricity price still does not meet the stop condition of the multi-head self-attention module after the number of adjustments exceeds the preset number of times. Then, the convolutional kernel weights of the convolutional neural network module are iterated, and when the fluctuation of the electricity price prediction value decreases after multiple iterations, the final prediction value is output.

[0101] It can be seen that in the embodiment of the present application, by using the first historical data to adjust the query matrix, key matrix, and value matrix in the multi-head self-attention module, the accuracy of the prediction result is further improved. During the adjustment process, the problem of gradient disappearance or explosion is solved by the scaling factor.

[0102] Embodiment 2:

[0103] The above application embodiment describes a method for predicting the electricity price at the target moment through the first historical data. Based on this, in the embodiment of the present application, a method for predicting the electricity price in combination with the second historical data is also provided. Please refer to Figure 4 , Figure 4 which is a schematic flowchart of another electricity price prediction method provided by the embodiment of the present application, including steps S401 - S405:

[0104] S401: Obtain multiple pieces of second historical data, where the second historical data includes historical electricity price data and electricity price-related data corresponding to different second historical periods.

[0105] Specifically, the second historical data respectively includes historical electricity price data and electricity price-related data in a different second historical period, and the second historical period is before the target period.

[0106] S402: Determine the correlation degree between the multiple pieces of second historical data and the target electricity price data.

[0107] Specifically, the correlation degree between the second historical data and the target electricity price data here is determined by various characteristics of the second historical data, and is specifically obtained by weighted calculation after quantifying characteristics such as the time difference between the second historical period corresponding to the historical second historical data and the target period, the types, quantities, and completeness of the electricity price-related data included in the second historical data. The smaller the time difference between the second historical period corresponding to the second historical data and the target period, the higher the correlation degree between the second historical data and the target electricity price data; the more the types, quantities, and completeness of the electricity price-related data included in the second historical data, the higher the correlation degree between the second historical data and the target electricity price data.

[0108] S403: Determine the second historical period with a correlation degree greater than the first preset threshold as the first historical period.

[0109] Exemplarily, please refer to Figure 5 , Figure 5 , which is a schematic diagram of the process for determining the first historical period provided by an embodiment of the present application. It can be seen that it includes 5 second historical periods with equal durations, namely 0 - t1, t1 - t2, t2 - t3, t3 - t4, t4 - t5. Among them, t5 - t6 is the target period. Among them, the correlation degrees of the three time periods t1 - t2, t3 - t4, and t4 - t5 are greater than the first preset threshold. Therefore, as Figure 5 shown, among the 5 second historical periods, the three time periods t1 - t2, t3 - t4, and t4 - t5 are the first historical periods, and the data within the three time periods t1 - t2, t3 - t4, and t4 - t5 are also the first historical data.

[0110] S404: Obtain the first historical data, where the first historical data includes historical electricity price data and electricity price-related data corresponding to the first historical period, and the electricity price-related data includes weather data, temperature data, and actual load data.

[0111] S405: Input the first historical data into the convolutional neural network - multi-head self-attention model to obtain the predicted target electricity price data for the target period, where the target period is after the first historical period.

[0112] For the detailed description of steps S404 - S405, please refer to the relevant content of steps S201 - S202, which will not be elaborated here.

[0113] It can be seen that in the embodiment of the present application, by determining the data with a correlation degree higher than the first preset threshold with the target electricity price data from multiple second historical data as the first historical data, the amount of data that the convolutional neural network - multi-head self-attention model needs to process is reduced, the data quality of the input convolutional neural network - multi-head self-attention model is improved, and thus the training efficiency of the model and the accuracy of model prediction are improved.

[0114] Embodiment Three:

[0115] The above application example describes a method for predicting electricity prices that screens input data based on the correlation between multiple second historical data and target electricity price data. Based on this, in the embodiments of the present application, a method for predicting electricity prices that includes more detailed screening of input data is also provided. Please refer to Figure 6 , Figure 6 which is a schematic flowchart of another method for predicting electricity prices provided by the embodiments of the present application, including steps S601 - S606:

[0116] S601: Obtain multiple second historical data, where the second historical data includes historical electricity price data and electricity price - related data corresponding to different second historical periods.

[0117] S602: Determine the correlation degrees between multiple second historical data and the historical electricity price data of the target historical period respectively, where the target historical period is the period closest to the target period among the multiple second historical periods.

[0118] Specifically, in this embodiment, the correlation degree between the second historical data and the target electricity price data of the target period will be calculated by comprehensively considering the actually existing second historical data and the target electricity price data.

[0119] However, since the target electricity price data of the period cannot be directly obtained, the historical electricity price data of the target historical period with the smallest time difference from the target period is used here to replace the historical electricity price data.

[0120] Specifically, the correlation degrees between multiple second historical data and the historical electricity price data of the target historical period can be calculated by comprehensively evaluating the time proximity and feature similarity of the historical data.

[0121] In addition, it should be noted that among the correlation degrees between multiple second historical data and the historical electricity price data of the target historical period determined here, it is not necessary to determine the correlation degree between the corresponding second historical data of the target historical period and the historical electricity price data of the target historical period.

[0122] In some possible embodiments, determining the correlation degrees between multiple historical periods and the target historical period according to the historical electricity price data - related data of multiple historical periods includes: calculating the mutual information values between multiple second historical data and the historical electricity price data of the target historical period respectively, where the mutual information value is used to characterize the correlation degree between the corresponding historical data and the historical electricity price data of the target historical period; determining the correlation degrees between multiple second historical periods and the target historical period according to the mutual information values.

[0123] Specifically, in the embodiments of the present application, the correlation degree between multiple second historical periods and the target historical period is determined by calculating the mutual information values of multiple second historical data and the historical electricity price data of the target historical period. Mutual Information (MI for short) is a concept in information theory used to measure the degree of mutual correlation between two random variables. In the fields of machine learning and feature selection, mutual information is often used to evaluate the correlation between a feature and a target variable for feature selection.

[0124] Exemplarily, for two random variables, the mutual information between X (historical electricity price data of the target historical period) and Y (one type of data in the second historical data) is calculated by the following formula (14):

[0125]

[0126] Where: p(x,y) is the joint probability distribution of X and Y obtaining specific values x and y simultaneously; p(x) and p(y) are the marginal distributions of X and Y respectively.

[0127] To measure the correlation between electricity prices and load demands at different time points; in the scenario of electricity price prediction, x and y respectively represent the specific values of electricity price data and the second historical data (such as load data, weather data, etc.).

[0128] In addition, regarding the load data, it should be noted that in time series prediction, there is usually a lag effect between electricity prices and load demands. For example, the mutual information between the electricity price and the load demand for the first lag value is expressed as MI{HEP(t - 1); HED(t)}.

[0129] Based on the above formula (14), the mutual information values of multiple second historical data and the historical electricity price data of the target historical period can be obtained. Thus, by performing a weighted sum of the mutual information values of all data in each second historical data, the mutual information value of each second historical data and the historical electricity price data of the target historical period can be obtained.

[0130] Furthermore, the mutual information value of each second historical data and the historical electricity price data of the target historical period can be directly determined as the correlation degree between each second historical period and the target historical period.

[0131] In a possible embodiment, before calculating the mutual information values between multiple pieces of second historical data and the historical electricity price data of the target historical period respectively, the method further includes: determining the data type of the second historical data, where the data type includes skewed distribution or symmetric distribution; if the data type of the second historical data is skewed distribution, preprocessing the second historical data based on Box-Cox or Yeo-Johnson logarithmic transformation, and if the data type of the second historical data is symmetric distribution, preprocessing the second historical data using min-max scaling.

[0132] It can be seen that in the embodiment of the present application, based on the data type of the second historical data, a preprocessing method matching the type of the second historical data is selected to preprocess the second historical data. For the second historical data with skewed distribution, after preprocessing, it can be made closer to the normal distribution, thereby improving the performance of the model.

[0133] In some possible embodiments, determining the correlation degree between multiple second historical periods and the target historical period according to the mutual information value includes: determining the second historical data with the mutual information value higher than the second preset threshold as the second training data, and determining the historical electricity price data of the target historical period as the second verification data; training the neural network model according to the second training data and the second verification data so that the neural network model can predict the second verification data based on the second training data after training; obtaining the calculation weights of the electricity price-related data of multiple second historical periods with the mutual information value higher than the preset threshold in the neural network model, where the calculation weights are determined during the training process of the neural network model; determining the correlation degree between the corresponding second historical period and the target historical period according to the calculation weights, and the calculation weights are positively correlated with the corresponding correlation degree.

[0134] Specifically, in the embodiment of the present application, the second historical data with the mutual information value higher than the second preset threshold is determined as the second training data, and the historical electricity price data of the target historical period is determined as the second verification data; the second training data and the second verification data are used to train the application network model.

[0135] The second historical data is calculated through each layer (input layer, hidden layer, and output layer) of the neural network model, where the input layer to the hidden layer is as shown in the following formula (15):

[0136]

[0137] Where: is the weight value from the input layer i to the hidden layer j; X i is the i-th subset of the input feature set X; b j is the bias of the hidden layer j; σ is the activation function; h j is the neuron corresponding to the hidden layer j; NV is the total number of input feature subsets.

[0138] The connection from the hidden layer to the output layer is as shown in Equation (16):

[0139]

[0140] Where: is the weight value from hidden layer j to output layer o; h j is the neuron corresponding to hidden layer j; b o is the bias of output layer o; σ is the activation function; H is the total number of hidden layers; refers to the neurons in the output layer.

[0141] It should be noted that the activation function, such as the SeLU function (Scaled Exponential Linear Unit), introduces non-linearity, enabling the network to learn and represent more complex patterns and relationships. It can keep the neural network at zero mean and unit variance during training, which helps to speed up the training process and improve the stability of the network.

[0142] Through the above process, the output layer of the neural network model outputs the predicted electricity price data of the neural network model. Here, the predicted electricity price data is the prediction of the electricity price data in the second historical period corresponding to the second validation data.

[0143] The neural network model is trained according to the second training data and the second validation data. Specifically, after the neural network model outputs the predicted electricity price data, the predicted electricity price data of the neural network model is verified through the second validation data, so as to continuously adjust the calculation weights (i.e., and ) assigned by the neural network model to each second historical data, so that the loss function converges.

[0144] When the loss function converges, the training ends. At this time, the calculation weights of the electricity price-related data in multiple second historical periods with mutual information values higher than the preset threshold in the neural network model are obtained.

[0145] The correlation degree between the corresponding second historical period and the target historical period is determined according to the calculation weights, and the calculation weights are positively correlated with the corresponding correlation degree.

[0146] It can be seen that in the embodiments of the present application, by calculating mutual information and / or obtaining the weights in the neural network model to calculate the correlation degree between multiple second historical periods and the target electricity price data, the first historical data with a higher correlation degree with the target electricity price data can be determined from multiple second historical periods, thereby reducing the amount of data that the convolutional neural network - multi-head self-attention model needs to process, improving the data quality input into the convolutional neural network - multi-head self-attention model, and further improving the training efficiency of the model and the accuracy of model prediction.

[0147] S603: Determine the correlation degree between the historical electricity price data of multiple second historical periods and the target historical period as the correlation degree with the target electricity price data.

[0148] The correlation degree between the historical electricity price data of multiple second historical periods and the target historical period will be determined as the correlation degree between multiple second historical periods and the target electricity price data.

[0149] S604: Determine the second historical periods with a correlation degree greater than the first preset threshold as the first historical periods.

[0150] S605: Obtain the first historical data, where the first historical data includes the historical electricity price data corresponding to the first historical period and electricity price-related data, and the electricity price-related data includes weather data, temperature data, and actual load data.

[0151] S606: Input the first historical data into the convolutional neural network - multi-head self-attention model to obtain the predicted target electricity price data for the target period, where the target period is after the first historical period.

[0152] For the detailed descriptions of steps S601 and steps S604 - S606, please refer to steps S401 - S405 and related content, which will not be elaborated here.

[0153] By implementing the method in the above application embodiments, it can be seen that by processing the first historical data through the convolutional neural network - multi-head self-attention model, the multi-head self-attention considers the correlation between different data in the input data, improving the accuracy of the final target electricity price data. Adjusting the query matrix, key matrix, and value matrix in the multi-head self-attention module through the first historical data improves the accuracy of the prediction result. During the adjustment process, the problem of gradient disappearance or explosion is solved through the scaling factor. Determining the data with a correlation degree higher than the first preset threshold with the target electricity price data from multiple second historical data as the first historical data improves the training efficiency of the model and the accuracy of model prediction. Calculating the mutual information and / or obtaining the weights in the neural network model to calculate the correlation degree between multiple second historical periods and the target electricity price data improves the training efficiency of the model and the accuracy of model prediction.

[0154] Based on the description of the above configuration method embodiments, the present application also provides an electricity price prediction device 700, and the electricity price prediction device 700 can be a computer program (including program code) running in Figure 1 the prediction terminal 101 shown, and is used to execute Figure 2 , Figure 4 and Figure 6 the methods shown. Please refer to Figure 7 , Figure 7A structural schematic diagram of a power price prediction device provided by an embodiment of this application. The power price prediction device 700 includes:

[0155] An acquisition unit 701, configured to acquire first historical data. The first historical data includes historical power price data corresponding to a first historical period and power price-related data. The power price-related data includes weather data, temperature data, and actual load data.

[0156] A prediction unit 702, configured to input the first historical data into a convolutional neural network-multi-head self-attention model to obtain predicted target power price data for a target period, where the target period is after the first historical period.

[0157] In a possible embodiment, the convolutional neural network-multi-head self-attention model includes a convolutional neural network module and a multi-head self-attention module. The multi-head self-attention module includes multiple self-attention heads. In terms of inputting the first historical data into the convolutional neural network-multi-head self-attention model to obtain the predicted target power price data for the target period, the prediction unit 702 is further specifically configured to: input the first historical data into the convolutional neural network module to obtain multiple first one-dimensional vectors, where the first one-dimensional vectors correspond one-to-one to the historical power price data, weather data, temperature data, and actual load data in the first historical data; input the multiple first one-dimensional vectors into the multi-head self-attention module to obtain multiple first output matrices; each self-attention head includes a corresponding query matrix, key matrix, and value matrix, and the multiple first output matrices correspond one-to-one to the multiple self-attention heads; determine the target power price data for the target period according to the multiple first output matrices.

[0158] In a possible embodiment, the prediction unit 702 is further specifically configured to: generate an initial query matrix, an initial key matrix, and an initial value matrix for each of the multiple self-attention heads; generate first training data and first validation data according to the first historical data; input the first training data into the convolutional neural network module to obtain multiple second one-dimensional vectors, where the second one-dimensional vectors correspond one-to-one to the historical electricity price data, weather data, temperature data, and actual load data in the first training data; input the multiple second one-dimensional vectors into the multi-head self-attention module, so that each of the multiple self-attention heads generates a corresponding second output matrix according to the corresponding initial query matrix, initial key matrix, initial value matrix, and second one-dimensional vector; determine the predicted electricity price for the first historical period corresponding to the first validation data according to the second output matrices generated by the multiple self-attention heads; calculate the prediction error index between the predicted electricity price and the historical electricity price data corresponding to the first validation data; determine whether the predicted electricity price meets the stop condition of the multi-head self-attention module according to the prediction error index; if the stop condition of the multi-head self-attention module is not met, adjust the initial query matrix, initial key matrix, and initial value matrix of the multiple self-attention heads according to the preset dot product scaling factor and the prediction error index; if the stop condition of the multi-head self-attention module is met, determine the initial query matrix, initial key matrix, and initial value matrix of each of the multiple self-attention heads as the query matrix, key matrix, and value matrix of the corresponding self-attention head.

[0159] In a possible embodiment, the acquisition unit 701 is further specifically configured to: acquire multiple second historical data, where the second historical data includes historical electricity price data and electricity price-related data corresponding to different second historical periods; determine the correlation degree between the multiple second historical data and the target electricity price data; determine the second historical period with a correlation degree greater than the first preset threshold as the first historical period.

[0160] In a possible embodiment, in terms of determining the correlation degree between the multiple second historical data and the target electricity price data, the prediction unit 702 is further specifically configured to: respectively determine the correlation degree between the multiple second historical data and the historical electricity price data of the target historical period, where the target historical period is the period closest to the target period among the multiple second historical periods; determine the correlation degree between the multiple second historical periods and the historical electricity price data of the target historical period as the correlation degree with the target electricity price data.

[0161] In a possible embodiment, in terms of determining the correlation degree between the multiple historical periods and the target historical period according to the historical electricity price data-related data of the multiple historical periods, the prediction unit 702 is further specifically configured to: respectively calculate the mutual information values between the multiple second historical data and the historical electricity price data of the target historical period, where the mutual information value is used to characterize the correlation degree between the corresponding historical data and the historical electricity price data of the target historical period; determine the correlation degree between the multiple second historical periods and the target historical period according to the mutual information values.

[0162] In a possible embodiment, in terms of determining the correlation degree between multiple second historical periods and the target historical period according to the mutual information value, the prediction unit 702 is further specifically configured to: determine the second historical data with the mutual information value higher than the second preset threshold as the second training data, and determine the historical electricity price data of the target historical period as the second verification data; train the neural network model according to the second training data and the second verification data, so that the neural network model can predict the second verification data according to the second training data after training; obtain the calculation weights of the electricity price-related data of multiple second historical periods with the mutual information value higher than the preset threshold in the neural network model, and the calculation weights are determined during the training process of the neural network model; determine the correlation degree between the corresponding second historical period and the target historical period according to the calculation weights, and the calculation weights are positively correlated with the corresponding correlation degree.

[0163] Based on the description of the above method embodiments and apparatus embodiments, please refer to Figure 8 , Figure 8 which is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Figure 8 The illustrated electronic device 800 (the electronic device 800 may specifically be a computer device or Figure 1 the illustrated prediction terminal 101) includes a memory 801, a processor 802, a communication interface 803, and a bus 804. Among them, the memory 801, the processor 802, and the communication interface 803 are communicatively connected to each other through the bus 804.

[0164] The memory 801 may be a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM).

[0165] The memory 801 may store a program. When the program code stored in the memory 801 is executed by the processor 802, the processor 802 and the communication interface 803 are used to execute each step of the electricity price prediction method of the embodiment of the present application.

[0166] The processor 802 may adopt a general-purpose central processing unit (CPU), a microcontroller, an application specific integrated circuit (ASIC), a graphics processing unit (GPU), or one or more integrated circuits, and is used to execute relevant programs to implement the functions required to be executed by the units in the electronic device 800 of the embodiment of the present application, or execute the electricity price prediction method of the method embodiment of the present application.

[0167] The processor 802 can also be an integrated circuit chip with the ability to process signals. In the implementation process, each step of the electricity price prediction method of the present application can be completed by the integrated logic circuit of the hardware in the processor 802 or the instructions in the form of software. The above-mentioned processor 802 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microcontroller or the processor can also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as being executed and completed by the hardware decoding processor, or executed and completed by a combination of the hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory 801, and the processor 802 reads the information in the memory 801 and combines its hardware to complete the functions required to be executed by the units included in the electronic device 800 in the embodiments of the present application, or executes the electricity price prediction method in the method embodiments of the present application.

[0168] The communication interface 803 uses a transceiver device such as, but not limited to, a transceiver to implement the communication between the electronic device 800 and other devices or communication networks. For example, data can be obtained through the communication interface 803.

[0169] The bus 804 can include a path for transmitting information between various components of the electronic device 800 (for example, the memory 801, the processor 802, the communication interface 803).

[0170] It should be noted that although Figure 8 the shown electronic device 800 only shows the memory 801, the processor 802, and the communication interface 803, in the specific implementation process, those skilled in the art should understand that the electronic device 800 also includes other devices necessary for normal operation. At the same time, according to specific needs, those skilled in the art should understand that the electronic device 800 may also include hardware devices for implementing other additional functions. In addition, those skilled in the art should understand that the electronic device 800 may also only include the devices necessary for implementing the embodiments of the present application, and do not necessarily include Figure 8 all the devices shown in

[0171] An embodiment of the present application also provides a chip, which includes a processor and a data interface. The processor reads instructions stored on a memory through the data interface to implement the electricity price prediction method described above.

[0172] Optionally, as an implementation manner, the chip may further include a memory, and instructions are stored in the memory. The processor is configured to execute the instructions stored on the memory. When the instructions are executed, the processor is configured to execute the electricity price prediction method described above.

[0173] An embodiment of the present application also provides a computer-readable storage medium, in which instructions are stored. When it runs on a computer or a processor, the computer or the processor is caused to execute one or more steps in any of the above methods.

[0174] An embodiment of the present application also provides a computer program product containing instructions. When the computer program product runs on a computer or a processor, the computer or the processor is caused to execute one or more steps in any of the above methods.

[0175] Those skilled in the art can understand that the functions described in connection with the various illustrative logical blocks, modules, and algorithm steps disclosed herein can be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions described in the various illustrative logical blocks, modules, and steps can be stored or transmitted as one or more instructions or codes on a computer-readable medium and executed by a hardware-based processing unit. The computer-readable medium can include a computer-readable storage medium corresponding to a tangible medium, such as a data storage medium, or a communication medium including any medium that facilitates the transfer of a computer program from one place to another (e.g., based on a communication protocol). In this way, the computer-readable medium generally corresponds to (1) a non-transitory tangible computer-readable storage medium, or (2) a communication medium, such as a signal or a carrier wave. The data storage medium can be any available medium that can be accessed by one or more computers or one or more processors to retrieve instructions, codes, and / or data structures for implementing the techniques described in the present application. The computer program product can include a computer-readable medium.

[0176] By way of example and not limitation, such computer-readable storage media can include RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, flash memory, or any other medium that can be used to store the desired program code in the form of instructions or data structures and that can be accessed by a computer. Also, any connection is properly termed a computer-readable medium. For example, if instructions are transmitted using coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of the medium. However, it should be understood that the computer-readable storage media and data storage media do not include connections, carrier waves, signals, or other transient media, but rather are directed to non-transitory tangible storage media. As used herein, disk and optical disks include compact disk (CD), laser disk, optical disk, digital versatile disk (DVD), and Blu-ray disk, where disks typically reproduce data magnetically, while optical disks utilize lasers to optically reproduce data. Combinations of the above should also be included within the scope of computer-readable media.

[0177] Instructions can be executed by one or more processors, such as one or more digital signal processors (DSPs), general purpose microcontrollers, application specific integrated circuits (ASICs), field programmable gate arrays (FPGAs), or other equivalent integrated or discrete logic circuitry. Thus, the term "processor" as used herein can refer to any of the foregoing structures or any other structure suitable for implementing the techniques described herein. Additionally, in some aspects, the functions described for the various illustrative logical blocks, modules, and steps can be provided within dedicated hardware and / or software modules configured for encoding and decoding, or incorporated in a combined codec. Moreover, the techniques can be fully implemented in one or more circuits or logic elements.

[0178] The techniques of this application can be implemented in a variety of apparatus or devices, including a wireless handset, an integrated circuit (IC), or a group of ICs (e.g., a chip set). The various components, modules, or units described in this application are described to emphasize functional aspects of the apparatus for performing the disclosed techniques, but need not be implemented by different hardware units. In fact, as described above, the various units can be combined in a coded hardware unit with suitable software and / or firmware, or provided by interoperating hardware units, including one or more processors as described above.

[0179] Those skilled in the art can clearly understand that for the convenience and conciseness of description, the specific working processes of the systems, devices, and units described above can refer to the specific descriptions of the corresponding steps in the foregoing method embodiments, and will not be elaborated herein.

[0180] It should be understood that in the description of this application, unless otherwise specified, " / " indicates that the objects associated before and after are in an "or" relationship. For example, A / B can represent A or B; where A and B can be singular or plural. Also, in the description of this application, unless otherwise specified, "a plurality of" means two or more than two. "At least one (item)" or its similar expressions refer to any combination of these items, including any combination of a single item or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, a - b, a - c, b - c, or a - b - c, where a, b, and c can be single or multiple. Additionally, for the convenience of clearly describing the technical solutions of the embodiments of this application, in the embodiments of this application, terms such as "first" and "second" are used to distinguish between identical or similar items with basically the same functions and roles. Those skilled in the art can understand that terms such as "first" and "second" do not limit the quantity and execution order, and "first" and "second" do not necessarily mean different. At the same time, in the embodiments of this application, words such as "exemplary" or "for example" are used to represent examples, illustrations, or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary" or "for example" is intended to present relevant concepts in a specific manner for easy understanding.

[0181] In several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the division of the unit is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The couplings, direct couplings, or communication connections shown or discussed with each other can be through some interfaces, and the indirect couplings or communication connections of devices or units can be in electrical, mechanical, or other forms.

[0182] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0183] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions according to the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired manner (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or a wireless manner (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more integrated available media. The available medium can be a read-only memory (ROM), a random access memory (RAM), a magnetic medium, such as a floppy disk, a hard disk, a magnetic tape, a magnetic disk, or an optical medium, such as a digital versatile disc (DVD), or a semiconductor medium, such as a solid state disk (SSD), etc.

[0184] As described above, it is only the specific implementation manners of the embodiments of the present application, but the protection scope of the embodiments of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the embodiments of the present application should be covered by the protection scope of the embodiments of the present application. Therefore, the protection scope of the embodiments of the present application should be subject to the protection scope of the claims.

[0185] The device embodiments described above are merely illustrative. The units and modules described as separate components may or may not be physically separated. Additionally, some or all of the units and modules can be selected according to actual needs to achieve the objectives of the solutions of this embodiment. A person of ordinary skill in the art can understand and implement it without creative efforts.

[0186] The above description is only the specific implementation manners of the present application. It should be noted that for those of ordinary skill in the art in the technical field of the present application, without departing from the principle of the present application, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present application.

Claims

1. A method for predicting electricity prices, characterized in that, The method includes: Obtaining first historical data, where the first historical data includes historical electricity price data corresponding to a first historical period and electricity price-related data, and the electricity price-related data includes weather data, temperature data, and actual load data; Inputting the first historical data into a convolutional neural network-multi-head self-attention model to obtain target electricity price data for a target period, where the target period is after the first historical period.

2. The method according to claim 1, wherein The convolutional neural network-multi-head self-attention model includes a convolutional neural network module and a multi-head self-attention module. The multi-head self-attention module includes multiple self-attention heads. Inputting the first historical data into the convolutional neural network-multi-head self-attention model to obtain target electricity price data for a target period includes: Inputting the first historical data into the convolutional neural network module to obtain multiple first one-dimensional vectors, where the first one-dimensional vectors correspond one-to-one to the historical electricity price data, weather data, temperature data, and actual load data in the first historical data; Inputting the multiple first one-dimensional vectors into the multi-head self-attention module to obtain multiple first output matrices; where each self-attention head includes a corresponding query matrix, key matrix, and value matrix, and the multiple first output matrices correspond one-to-one to the multiple self-attention heads; Determining the target electricity price data for the target period according to the multiple first output matrices.

3. The method according to claim 2, wherein The method further includes: Generating an initial query matrix, an initial key matrix, and an initial value matrix for each self-attention head in the multiple self-attention heads; Generating first training data and first validation data according to the first historical data; Inputting the first training data into the convolutional neural network module to obtain multiple second one-dimensional vectors, where the second one-dimensional vectors correspond one-to-one to the historical electricity price data, weather data, temperature data, and actual load data in the first training data; Inputting the multiple second one-dimensional vectors into the multi-head self-attention module so that the multiple self-attention heads respectively generate corresponding second output matrices according to the corresponding initial query matrix, initial key matrix, initial value matrix, and the second one-dimensional vectors; Determining the predicted electricity price for the first historical period corresponding to the first validation data according to the second output matrices generated by the multiple self-attention heads; Calculating a prediction error index between the predicted electricity price and the historical electricity price data corresponding to the first validation data; Judging whether the predicted electricity price meets the stop condition of the multi-head self-attention module according to the prediction error index; If the stop condition of the multi-head self-attention module is not met, adjusting the initial query matrix, initial key matrix, and initial value matrix of the multiple self-attention heads according to a preset dot product scaling factor and the prediction error index; If the stop condition of the multi-head self-attention module is met, determining the initial query matrix, initial key matrix, and initial value matrix of each self-attention head in the multiple self-attention heads as the query matrix, key matrix, and value matrix corresponding to the self-attention head.

4. The method according to any one of claims 1-3, characterized in that, The method further includes: Obtaining multiple second historical data, where the second historical data includes historical electricity price data and electricity price-related data corresponding to different second historical periods; Determine the correlation degree between the multiple second historical data and the target electricity price data; Determine the second historical period with the correlation degree greater than the first preset threshold as the first historical period.

5. The method according to claim 4, wherein The determination of the correlation degree between the multiple second historical data and the target electricity price data includes: Respectively determine the correlation degree between the multiple second historical data and the historical electricity price data of the target historical period, where the target historical period is the period closest to the target period among the multiple second historical periods; Determine the correlation degree between the multiple second historical periods and the historical electricity price data of the target historical period as the correlation degree with the target electricity price data.

6. The method according to claim 5, wherein The determination of the correlation degree between the multiple historical periods and the target historical period according to the relevant data of the historical electricity price data of the multiple historical periods includes: Respectively calculate the mutual information values between the multiple second historical data and the historical electricity price data of the target historical period, where the mutual information value is used to characterize the correlation degree between the corresponding historical data and the historical electricity price data of the target historical period; Determine the correlation degree between the multiple second historical periods and the target historical period according to the mutual information value.

7. The method according to claim 6, wherein The determination of the correlation degree between the multiple second historical periods and the target historical period according to the mutual information value includes: Determine the second historical data with the mutual information value higher than the second preset threshold as the second training data, and determine the historical electricity price data of the target historical period as the second verification data; Train the neural network model according to the second training data and the second verification data, so that the neural network model can predict the second verification data according to the second training data after training; Obtain the calculation weights of the electricity price-related data of the multiple second historical periods with the mutual information value higher than the preset threshold in the neural network model, where the calculation weights are determined during the training process of the neural network model; Determine the correlation degree between the corresponding second historical period and the target historical period according to the calculation weights, and the calculation weights are positively correlated with the corresponding correlation degree.

8. An electricity price prediction device, characterized in that, For executing the electricity price prediction method, the device includes: An acquisition unit, configured to acquire first historical data, where the first historical data includes historical electricity price data and electricity price-related data corresponding to the first historical period, and the electricity price-related data includes weather data, temperature data, and actual load data; A prediction unit, configured to input the first historical data into a convolutional neural network-multi-head self-attention model to obtain the target electricity price data of the predicted target period, where the target period is after the first historical period.

9. An electronic device, characterized in that, It includes a processor, a memory, a communication interface, and one or more programs, where the one or more programs are stored in the memory and are configured to be executed by the processor, and the programs include instructions for executing the steps in the method according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program for electronic data exchange, where the computer program causes the computer to execute the method according to any one of claims 1-7.