A method for electricity price forecasting
Patent Information
- Application Number
- CN202510241935.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-03
- Publication Date
- 2026-09-11
AI Technical Summary
[0002]在电力现货市场中,电价波动受到多种因素影响,例如不同种类电源的发电量、市场用电量和天气状况等等,现货电价的不确定性对发电侧、用电侧以及电力市场运营商提出了更高的要求,其频繁的波动对准确的电价预测带来了挑战,从而影响市场参与者的决策效率和经济收益
Smart Images

Figure CN122736643A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of electricity price analysis and forecasting technology, and in particular to an electricity price forecasting method. Background Technology
[0002] In the electricity spot market, electricity price fluctuations are affected by a variety of factors, such as the generation of different types of power sources, market electricity consumption, and weather conditions. The uncertainty of spot electricity prices places higher demands on the generation side, the consumption side, and electricity market operators. Its frequent fluctuations pose a challenge to accurate electricity price forecasting, thereby affecting the decision-making efficiency and economic benefits of market participants.
[0003] Currently, most spot electricity price forecasting models rely on historical electricity price data for linear extrapolation, failing to fully consider the impact of external factors such as weather changes and changes in supply and demand. They are unable to fully capture the multi-level factors affecting electricity price changes, making it difficult for most forecasting models to adapt to changes in external influencing factors, resulting in a large deviation between the forecast results and the actual electricity price. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide at least one electricity price forecasting method, which uses the LSTM Seq2Seq model architecture to capture the impact of electricity price fluctuation factors on electricity prices, builds a corresponding electricity price forecasting model, and improves the accuracy and flexibility of electricity price forecasting.
[0005] This application mainly includes the following aspects:
[0006] In a first aspect, embodiments of this application provide an electricity price forecasting method, the method comprising: sampling observation data of different electricity price fluctuation influencing factors generated in a given historical period within a specified area according to a given sampling frequency, forming an observation time series corresponding to the electricity price fluctuation influencing factors; constructing feature engineering based on the observation time series corresponding to the electricity price fluctuation influencing factors to form a feature data table, the feature data table including multiple feature columns, each row in the feature data table forming corresponding electricity price forecasting feature data; dividing the electricity price forecasting feature data recorded in the feature data table into multiple input data sets according to a preset ratio and date order based on the number of days corresponding to the electricity price forecasting feature data; and performing LSTM based on the electricity price forecasting feature data corresponding to the input data sets. The Seq2Seq model architecture requires the following data formats: Input samples and output samples are constructed for each input dataset. The output sample is the clearing electricity price sequence corresponding to the prediction time period, and the input samples are the electricity price prediction feature data for each time step within the effective time range preceding the output sample. All input samples and the output samples corresponding to each input sample are divided into multiple data batches according to a preset batch size. Based on the multiple input samples corresponding to each data batch, the output samples corresponding to each input sample, and the LSTM Seq2Seq model architecture, an electricity price prediction model is trained. Based on the electricity price prediction model, the day-ahead clearing electricity price sequence corresponding to the target prediction date is predicted.
[0007] In one possible implementation, the factors influencing electricity price fluctuations include the day-ahead clearing electricity price, and the observation time series includes the observation time series of the day-ahead clearing electricity price. Before constructing feature engineering based on the observation time series corresponding to the factors influencing electricity price fluctuations to form a feature data table, the method further includes: for each factor influencing electricity price fluctuations other than the day-ahead clearing electricity price, performing the following processing: determining whether the given sampling frequency corresponding to the factor influencing electricity price fluctuations is the same as the given sampling frequency corresponding to the day-ahead clearing electricity price; if the given sampling frequency corresponding to the factor influencing electricity price fluctuations is different from the given sampling frequency corresponding to the day-ahead clearing electricity price, then resampling the observation time series corresponding to the factor influencing electricity price fluctuations to unify the observation time series corresponding to the factor influencing electricity price fluctuations to the same sampling frequency as the day-ahead clearing electricity price.
[0008] In one possible implementation, the observation time series includes observed values of the electricity price fluctuation influencing factors under different collection timestamps. Multiple feature columns include multiple first feature columns, wherein the first feature columns are determined as follows: the observation time series are sorted in ascending order according to the collection timestamps to obtain a first processed observation time series; outliers in the first processed observation time series are set to null values to obtain a second processed observation time series; for the observed values under repeated collection timestamps in the second processed observation time series, the target observed value is retained and redundant observed values under repeated collection timestamps are deleted, forming a third processed observation time series; for the third processed observation time series, the cumulative missing value time corresponding to each target unit time is calculated; for each target unit time, if the cumulative missing value time corresponding to that target unit time exceeds a preset time threshold, the observed value under that target unit time is deleted, forming a fourth processed observation time series; the missing values in the fourth processed observation time series are filled using linear interpolation, forming the first feature column corresponding to the electricity price fluctuation influencing factor.
[0009] In one possible implementation, the multiple feature columns further include a second feature column, wherein the second feature column is determined by: aligning different first feature columns according to the acquisition timestamp, forming a data table to be processed from the aligned first feature columns; deleting null rows in the data table to be processed; converting the acquisition timestamp corresponding to each row in the data table to be processed into a standard acquisition time; and forming a second feature column from the standard acquisition time corresponding to each row, wherein the standard acquisition time is a real number.
[0010] In one possible implementation, before forming the feature data table, the method further includes: identifying the observation type corresponding to each first feature column, wherein the first feature column is divided into real number feature columns and category feature columns according to its corresponding observation type, the observation values under the category feature columns are non-real numbers, and the observation values under the real number feature columns are real numbers; performing real number mapping processing on each first feature column to obtain multiple first feature columns after real number mapping processing, wherein the real number mapping processing includes: determining whether the first feature column is a category feature column; if the first feature column is a category feature column, then mapping each observation value under the category feature column to the corresponding label code according to the pre-given mapping relationship between the observation values and the label code under the category feature column, the label code being a real number; if the first feature column is a real number feature column, then no processing is performed.
[0011] In one possible implementation, before forming the feature data table, the method further includes: for each first feature column and each second feature column after real number mapping processing, performing the following processing: obtaining the maximum and minimum observation values under the feature column; for each observation value under the feature column, normalizing the observation value according to the maximum and minimum observation values to obtain a normalized observation value, wherein the normalization process includes: calculating a first difference between the maximum observation value and the observation value and a second difference between the maximum observation value and the minimum observation value respectively, and determining the ratio between the first difference and the second difference as the normalized observation value; determining the corresponding feature column after normalization processing for each normalized observation value.
[0012] In one possible implementation, the effective time range includes multiple effective acquisition days, and the multiple feature columns also include multiple third feature columns. The method further includes: for each first feature column, performing the following steps: for each observation: determining the real-time acquisition day corresponding to the observation and its acquisition timestamp under the real-time acquisition day; determining the observation corresponding to the acquisition timestamp under each effective acquisition day prior to the real-time acquisition day to which the observation belongs as the feature value of the observation; forming multiple third feature columns corresponding to the first feature column from the multiple feature values corresponding to each observation; forming a temporary data table from the multiple first feature columns, multiple second feature columns, and multiple third feature columns corresponding to each first feature column; deleting empty rows in the temporary data table to obtain the feature data table.
[0013] In one possible implementation, the multiple input datasets include at least a training set, and the first feature column includes a day-ahead clearing electricity price column. For each feature column in the training set, the method further includes: for each real-valued feature column, performing the following processing: calculating the Pearson correlation coefficient between the real-valued feature column and the day-ahead clearing electricity price column, where a Pearson correlation coefficient closer to 1 indicates a more positive correlation between the real-valued feature column and the day-ahead clearing electricity price column; a Pearson correlation coefficient closer to -1 indicates a more negative correlation between the real-valued feature column and the day-ahead clearing electricity price column; and a Pearson correlation coefficient closer to 0 indicates a less correlation between the real-valued feature column and the day-ahead clearing electricity price column; determining whether the absolute value of the Pearson correlation coefficient is less than a preset correlation threshold; and deleting the real-valued feature column from the training set if the absolute value of the Pearson correlation coefficient is less than the preset correlation threshold.
[0014] In one possible implementation, the multiple input datasets include a training set, a validation set, and a test set, wherein the data dates of the training set are earlier than those of the validation set, and the data dates of the validation set are earlier than those of the test set.
[0015] In one possible implementation, multiple input training samples and multiple output samples corresponding to each training set, validation set, and test set are constructed as follows: A target sliding window is initialized, with a length equal to the first time step within the effective time range, the total number of time steps between the second and third time steps corresponding to the prediction date, and the third time step being the number of time steps between the closing time of the trading window before the prediction date and 00:00 on the prediction date. The target sliding window width is equal to the number of feature columns in the input dataset. In the training set, the target sliding window is slid from the first total time step of the training set to the last total time step of the training set according to the first sliding step size. In the validation set, the target sliding window is moved from the last fourth time step in the training set to the last total time step in the validation set by a second sliding step, where the fourth time step is equal to the sum of the first and third time steps. In the test set, the target sliding window is moved from the last fourth time step in the validation set to the last total time step in the test set by a second sliding step. For each sliding of the target sliding window, the input sample is formed by multiple electricity price prediction feature data corresponding to the first time step within the target sliding window, and the output sample is formed by multiple electricity price prediction feature data corresponding to the last second time step within the target sliding window.
[0016] In one possible implementation, the method further includes: for each input data set, dividing the multiple input samples and multiple output samples corresponding to the input data set into multiple data batches; forming an input training set from the input samples under each data batch, wherein the input samples include multiple electricity price prediction feature data within the effective time range before the prediction date; and forming an output training set from the output samples under each data batch, wherein the output samples include the spot market clearing price time series corresponding to the prediction date.
[0017] In one possible implementation, the LSTM Seq2Seq model architecture includes an encoder and a decoder. The electricity price prediction model is trained and generated as follows: All corresponding data batches are retrieved from the training set, and a round of optimization training is performed on the LSTM Seq2Seq model architecture. For each data batch, the following steps are performed: the data batch is input into the encoder, which performs feature mapping and time-series computation on the data batch to obtain the first input data, hidden state, and cell state; the first input data, hidden state, and cell state corresponding to the data batch are input into the decoder for decoding loop to obtain multiple predicted output columns corresponding to each input sample in the data batch; a specified day-ahead electricity price prediction feature column is selected from the multiple predicted output columns as the day-ahead electricity price prediction time series corresponding to the input sample; the LSTM Seq2Seq model parameters are optimized based on the error between the day-ahead electricity price prediction time series corresponding to each input sample in the data batch and the output sample; after completing one round of optimization training, the optimized LSTM Seq2Seq model architecture is validated using a validation set. If the validation passes, the LSTM Seq2Seq training ends. The Seq2Seq model architecture is trained to obtain the electricity price prediction model. If the validation fails, all data batches are retrieved from the training set again to train the LSTM Seq2Seq model architecture for a new round.
[0018] In one possible implementation, the process of validating the optimized LSTM Seq2Seq model architecture using a validation set includes: for each input sample in the validation set, inputting the input sample into the optimized LSTM Seq2Seq model architecture to obtain the day-ahead electricity price forecast time series corresponding to the input sample; for each input sample, calculating multiple error values between the day-ahead electricity price forecast time series corresponding to the input sample and the output sample; if the minimum error value is less than or equal to a preset error threshold, then ending the training of the LSTM Seq2Seq model architecture to obtain the electricity price forecast model, wherein the preset error threshold is generated by a custom error threshold generation mechanism; if the minimum error value is greater than the preset error threshold, then retrieving all data batches from the training set to perform a new round of training on the LSTM Seq2Seq model architecture.
[0019] In one possible implementation, the method further includes: inputting input samples from the test set into the electricity price prediction model to obtain the day-ahead electricity price prediction time series corresponding to each input sample; for each input sample in the test set corresponding to the day-ahead electricity price prediction time series and the output sample, inputting the day-ahead electricity price prediction value at the time step corresponding to the input sample and the day-ahead electricity price observation value at the corresponding time step of the output sample into a preset evaluation function to generate the prediction accuracy evaluation result corresponding to the electricity price prediction model.
[0020] This application provides an electricity price forecasting method, comprising: forming a feature data table based on the observation time series corresponding to factors influencing electricity price fluctuations; dividing the electricity price forecasting feature data recorded in the feature data table into multiple input data sets according to a preset ratio and date order, based on the number of days corresponding to the electricity price forecasting feature data; constructing input samples corresponding to each input data set and output samples corresponding to each input sample based on the electricity price forecasting feature data corresponding to the input data sets; training and generating an electricity price forecasting model based on the multiple input samples corresponding to each input data set, the output samples corresponding to each input sample, and an LSTM Seq2Seq model architecture; and forecasting the day-ahead clearing electricity price sequence corresponding to the target forecast date based on the electricity price forecasting model. By capturing the impact of factors influencing electricity price fluctuations on electricity prices through the LSTM Seq2Seq model architecture, and building a corresponding electricity price forecasting model, the accuracy and flexibility of electricity price forecasting are improved.
[0021] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0022] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 A flowchart of an electricity price forecasting method provided in an embodiment of this application is shown;
[0024] Figure 2 This paper illustrates a functional block diagram of an electricity price forecasting device provided in an embodiment of this application;
[0025] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0027] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0028] Currently, most spot electricity price forecasting models rely on linear extrapolation of historical electricity price data, failing to fully consider the impact of external factors such as weather changes and supply-demand relationship changes. They are unable to fully capture the multi-level factors affecting electricity price changes, making it difficult for most forecasting models to adapt to changes in external influencing factors. This results in a large deviation between the forecast results and the actual electricity price. Even if some models take into account the impact of weather changes and supply-demand relationship on electricity price changes, the forecasting errors of future weather, future power generation, and future electricity consumption will further cause greater errors in electricity price forecasting.
[0029] Based on this, this application provides an electricity price prediction method. It uses an LSTM Seq2Seq model architecture to capture the impact of electricity price fluctuation factors on electricity prices, and builds a corresponding electricity price prediction model to improve the accuracy and flexibility of electricity price prediction. The details are as follows:
[0030] Please see Figure 1 , Figure 1 This is a flowchart illustrating an electricity price forecasting method provided in an embodiment of this application. Figure 1 As shown, the method provided in this application embodiment includes the following steps:
[0031] S100. Within the designated area, according to the given sampling frequency, sample the observation data of different electricity price fluctuation influencing factors generated in a given historical period to form the observation time series corresponding to the electricity price fluctuation influencing factors.
[0032] S200. Based on the observation time series corresponding to the factors affecting electricity price fluctuations, feature engineering is constructed to form a feature data table.
[0033] The feature data table includes multiple feature columns, and each row in the feature data table forms the corresponding electricity price prediction feature data.
[0034] S300: Based on the number of days corresponding to the electricity price forecast feature data, the electricity price forecast feature data recorded in the feature data table is divided into multiple input data sets according to a preset ratio and date order.
[0035] S400. Based on the electricity price prediction feature data corresponding to the input data set, construct the input samples corresponding to each input data set and the output samples corresponding to each input sample according to the data format required by the LSTM Seq2Seq model architecture.
[0036] The output sample is the clearing electricity price sequence corresponding to the prediction time period, and the input sample is the electricity price prediction feature data corresponding to each time step within the effective time range before the output sample.
[0037] S500: Divide all input samples of the input data set and the output samples corresponding to each input sample into multiple data batches according to a preset batch size.
[0038] The S600, based on multiple input samples corresponding to each data batch, output samples corresponding to each input sample, and the LSTM Seq2Seq model architecture, trains and generates an electricity price prediction model.
[0039] S700, based on the electricity price forecasting model, predicts the spot market clearing price sequence corresponding to the target forecast date.
[0040] In step S100, the factors affecting electricity price fluctuations include, but are not limited to, at least one of the following: the day-ahead clearing electricity price, the total output power of wind power, the total output power of photovoltaic power, the total output power of non-wind and solar power sources, and meteorological factors, as shown in Table 1, which is a table of meteorological factors.
[0041] Table 1
[0042] temperature real numbers humidity real numbers wind speed real numbers wind direction category air pressure real numbers direct normal radiation real numbers Horizontal scattered radiation real numbers Global horizontal radiation real numbers
[0043] As shown in Table 1, meteorological factors affecting clearing electricity prices include, but are not limited to, at least one of the following: temperature, humidity, wind speed, wind direction, air pressure, DNI (Direct Normal Irradiance), DHI (Diffuse Horizontal Irradiance), and GHI (Global Horizontal Irradiance). Table 1 also describes the observation types corresponding to different meteorological factors. The observation types include real number types (represented by numerical values) and category types (represented by non-numerical values). For example, for temperature, the corresponding observation type is real number type, such as 24℃, and for wind direction, the observation value is a category type such as east, west, etc.
[0044] After determining the factors influencing electricity price fluctuations, the observed values of these factors are sampled within a specified historical time period according to the given sampling frequency corresponding to each factor. Each sampling is recorded with a corresponding sampling timestamp to form the corresponding observation time series. The historical time period can be one year, and there is no specific restriction. The longer the given time period, the more accurate the subsequent model training will be.
[0045] Please refer to Table 2, which is a table of sampling frequency data corresponding to electricity price fluctuation factors.
[0046] Table 2
[0047] Spot day clearing electricity price sequence 15min Wind power total output time sequence 15min Photovoltaic total output power timing 15min Non-wind and solar power total output power timing 15min Meteorological observation time series 1h
[0048] As shown in Table 2, the time series includes the time series name and sampling frequency. Specifically, according to different factors affecting electricity price fluctuations, the corresponding observation time series includes the spot market day-clearing price time series, the total wind power output time series, the total photovoltaic power output time series, the total non-wind and solar power output time series, and the meteorological observation time series corresponding to each meteorological factor. As shown in Table 2, for the spot market day-clearing price, the corresponding given sampling frequency is 15 minutes, and the given sampling frequency for meteorological factors is 1 hour. That is, this application can specify different sampling frequencies for different factors affecting electricity price fluctuations based on actual needs.
[0049] In a preferred embodiment, before executing step S200, for each electricity price fluctuation influencing factor other than the spot day-clearing electricity price, the following processing is performed: determining whether the given sampling frequency corresponding to the electricity price fluctuation influencing factor is the same as the given sampling frequency corresponding to the spot day-clearing electricity price; if the given sampling frequency corresponding to the electricity price fluctuation influencing factor is different from the given sampling frequency corresponding to the spot day-clearing electricity price, then the observation time series corresponding to the electricity price fluctuation influencing factor is resampled to unify the observation time series corresponding to the electricity price fluctuation influencing factor to the same sampling frequency as the spot day-clearing electricity price.
[0050] In different electricity spot markets, the sampling frequency corresponding to the day-ahead clearing price may be different. For example, it is 1 hour in Germany and 30 minutes in the UK. The timing of various factors affecting electricity price fluctuations needs to be resampled to the sampling frequency corresponding to the day-ahead clearing price in the current electricity spot market.
[0051] In specific implementation, before executing step S200, it is necessary to unify the sampling frequency corresponding to the observation time series of each electricity price fluctuation influencing factor. Specifically, the sampling frequency corresponding to each electricity price fluctuation influencing factor other than the spot day-clearing electricity price should be aligned with the sampling frequency corresponding to the spot day-clearing electricity price. Taking Table 2 as an example, the sampling frequency corresponding to the spot day-clearing electricity price time series in Table 2 is 15 minutes, but the sampling frequency corresponding to the meteorological observation time series is 1 hour. In this case, it is necessary to resample the meteorological observation time series to the same sampling frequency as the spot day-clearing electricity price time series. The resampling rule is to repeat the meteorological observation values recorded in the same hour under the sampling timestamp of the same hour.
[0052] The observation time series includes the observed values of factors affecting electricity price fluctuations at different collection timestamps. Multiple feature columns include multiple first feature columns. In a preferred embodiment, step S200 includes:
[0053] The observation time series are sorted in ascending order according to the collection timestamp to obtain the first processing observation time series. Outliers in the first processing observation time series are set to null values to obtain the second processing observation time series. For the observations under the duplicate collection timestamps in the second processing observation time series, the target observation value is retained and the redundant observations under the duplicate collection timestamps are deleted to form the third processing observation time series. For the third processing observation time series, the cumulative missing value time corresponding to each target unit time is counted. For each target unit time, if the cumulative missing value time corresponding to the target unit time exceeds the preset time threshold, the observations under the target unit time are deleted to form the fourth processing observation time series. The missing values in the fourth processing observation time series are filled by linear interpolation to form the first feature column corresponding to the factors affecting electricity price fluctuations.
[0054] Specifically, for the second processing observation time series, if there are duplicate acquisition timestamps, only the target observation value among the multiple observation values corresponding to the duplicate acquisition timestamps will be retained. The target observation value is the observation value corresponding to the first acquisition timestamp in the duplicate acquisition timestamps.
[0055] For the observations under the third processing observation time series, they can be divided according to the target unit time (e.g., day). The target unit time is the same as the prediction time period. Statistical analysis is performed on multiple observations under each target unit time. For example, if the cumulative missing value in a certain day exceeds 2 hours, the corresponding observations for that day are deleted.
[0056] The multiple feature columns also include a second feature column, which describes the acquisition time corresponding to each observation under the first feature column. In a preferred embodiment, step S200 further includes:
[0057] Align the different first feature columns according to the collection timestamp, form a data table to be processed from the aligned first feature columns, delete the empty rows in the data table to be processed, and convert the collection timestamp corresponding to each row in the data table to the standard collection time, form a second feature column from the standard collection time corresponding to each row, and the standard collection time is a real number.
[0058] Specifically, the format of the standard collection time can be defined according to requirements. The standard collection time is generally represented by a real number. For example, the collection timestamp can be converted according to the rule that the integer part is hours and the decimal part is minutes to obtain the corresponding standard collection time.
[0059] In a preferred embodiment, before forming the feature data table, step S200 further includes:
[0060] The observation type corresponding to each first feature column is identified. The first feature column is divided into real number feature columns and category feature columns according to its corresponding observation type. The observations under the category feature columns are non-real numbers, and the observations under the real number feature columns are real numbers. Real number mapping processing is performed on each first feature column to obtain multiple first feature columns after real number mapping processing. The real number mapping processing includes: determining whether the first feature column is a category feature column. If the first feature column is a category feature column, then according to the pre-given mapping relationship between the observations under the category feature column and the label code, each observation under the category feature column is mapped to the corresponding label code, and the label code is a real number. If the first feature column is a real number feature column, no processing is performed.
[0061] For example, taking the feature column corresponding to wind direction as an example, the corresponding observation value is the wind direction category. Then, for the wind direction feature column, the label coding pool corresponding to the wind direction feature column is determined. The label coding pool includes the label code corresponding to each wind direction category. For each observation value under the wind direction feature column, the observation value is mapped or converted into the corresponding label code in the label coding pool. This makes it easier to perform subsequent calculations and processing and will not result in garbled characters.
[0062] In a preferred embodiment, before forming the feature data table, step S200 further includes:
[0063] For each first feature column and each second feature column after real number mapping, the following processing is performed: obtain the maximum and minimum observed values under the feature column; for each observed value under the feature column, normalize the observed value according to the maximum and minimum observed values to obtain the normalized observed value. The normalization process includes: calculating the first difference between the maximum and the observed value and the second difference between the maximum and the minimum observed value respectively; determining the ratio between the first difference and the second difference as the normalized observed value; and determining the corresponding feature column after normalization for each normalized observed value.
[0064] In one specific embodiment, for each second feature column and each first feature column after real number mapping: Max-min normalization is performed to ensure that all observations of the feature column are scaled to the interval [0, 1]. The observations of each second feature column and each first feature column after real number mapping are normalized using the following formula:
[0065]
[0066] In this formula, x max x represents the maximum observed value corresponding to the first or second feature column. min Let x represent the minimum observed value corresponding to the first or second feature column. normalized This represents the normalized observation value.
[0067] Preferably, the multiple feature columns also include multiple third feature columns, and the effective time range includes multiple effective collection days. In a preferred embodiment, step S200 further includes:
[0068] For each first feature column, perform the following: For each observation: determine the real-time acquisition day corresponding to the observation and its acquisition timestamp under the real-time acquisition day; determine the observation corresponding to the acquisition timestamp under each valid acquisition day before the real-time acquisition day to which the observation belongs as the feature value corresponding to the observation; form multiple third feature columns corresponding to the first feature column from the multiple feature values corresponding to each observation; form a temporary data table from the multiple first feature columns, multiple second feature columns, and multiple third feature columns corresponding to each first feature column; delete the empty rows in the temporary data table to obtain the feature data table.
[0069] In one example, the effective time range is generally 7 days before the real-time collection date to which the collection timestamp belongs. Each day within the effective time range is defined as a valid collection day. In this application, for each observation point in the first feature column, the collection timestamp of the observation point under its real-time collection date is used as the standard. The observation values under the same collection timestamp as the observation point under the 7 valid collection days before the real-time collection date to which the observation point belongs are extracted as the feature values of the observation point. These 7 feature values form 7 new features corresponding to the observation value. And the 7 feature values corresponding to each observation value in the first feature column form 7 third feature columns corresponding to the first feature column.
[0070] Preferably, in step S300, the multiple input data sets include a training set, a validation set, and a test set. In this application, for multiple electricity price prediction feature data in the feature data table, the multiple electricity price prediction feature data are divided into a training set, a validation set, and a test set according to the chronological order of the collection timestamps corresponding to each electricity price prediction feature data, in days / days, with a given division ratio (e.g., 6:2:2). Correspondingly, each input data set also includes multiple first feature columns, second feature columns, and multiple third feature columns, wherein the data dates of the training set are earlier than those of the validation set, and the data dates of the validation set are earlier than those of the test set.
[0071] In a preferred embodiment, the plurality of first feature columns include a spot day-ahead clearing electricity price column. After dividing the data into multiple input sets, the method provided in this application further includes:
[0072] For each feature column in the training set, perform the following: For each real feature column, calculate the Pearson correlation coefficient between the real feature column and the spot day-clearing electricity price column. Determine whether the absolute value of the Pearson correlation coefficient is less than a preset correlation threshold. If the absolute value of the Pearson correlation coefficient is less than the preset correlation threshold, then delete the real feature column from the training set.
[0073] In one specific embodiment, it is assumed that there are N observations under the real-number feature column or N electricity price prediction feature data in the training set, and the average value of the observations under the real-number feature column is... Among them, the observed average value under the spot day-clearing electricity price list is The Pearson correlation coefficient between the real characteristic column and the day-ahead clearing electricity price column is:
[0074]
[0075] Where, ρ XY This represents the Pearson correlation coefficient between the real-valued feature column X and the day-ahead clearing electricity price column Y. i Let y represent the i-th observation in the real number feature column. i This represents the i-th observation in the day-ahead clearing electricity price series.
[0076] Specifically, the closer the Pearson correlation coefficient is to 1, the more positively correlated the real feature column is with the day-ahead clearing electricity price column; the closer the Pearson correlation coefficient is to -1, the more negatively correlated the real feature column is with the day-ahead clearing electricity price column; and the closer the Pearson correlation coefficient is to 0, the less correlated the real feature column is with the day-ahead clearing electricity price column. Generally, the preset correlation threshold is 0.5.
[0077] In a preferred embodiment, step S400 includes:
[0078] Initialize a target sliding window. The length of the target sliding window is the total number of time steps between the first time step within the effective time range and the second and third time steps corresponding to the prediction date. The third time step is the third time step between the closing time of the trading window before the prediction date and 0:00 AM on the prediction date. The width of the target sliding window is the number of feature columns in the input dataset. In the training set, the target sliding window slides from the first total time step to the last total time step of the training set with the first sliding step. In the validation set, the target sliding window slides from the last fourth time step of the training set to the last total time step of the validation set with the second sliding step, where the fourth time step is equal to the sum of the first and third time steps. In the test set, the target sliding window slides from the last fourth time step of the validation set to the last total time step of the test set with the second sliding step. For each slide of the target sliding window, the input sample is formed by multiple electricity price prediction feature data corresponding to the first time step within the target sliding window, and the output sample is formed by multiple electricity price prediction feature data corresponding to the last second time step within the target sliding window.
[0079] In a preferred embodiment, this application mainly creates a corresponding electricity price prediction model based on the LSTM Seq2Seq model architecture. Therefore, this application needs to convert multiple electricity price prediction feature data corresponding to each input data set into a data format supported by the LSTM Seq2Seq model architecture. The format supported by the LSTM Seq2Seq model is input set-output set, where the input set includes multiple input samples and the output set includes output samples corresponding to each input sample.
[0080] In one specific embodiment, the second sliding step size is equal to the second time step number.
[0081] Specifically, each electricity price forecast feature data corresponds to a time step. This application generally predicts the spot day-ahead electricity price time series for the next day based on the electricity price forecast feature data within the effective time range before the day-ahead trading window closes (generally 7 days before the day-ahead trading window closes). Taking a collection frequency of 15 minutes as an example, 1 hour corresponds to 4 time steps (i.e., 4 collections per hour), so the number of time steps per day is 96, that is, 96 electricity price forecast feature data per day. In this case, 96 × 7 electricity price forecast feature data before the day-ahead trading window closes are used to predict 96 electricity price forecast feature data for the next day. Therefore, a target sliding window for constructing the input-output set corresponding to the LSTM Seq2Seq model architecture is first initialized. The length of this target sliding window is the total number of time steps L. total = 96×8 (7-day time steps before the forecast date + 7-day time steps before the forecast date) + 3rd time steps between the closing time of the trading window before the forecast date and 0:00 AM on the forecast date. Among them, the first 96×7 electricity price forecast feature data in the target sliding window are the input samples, and the clearing electricity prices of the last 96 spot days of the target sliding window are the output samples.
[0082] In one specific embodiment, in the training set, the target sliding window is set to start from L at the beginning of the training set. total The data for electricity price prediction features is slid to the last L of the training set. total The data for electricity price prediction features a sliding step of 1. Each sliding step forms a set of input samples and output samples corresponding to the training set through the target sliding window.
[0083] In the validation set, let the target sliding window start from the last L of the training set. total - 96 data points on electricity price forecasting and the validation set. The first 96 data points on electricity price forecasting are slid to the end of the validation set. total The electricity price prediction feature has a second sliding step size of 96. Each sliding step forms a set of input samples and output samples corresponding to the validation set through the target sliding window.
[0084] In the test set, let the target sliding window start from the last L in the validation set. total - 96 electricity price forecast feature data points and the first 96 electricity price forecast feature data points of the test set slide to the end of the test set L total The electricity price prediction feature has a second sliding step size of 96. Each sliding step forms a set of input samples and output samples corresponding to the test through the target sliding window.
[0085] Specifically, the first sliding step of the target sliding window in the training set is set to 1, which ensures that the training set can generate enough input and output samples. The second sliding step corresponding to the validation set and the test set is 96, which ensures that the validation and test objects are the clearing electricity prices corresponding to 96 time steps of a whole day, and there is no overlap between each validation day and each test day.
[0086] In a preferred embodiment, steps S400 to S500 include:
[0087] For each input data set, the multiple input samples and multiple output samples corresponding to the input data set are divided into multiple data batches. An input training set is formed by the input samples under each data batch. The input samples include multiple electricity price prediction feature data within the effective time range before the prediction date. An output training set is formed by the output samples under each data batch. The output samples include the spot day-clearing electricity price time series corresponding to the prediction date.
[0088] In each input dataset (including training set, validation set, and test set), to improve training efficiency, the multiple input samples and multiple output samples corresponding to the input dataset are divided into multiple data batches. The input samples in each data batch form an input training set M, and the output samples in each data batch form an output training set Q.
[0089] The shape corresponding to the input training set M is (batch size, number of electricity price prediction feature data corresponding to each input sample, number of features corresponding to each number of electricity price prediction feature data). For example, the shape corresponding to a certain input training set M is (100, 96×7, 36), which means that the input training set M includes 100 input samples, each input sample includes 96×7 electricity price prediction feature data, and each electricity price prediction feature data includes 36 features. The features correspond to the feature columns, which are divided into real number feature columns and category feature columns.
[0090] The shape of the output training set Q is (batch size, number of electricity price prediction feature data corresponding to the output sample, 1). In this application, 1 represents the prediction feature column in this application, that is, the spot day-clearing electricity price column corresponding to the prediction date. For example, the shape of the output training set Q is (100, 96, 1), which means that the output training set Q includes 100 output training samples. Each output sample includes 96 electricity price prediction feature data corresponding to the prediction date of the input sample. 1 represents the spot day-clearing electricity price column corresponding to the prediction date of the input sample.
[0091] The LSTM Seq2Seq model architecture includes an encoder and a decoder. After constructing the LSTM Seq2Seq model architecture, the hyperparameters used for training the LSTM Seq2Seq model architecture are determined. The hyperparameters include, but are not limited to, the batch size corresponding to the data batch, the number of training epochs, the learning rate, the loss function, and the optimizer.
[0092] In this application, the Adam optimizer is selected. Compared with the traditional gradient descent optimizer, Adam has the following advantages: 1. Adaptive learning rate; 2. Smoothness of the squared gradient; 3. Bias correction; 4. Fast convergence; 5. High stability.
[0093] In this application, weight decay is added to the optimizer Adam to prevent overfitting. In addition, this application does not impose specific restrictions on the choice of optimizer, which can be determined according to actual needs.
[0094] Once the hyperparameters and fitting mechanism for training the LSTM Seq2Seq model architecture are determined, the LSTM Seq2Seq model architecture can be trained.
[0095] In a preferred embodiment, step S600 includes:
[0096] Retrieve all corresponding data batches from the training set and perform one round of optimization training on the LSTM Seq2Seq model architecture: For each data batch, execute:
[0097] The input training set corresponding to the data batch is input into the encoder. The encoder performs feature mapping and time series calculation on the input training set to obtain the first input data, hidden state, and cell state. The first input data, hidden state, and cell state corresponding to the data batch are then input into the decoder for decoding loop to obtain multiple predicted output columns corresponding to each input sample in the data batch. From the multiple predicted output columns, a specified spot day-ahead electricity price prediction feature column is selected as the spot day-ahead electricity price prediction time series corresponding to the input sample. Based on the error between the spot day-ahead electricity price prediction time series corresponding to each input sample in the data batch and the output sample, the parameters of the LSTM Seq2Seq model for the data batch are optimized. After completing one round of optimization training, the optimized LSTM Seq2Seq model architecture is validated using the validation set. If the validation passes, the training of the LSTM Seq2Seq model architecture ends, and the electricity price prediction model is obtained. If the validation fails, all data batches are retrieved from the training set again, and a new round of training of the LSTM Seq2Seq model architecture is performed.
[0098] In a preferred embodiment, the network structure corresponding to the encoder includes an embedding layer, a recurrent neural network (RNN) layer, a residual layer, a first LSTM (Long Short-Term Memory) layer, and a first output layer, specifically, in the following manner:
[0099] The input training set M is input into the embedding layer. Through the embedding layer, the label encoding under the category feature column corresponding to each input sample in the input training set M is mapped to a continuous vector form space, and finally the processed first input data Embedding(M) is obtained. The shape of the first input data Embedding(M) is (batch size, number of electricity price prediction feature data corresponding to each input sample, number of consecutive features), for example, (batch size, 96×7, number of consecutive features).
[0100] The role of the embedding layer is to map high-dimensional sparse class features to a low-dimensional continuous space to overcome the limitations of label encoding and avoid the LSTM Seq2Seq model architecture from interpreting label encoding as a sequential relationship.
[0101] The first input data Embedding(M) is input into the RNN layer for RNN computation to capture the short-sequence information of historical spot day-clearing electricity prices, historical supply and demand relationships, and historical weather hidden in Embedding(M). The second input training data RNN(Embedding(M)) is output. The shape of the second input training data RNN(Embedding(M)) is (batch size, number of electricity price prediction feature data corresponding to each input sample, number of consecutive features), for example (batch size, 96×7, number of consecutive features).
[0102] The second input training data RNN(Embedding(M)) output from the RNN layer is concatenated with the first input data Embedding(M) into the residual layer to give Embedding(M) short sequence information, resulting in the third input training data Embedding(M)+RNN(Embedding(M)). The shape of the third input training data is (batch size, number of electricity price prediction feature data corresponding to each input sample, number of consecutive features), for example (batch size, 96×7, number of consecutive features).
[0103] The third input training data, Embedding(M) + RNN(Embedding(M)), is input into the first LSTM layer for LSTM computation to extract long sequence information. The number of consecutive features is mapped to the hidden layer size, and the long sequence memory information is output to obtain the hidden state LSTM(Embedding(M) + RNN(Embedding(M))) corresponding to the fourth input training data. h and cell state LSTM(Embedding(M)+RNN(Embedding(M))) c The shape corresponding to the hidden state is (1, batch size, hidden layer size), and the shape corresponding to the cell state is (1, batch size, hidden layer size).
[0104] Finally, the encoder output is output through the first output layer:
[0105] First input data: Embedding(M)
[0106] Hidden state LSTM9Embedding(M)+RNN9Embedding(M))) h
[0107] Cellular state LSTM9Embedding(M)+RNN(Embedding(M))) c .
[0108] In another preferred embodiment, the network structure corresponding to the decoder includes a second LSTM layer, an activation function layer, a random deactivation layer, a linear layer, and a second output layer, specifically:
[0109] Determine if the decoder is in its first loop. If it is, then retrieve the electricity price prediction feature data Embedding(M) corresponding to the last time step in the first input data Embedding(M). lasttimestep Hidden state LSTM(Embedding(M)+RNN(Embedding(M))) h and cell state LSTM(Embedding(M)+RNN(Embedding(M))) c Embedding(M) lasttimestep Hidden state LSTM(Embedding(M)+RNN(Embedding(M))) h and cell state LSTM(Embedding(M)+RNN(Embedding(M))) cThe input data for this loop is fed into the second LSTM layer as the decoder (based on the LSTM principle, the hidden state and cell state output by the encoder are the last step of the sequence of all hidden states and all cell states).
[0110] If the decoder is not in its first loop, then obtain the decoder's output data from the previous loop (including the decoder's output of the previous loop's decoded input training data). Decoding hidden state and decoding cell state The input data for this loop is fed into the second LSTM layer, where t represents the current loop and t-1 represents the previous loop.
[0111] The second LSTM layer performs LSTM computation on the input data of this loop, decodes the long sequence memory information inherited from the previous time step, and maps the number of consecutive features to the hidden layer size to obtain the first processed data. Decoding hidden state corresponding to this loop and decoding cell state The corresponding shape is (batch size, 1, hidden layer size), and the corresponding decoding hidden state in this loop. and decoding cell state The corresponding shape is (1, batch size, hidden layer size).
[0112] The first processed data The input to the activation function layer yields the second processed data, which is the corresponding activation function. For example, the activation function is obtained. The second processed data corresponds to the shape (1, batch size, hidden layer size).
[0113] The second-processed data is input into a randomly deactivated layer, and a portion of the hidden layer neurons are set to 0 according to probability to obtain the third-processed data. The shape corresponding to the third processed data is (1, batch size, hidden layer size).
[0114] The third processed data is input into the linear layer to map the hidden layer size to the number of consecutive features, thus obtaining the decoded input training data for the current loop output.
[0115] Its corresponding shape is (batch size, 1, number of consecutive features), which is the decoded input training data output in this loop. This is the electricity price prediction feature data corresponding to the third-processed data after linear processing.
[0116] Finally, the decoded input training data output by the second output layer decoder in this loop is used. Decoding hidden state and decoding cell state
[0117] In one specific embodiment, the decoding process is related to the number of time steps corresponding to the day-ahead clearing electricity price. Assuming the number of time steps corresponding to the day-ahead clearing electricity price is 96, the decoding process is a loop that iterates through 96 time steps. The output of the decoder in each loop becomes the input for the next loop. Therefore, the single-step input of the decoder is denoted as... and Single-step output is denoted as and
[0118] Taking a sampling frequency of 15 minutes as an example, the decoder performs 96 loops. In each loop of the decoder, the input training data is decoded. The values of fixed feature columns are selected as the predicted values for the current time step in the current loop. After completing 96 loops, the predicted time series of the spot day-clearing electricity price for each training sample in the data batch can be obtained.
[0119] In this application, during the training of the LSTM Seq2Seq model architecture, the training and validation processes are performed alternately. First, all data batches are extracted from the training set to perform a round of optimization training on the LSTM Seq2Seq model architecture:
[0120] For each data batch, the following steps are performed: input the data batch into the encoder, perform feature mapping and time series calculation on the data batch to obtain the first input data, hidden state, and cell state; input the first input data, hidden state, and cell state corresponding to the data batch into the decoder for decoding loop to obtain multiple predicted output columns corresponding to each input sample in the data batch; select a specified spot day-ahead electricity price prediction feature column from the multiple predicted output columns as the spot day-ahead electricity price observation time series corresponding to the input sample; and optimize the LSTM Seq2Seq model parameters based on the error between the spot day-ahead electricity price prediction time series corresponding to each input sample and the output sample in the data batch.
[0121] After completing one round of optimization training, the optimized LSTM Seq2Seq model architecture is validated using the validation set. If the validation passes, the training of the LSTM Seq2Seq model architecture ends, and the electricity price prediction model is obtained. If the validation fails, all data batches are retrieved from the training set again, and a new round of training is carried out on the LSTM Seq2Seq model architecture.
[0122] In a preferred embodiment, the process of validating the optimized LSTM Seq2Seq model architecture using a validation set includes:
[0123] For each input sample in the validation set, the input sample is fed into the optimized LSTM Seq2Seq model architecture to obtain the day-ahead electricity price forecast time series corresponding to the input sample. For each input sample, multiple error values between the day-ahead electricity price forecast time series corresponding to the input sample and the output sample are calculated. If the minimum error value is less than or equal to the preset error threshold, the training of the LSTM Seq2Seq model architecture ends, and the electricity price forecast model is obtained. The preset error threshold is generated by a custom error threshold generation mechanism. If the minimum error value is greater than the preset error threshold, all data batches are retrieved from the training set again to perform a new round of training on the LSTM Seq2Seq model architecture.
[0124] For example, a custom error threshold generation mechanism could be: take the minimum validation set error from the first 10 training rounds as the preset error threshold.
[0125] Specifically, this application calculates the loss between the predicted spot day-ahead electricity price at each time step in the spot day-ahead electricity price forecast time series and the observed spot day-ahead electricity price at the corresponding time step of the output sample using a preset loss function. The preset loss function is:
[0126]
[0127] In this formula, LOSS i This represents the loss value at the i-th time step in the day-ahead electricity price forecast time series. This represents the predicted spot-day electricity price at the i-th time step in the spot-day electricity price forecast time series. OP1 represents the observed spot day-ahead electricity price at the i-th time step in the spot day-ahead electricity price forecast time series, OP2 represents the first given error coefficient, and OP2 represents the second given error coefficient. In a specific embodiment, OP1 = 0.5 and OP2 = 0.15.
[0128] Because of the presence of the squared term, MSE (mean squared error) penalizes larger errors more severely, making it highly sensitive to outliers. Conversely, MAE (mean absolute error), which uses absolute values, penalizes larger errors less severely, making it less sensitive to outliers. To improve the robustness of the electricity price forecasting model to meteorological noise, the loss function is preset to apply to small errors... When using MSE, in large errors Use MAE to reduce the impact of meteorological noise.
[0129] In a preferred embodiment, the method provided in this application further includes:
[0130] Input samples from the test set are fed into the electricity price prediction model to obtain the day-ahead electricity price prediction time series corresponding to each input sample. For each input sample in the test set, the day-ahead electricity price prediction value at the time step corresponding to the day-ahead electricity price prediction time series of the input sample and the day-ahead electricity price observation value at the corresponding time step of the output sample are substituted into the preset evaluation function to generate the prediction accuracy evaluation result corresponding to the electricity price prediction model.
[0131] Specifically, the preset evaluation functions include:
[0132]
[0133] WAPE (weighted absolute percentage error) represents the weighted absolute percentage error corresponding to the input sample, and N represents the number of time steps corresponding to the day-ahead electricity price forecast time series of the input sample. This application uses weighted absolute percentage error, which can avoid the problem that the denominator of the average absolute percentage error is close to 0 when the electricity price is zero, thus resulting in infinite error.
[0134] In one specific embodiment, the trained electricity price prediction model is deployed in an engineered manner. Taking a data collection frequency of 15 minutes as an example, before the trading window closes, the model acquires the past 7 days' spot day-clearing electricity price time series, wind power total output time series, photovoltaic power total output time series, non-wind and solar power total output time series, and meteorological observation time series published by meteorological agencies. After processing, a feature data table is obtained. The feature data table is used to predict the spot day-clearing electricity price corresponding to 96 time steps of the next day. Based on the spot day-clearing electricity price of 96 time steps of the next day, market participants can reasonably declare the day-ahead market charging and discharging power curve or reasonably bid for volume to obtain maximum profit.
[0135] The advantages of this application are:
[0136] This application comprehensively considers the long-term time-series dependence of future day-clearing electricity prices on historical supply and demand relationships in the spot market and weather trends. It uses historical supply and demand relationships, historical electricity prices, and weather trends to predict future day-clearing electricity prices. The electricity price prediction model built on the LSTM Seq2Seq model architecture is robust and can reduce the impact of noise, especially weather noise.
[0137] The electricity price forecasting model can flexibly change the input and output lengths, and directly infer future electricity price changes through changes in historical weather and historical supply and demand relationships. In summary, the electricity price forecasting model provided in this application can flexibly make more accurate and robust predictions of the day-ahead clearing electricity price in different forecasting step scenarios.
[0138] Based on the same application concept, this application also provides an electricity price prediction device corresponding to the electricity price prediction method provided in the above embodiments. Since the principle of the device in this application is similar to the electricity price prediction method in the above embodiments of this application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0139] Please see Figure 2 , Figure 2 This diagram illustrates a functional block diagram of an electricity price forecasting device provided in an embodiment of this application. Figure 2 As shown, the device includes:
[0140] The sampling module 800 is used to sample observation data of different electricity price fluctuation influencing factors generated in a given historical period within a specified area, according to a given sampling frequency, to form the observation time series corresponding to the electricity price fluctuation influencing factors;
[0141] The feature construction module 810 is used to construct feature engineering based on the observation time series corresponding to the factors affecting electricity price fluctuations, so as to form a feature data table. The feature data table includes multiple feature columns, and each row in the feature data table forms the corresponding electricity price prediction feature data.
[0142] The first partitioning module 820 is used to partition the electricity price forecast feature data recorded in the feature data table into multiple input data sets based on the number of days corresponding to the electricity price forecast feature data and according to a preset ratio and date order.
[0143] The sample generation module 830 is used to construct input samples corresponding to each input data set and output samples corresponding to each input sample according to the data format required by the LSTMSeq2Seq model architecture, based on the electricity price prediction feature data corresponding to the input data set. The output sample is the clearing electricity price sequence corresponding to the prediction time period, and the input sample is the electricity price prediction feature data corresponding to each time step within the effective time range before the output sample.
[0144] The second partitioning module 840 is used to divide all input samples of the input data set and the output samples corresponding to each input sample into multiple data batches according to a preset batch size.
[0145] The model training module 850 is used to train and generate an electricity price prediction model based on multiple input samples corresponding to each data batch, output samples corresponding to each input sample, and the LSTM Seq2Seq model architecture.
[0146] The forecasting module 860 is used to forecast the spot market clearing price sequence corresponding to the target forecast date based on the electricity price forecasting model.
[0147] Based on the same application concept, please refer to Figure 3 , Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Figure 3 As shown, the electronic device 900 includes a processor 910, a memory 920, and a bus 930. The memory 920 stores machine-readable instructions that can be executed by the processor 910. When the electronic device 900 is running, the processor 910 and the memory 920 communicate through the bus 930. The machine-readable instructions are executed by the processor 910 to perform the steps of any of the electricity price prediction methods provided in the above embodiments.
[0148] Based on the same concept, this application also provides a computer-readable storage medium storing a computer program, which, when run by a processor, executes the steps of the electricity price prediction method provided in the above embodiments.
[0149] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
[0150] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0151] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0152] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0153] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for predicting electricity prices, characterized in that, The method includes: Within a designated area, observational data of different factors influencing electricity price fluctuations during a given historical period are sampled according to a given sampling frequency to form an observation time series corresponding to the factors influencing electricity price fluctuations. Based on the observation time series corresponding to the factors affecting electricity price fluctuations, feature engineering is constructed to form a feature data table. The feature data table includes multiple feature columns, and each row in the feature data table forms the corresponding electricity price prediction feature data. Based on the number of days corresponding to the electricity price forecast feature data, the electricity price forecast feature data recorded in the feature data table is divided into multiple input data sets according to a preset ratio and date order. Based on the electricity price prediction feature data corresponding to the input dataset, the input samples and output samples corresponding to each input dataset are constructed according to the data format required by the LSTMSeq2Seq model architecture. The output sample is the clearing electricity price sequence corresponding to the prediction time period, and the input sample is the electricity price prediction feature data corresponding to each time step within the effective time range before the output sample. The input dataset is divided into multiple data batches according to a preset batch size. Based on the multiple input samples corresponding to each data batch, the output samples corresponding to each input sample, and the LSTM Seq2Seq model architecture, an electricity price prediction model is trained and generated. Based on the electricity price prediction model, the spot market clearing price sequence corresponding to the target prediction date is predicted.
2. The method according to claim 1, characterized in that, The factors influencing electricity price fluctuations include the day-ahead clearing electricity price, and the observation time series includes the day-ahead clearing electricity price observation time series. Before constructing feature engineering based on the observation time series corresponding to the factors affecting electricity price fluctuations to form a feature data table, the method further includes: For each factor affecting electricity price fluctuations other than the day-ahead clearing price, the following procedures shall be followed: Determine whether the given sampling frequency corresponding to the electricity price fluctuation influencing factor is the same as the given sampling frequency corresponding to the spot day-ahead clearing electricity price; If the given sampling frequency corresponding to the electricity price fluctuation influencing factor is different from the given sampling frequency corresponding to the spot day-clearing electricity price, then the observation time series corresponding to the electricity price fluctuation influencing factor will be resampled to unify the observation time series corresponding to the electricity price fluctuation influencing factor to the same sampling frequency as the spot day-clearing electricity price.
3. The method according to claim 1, characterized in that, The observation time series includes the observed values of factors affecting electricity price fluctuations at different collection timestamps, and the multiple feature columns include multiple first feature columns. The first feature column is determined in the following way: The observation time series are sorted in ascending order according to the collection timestamp to obtain the first processed observation time series; The outliers in the first processing observation time series are set to null values to obtain the second processing observation time series; For the observations under the repeated acquisition timestamps in the second processing observation time series, the target observations are retained and the redundant observations under the repeated acquisition timestamps are deleted, forming the third processing observation time series; For the third processing observation time series, the cumulative missing value time corresponding to each target unit time is counted. For each target unit time, if the cumulative missing value time corresponding to that target unit time exceeds the preset time threshold, the observation value under that target unit time is deleted to form the fourth processing observation time series. The missing values in the fourth processing observation time series are filled by linear interpolation to form the first feature column corresponding to the factors affecting electricity price fluctuations.
4. The method according to claim 3, characterized in that, The plurality of feature columns also includes a second feature column. The second feature column is determined in the following manner: The different first feature columns are aligned according to the collection timestamp, and the aligned first feature columns form a data table to be processed. Delete the rows with empty values in the data table to be processed; For each row in the data table to be processed, convert the collection timestamp into a standard collection time. The second feature column is formed by the standard acquisition time corresponding to each row, and the standard acquisition time is a real number.
5. The method according to claim 3, characterized in that, Before forming the feature data table, the method further includes: Identify the observation type corresponding to each first feature column. The first feature column is divided into real number feature column and category feature column according to its corresponding observation type. The observation value under the category feature column is non-real number, and the observation value under the real number feature column is real number. Perform real-number mapping processing on each first feature column to obtain multiple first feature columns after real-number mapping processing. The real-number mapping processing includes: Determine whether the first feature column is a category feature column. If the first feature column is a category feature column, then according to the pre-given mapping relationship between the observations and label codes under that category feature column, map each observation under that category feature column to the corresponding label code, where the label code is a real number. If the first feature column is a real number feature column, then no processing is performed.
6. The method according to claim 4, characterized in that, Before forming the feature data table, the method further includes: For each first feature column and each second feature column after real number mapping, perform the following processing: Obtain the maximum and minimum observation values under this feature column; For each observation value under the feature column, the observation value is normalized according to the maximum observation value and the minimum observation value to obtain the normalized observation value. The normalization process includes: calculating the first difference between the maximum observation value and the observation value and the second difference between the maximum observation value and the minimum observation value respectively, and determining the ratio between the first difference and the second difference as the normalized observation value. For each observation after normalization, determine the corresponding feature column after normalization.
7. The method according to claim 3, characterized in that, The effective time range includes multiple effective data collection days, and the multiple feature columns also include multiple third feature columns. The method further includes: For each first feature column, execute: For each observation: determine the real-time acquisition day corresponding to the observation and its acquisition timestamp on the real-time acquisition day; The observation value corresponding to the collection timestamp of each valid collection day before the real-time collection day to which the observation value belongs is determined as the feature value of the observation value; Multiple third feature columns corresponding to the first feature column are formed by multiple feature values corresponding to each observation value; A temporary data table is formed by the plurality of first feature columns, the plurality of second feature columns, and the plurality of third feature columns corresponding to each first feature column; Delete the empty rows in the temporary data table to obtain the feature data table.
8. The method according to claim 4, characterized in that, The plurality of input data sets include at least a training set, and the first feature column includes a spot day-ahead clearing electricity price column. For the feature columns in the training set, the method further includes: For each real number feature column, perform the following processing: Calculate the Pearson correlation coefficient between the real feature column and the spot day-to-day clearing electricity price column. The closer the Pearson correlation coefficient is to 1, the more positively correlated the real feature column and the spot day-to-day clearing electricity price column are. The closer the Pearson correlation coefficient is to -1, the more negatively correlated the real feature column and the spot day-to-day clearing electricity price column are. The closer the Pearson correlation coefficient is to 0, the less correlated the real feature column and the spot day-to-day clearing electricity price column are. Determine whether the absolute value of the Pearson correlation coefficient is less than a preset correlation threshold; If the absolute value of the Pearson correlation coefficient is less than a preset correlation threshold, then the real-valued feature column is deleted from the training set.
9. The method according to claim 1, characterized in that, The multiple input data sets include a training set, a validation set, and a test set, wherein the data dates of the training set are earlier than those of the validation set, and the data dates of the validation set are earlier than those of the test set.
10. The method according to claim 9, characterized in that, The following methods are used to construct multiple input training samples and multiple output samples corresponding to each training set, validation set, and test set: Initialize a target sliding window. The length of the target sliding window is the total number of time steps between the first time step within the effective time range, the second time step corresponding to the prediction day, and the third time step. The third time step is the number of time steps between the closing time of the trading window before the prediction day and 0:00 AM on the prediction day. The width of the target sliding window is the number of feature columns in the input data set. In the training set, the target sliding window is made to slide from the first total time step of the training set to the last total time step of the training set according to a first sliding step size; In the validation set, the target sliding window is made to slide from the last fourth time step in the training set to the last total time step in the validation set according to the second sliding step, where the fourth time step is equal to the sum of the first time step and the third time step; In the test set, the target sliding window is made to slide from the last fourth time step of the validation set to the last total time step of the test set according to the second sliding step size; For each slide of the target sliding window, a corresponding input sample is formed by multiple electricity price prediction feature data corresponding to the first time step within the target sliding window, and a corresponding output sample is formed by multiple electricity price prediction feature data corresponding to the last second time step within the target sliding window.
11. The method according to claim 10, characterized in that, The method further includes: For each input dataset, the multiple input samples and multiple output samples corresponding to that input dataset are divided into multiple data batches; An input training set is formed by the input samples under each data batch. The input samples include multiple electricity price prediction feature data within the effective time range before the prediction date. An output training set is formed from the output samples of each data batch. The output samples include the time series of the spot clearing electricity price corresponding to the prediction date.
12. The method according to claim 11, characterized in that, The LSTM Seq2Seq model architecture includes an encoder and a decoder. The electricity price prediction model is trained and generated in the following way: Retrieve all corresponding data batches from the training set and perform one round of optimization training on the LSTM Seq2Seq model architecture: For each data batch, execute: The data batch is input into the encoder, and the encoder performs feature mapping and temporal calculations on the data batch to obtain the first input data, hidden state and cell state. The first input data, hidden state, and cell state corresponding to the data batch are input into the decoder for decoding loop to obtain multiple prediction output columns corresponding to each input sample in the data batch. From the multiple prediction output columns, a specified spot day-ahead electricity price prediction feature column is selected as the spot day-ahead electricity price prediction time series corresponding to the input sample. To address the error between the day-ahead electricity price forecast time series corresponding to each input sample and the output sample in this data batch, the parameters of the LSTM Seq2Seq model are optimized. After completing one round of optimization training, the optimized LSTM Seq2Seq model architecture is validated using the validation set. If the validation passes, the training of the LSTM Seq2Seq model architecture ends, and the electricity price prediction model is obtained. If the validation fails, all data batches are retrieved from the training set again, and a new round of training is carried out on the LSTM Seq2Seq model architecture.
13. The method according to claim 12, characterized in that, The process of validating the optimized LSTM Seq2Seq model architecture using a validation set includes: For each input sample in the validation set, the input sample is fed into the optimized LSTM Seq2Seq model architecture to obtain the day-ahead electricity price forecast time series corresponding to the input sample; For each input sample, calculate multiple error values between the day-ahead spot electricity price forecast time series corresponding to that input sample and the output sample; If the minimum error value is less than or equal to the preset error threshold, the training of the LSTM Seq2Seq model architecture ends, and the electricity price prediction model is obtained. The preset error threshold is generated by a custom error threshold generation mechanism. If the minimum error value is greater than the preset error threshold, then all data batches are retrieved from the training set again to perform a new round of training on the LSTM Seq2Seq model architecture.
14. The method according to claim 1, characterized in that, The method further includes: Input the input samples from the test set into the electricity price prediction model to obtain the day-ahead electricity price prediction time series corresponding to each input sample; For each input sample in the test set, the predicted day-ahead electricity price forecast time series and the output sample are used to input the predicted day-ahead electricity price at the time step of the predicted day-ahead electricity price forecast time series of the input sample and the observed day-ahead electricity price at the corresponding time step of the output sample. The result of the prediction accuracy evaluation of the electricity price prediction model is then generated.