Power sale quantity prediction method based on attention sequential network and readable storage medium

By constructing a power sales forecasting model based on attention timing network, the problem of low power sales forecasting accuracy in the prior art is solved, and high-precision prediction of power sales is achieved, and time series and spatial characteristics are captured.

CN119623701APending Publication Date: 2025-03-14ANHUI JIYUAN SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411665798.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-20
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

When processing massive, high-dimensional, dynamically changing power sales data, the existing power sales forecast model faces the problems of insufficient processing capacity and limited prediction accuracy, and is particularly difficult to effectively capture the long-term dependence and spatial characteristics in the power sales time series.

Method used

The power sales forecasting method based on attention timing network is adopted, and the power sales forecasting network model including the LSTM network model and the FCN network model are pre-processed, and the power sales forecasting network model is constructed for training, and finally the prediction is made based on the real-time power sales data.

Benefits of technology

It effectively improves the prediction accuracy of power sales, can capture the changing characteristics and spatial characteristics of the time series, and thus achieve reliable prediction of power sales.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119623701A_ABST
    Figure CN119623701A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a power sale quantity prediction method based on an attention sequential network and a readable storage medium, and belongs to the field of power sale quantity prediction. The electricity sale quantity prediction method comprises the following steps: acquiring historical electricity sale data in a database of a power grid system, and preprocessing the historical electricity sale data; constructing an electricity selling prediction network model; according to the method, the historical electricity selling data in the database of the power grid system is acquired and preprocessed, the preprocessed historical electricity selling data is adopted to train the electricity selling prediction model, and finally, the electricity selling quantity is predicted according to the real-time electricity selling data of the current power grid system. Specifically, the electricity sale prediction network model adopts a mode of matching an LSTM network model and an FCN network model, and can effectively capture change features and spatial features of an electricity sale quantity time sequence, so that reliable prediction of the electricity sale quantity is realized, namely, the prediction precision of the electricity sale quantity is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electricity sales forecasting, and in particular to an attention time series network-based electricity sales forecasting method and a readable storage medium. Background Art

[0002] At present, the power sales forecasting technology of the power grid system is facing unprecedented development opportunities in the power industry. With the popularization of smart grids and the rapid development of big data technology, the scale of power sales data has increased dramatically. The normalized weekly and monthly forecasting tasks of power sales have brought huge challenges to traditional manual analysis and forecasting of power sales, especially the instability of new energy power has put forward higher requirements for data processing and forecasting accuracy. However, the existing power sales forecasting models face challenges such as insufficient processing capacity and limited forecasting accuracy when processing massive, high-dimensional, and dynamically changing power sales data.

[0003] Traditional forecasting models, such as ARIMA models or simple linear regression, are difficult to effectively capture the long-term dependencies in the time series of electricity sales, that is, the impact of long-distance information in historical data on the current forecast value. At the same time, electricity sales are affected by multiple spatial factors such as time, geographical location, weather conditions, and socioeconomic conditions, and are less effective in dealing with such spatial features.

[0004] The inventors of the present application discovered during the process of implementing the present invention that the above-mentioned solution in the prior art has the defect of low accuracy in predicting the amount of electricity sold. Summary of the invention

[0005] The purpose of the embodiments of the present invention is to provide a method for predicting electricity sales volume based on an attention time series network and a readable storage medium, which have the function of high accuracy in predicting electricity sales volume.

[0006] In order to achieve the above object, an embodiment of the present invention provides a method for predicting power sales based on an attention time series network, comprising:

[0007] Acquire historical electricity sales data from a database of the power grid system, and preprocess the historical electricity sales data;

[0008] Constructing a power sales forecasting network model, wherein the power sales forecasting network model includes an LSTM network model and an FCN network model;

[0009] Training the electricity sales prediction network model according to the preprocessed historical electricity sales data;

[0010] Obtaining real-time electricity sales data of the current power grid system;

[0011] The real-time electricity sales data of the current power grid system is input into the power sales forecasting network model to obtain the power sales forecast value of the power grid system.

[0012] Optionally, the historical electricity sales data includes electricity sales time, electricity sales amount, meteorological data, and macroeconomic data. The corresponding electricity sales amount, meteorological data, and macroeconomic data are aligned according to the electricity sales time, and a corresponding data set is constructed.

[0013] Optionally, preprocessing the historical electricity sales data includes:

[0014] Processing the data set using an interpolation method;

[0015] Using box plots to identify and handle outliers in the data set;

[0016] The data set was standardized using z-score standardization;

[0017] The data set is normalized.

[0018] Optionally, training the electricity sales prediction network model according to the preprocessed historical electricity sales data includes:

[0019] Perform preliminary feature screening on the preprocessed data set to obtain the data set to be input;

[0020] Inputting the data set to be input into the input layer of the LSTM network model, wherein the LSTM network model includes a Dropout layer;

[0021] Applying an attention mechanism to the output layer of the LSTM network model;

[0022] Reprocessing the output data processed by the attention mechanism;

[0023] Input the reprocessed data into the FCN network model;

[0024] Output the predicted value;

[0025] The model parameters of the LSTM network model and the FCN network model are modified according to the predicted value.

[0026] Optionally, preliminary feature screening is performed on the preprocessed data set to obtain the data set to be input including:

[0027] The Pearson correlation coefficient is used to obtain the correlation coefficient between each individual in the data set and the power sales amount;

[0028] Determine whether the correlation coefficient between the individual in the data set and the power sales amount is greater than or equal to a correlation threshold;

[0029] In the case where it is determined that the correlation coefficient between the individual in the data set and the power sales volume is greater than or equal to the correlation threshold, retaining the individual;

[0030] When it is determined that the correlation coefficient between the individual in the data set and the power sales volume is less than a correlation threshold, deleting the individual;

[0031] Get the input data set.

[0032] Optionally, reprocessing the output data processed by the attention mechanism includes:

[0033] Perform fast Fourier transform on the output data processed by the attention mechanism, and select a preset number of frequency signals with the largest amplitude;

[0034] Folding the frequency signal into a two-dimensional data structure according to the corresponding period;

[0035] A convolution process is performed on the two-dimensional data structure to obtain a one-dimensional data structure.

[0036] Optionally, correcting model parameters of the LSTM network model and the FCN network model according to the predicted value includes:

[0037] Get the predicted value sequence and target value sequence;

[0038] Obtain a multi-step sequence gradient loss function according to the predicted value sequence and the target value sequence;

[0039] A sequence trend loss function is obtained according to the predicted value sequence and the target value sequence.

[0040] Optionally, obtaining a multi-step sequence gradient loss function according to the predicted value sequence and the target value sequence includes:

[0041] According to formula (1), the multi-step gradient values ​​of the predicted value sequence are obtained.

[0042]

[0043] in, is the gradient value of the t-th prediction value with a step length of k in the prediction value sequence, is the tth predicted value in the predicted value sequence, is the tkth prediction value in the prediction value sequence, t is the sequence number, and t=k+1, k+2, …, T, T is the maximum sequence, k is the step length, k∈{1,2, …, K}, K is the maximum step length;

[0044] According to formula (2), the multi-step gradient values ​​of the target value sequence are obtained.

[0045] Δ k S t =S t -S t-k , (2)

[0046] Among them, Δ k S t is the gradient value of the t-th predicted value with a step length of k in the target value sequence, S t is the tth target value in the target value sequence, S t-k is the tkth target value in the target value sequence;

[0047] According to formula (3), the attenuation weight of the step length is obtained:

[0048] w k =exp(-λk), (3)

[0049] Among them, w k is the decay weight of step size k, λ is the decay rate, and λ>0;

[0050] According to formula (4), we can obtain the multi-step sequence gradient loss function:

[0051]

[0052] Among them, L1 is the multi-step sequence gradient loss function, B is the maximum batch value, D is the maximum feature dimension value, b is the batch number, and d is the dimension number.

[0053] Optionally, obtaining a sequence trend loss function according to the predicted value sequence and the target value sequence includes:

[0054] According to formula (5), the first-order difference values ​​of adjacent time steps of the predicted value sequence are obtained.

[0055]

[0056] in, is the first-order difference value of the adjacent time steps of the predicted value sequence, is the t-1th predicted value in the predicted value sequence, and t=2, 3, …, T;

[0057] According to formula (6), the first-order difference values ​​of adjacent time steps of the target value sequence are obtained.

[0058] ΔS t =S t -S t-1 , (6)

[0059] Among them, ΔS t is the first-order difference value of the target value sequence in adjacent time steps, St-1 is the t-1th target value in the target value sequence;

[0060] According to formula (7), we can obtain the sequence trend loss function:

[0061]

[0062] Wherein, L2 is the sequence trend loss function, and sign(·) is the sign function.

[0063] On the other hand, the present invention provides a machine-readable storage medium having instructions stored thereon, the instructions being used to enable a machine to execute any of the above-mentioned power sales amount prediction methods of the present application.

[0064] Through the above technical scheme, the power sales prediction method based on the attention time series network and the readable storage medium provided by the present invention obtain the historical power sales data in the database of the power grid system, pre-process the historical power sales data, use the pre-processed historical power sales data to train the power sales prediction model, and finally predict the power sales according to the real-time power sales data of the current power grid system; specifically, the power sales prediction network model adopts the LSTM network model and the FCN network model in a coordinated manner, which can effectively capture the changing characteristics and spatial characteristics of the power sales time series, thereby realizing reliable prediction of the power sales, that is, effectively improving the prediction accuracy of the power sales.

[0065] Other features and advantages of the embodiments of the present invention will be described in detail in the subsequent detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] The accompanying drawings are used to provide a further understanding of the embodiments of the present invention and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present invention, but do not constitute a limitation on the embodiments of the present invention. In the accompanying drawings:

[0067] Figure 1 is a flowchart of a method for predicting electricity sales based on an attention time series network according to an embodiment of the present invention;

[0068] Figure 2 is a flowchart of preprocessing historical electricity sales data in a method for predicting electricity sales based on an attention time series network according to an embodiment of the present invention;

[0069] Figure 3 is a flowchart of training a power sales prediction network model in a power sales prediction method based on an attention time series network according to an embodiment of the present invention;

[0070] Figure 4is a flowchart of preliminary feature screening of a data set in a method for predicting electricity sales volume based on an attention time series network according to an embodiment of the present invention;

[0071] Figure 5 is a flowchart of data reprocessing in a method for predicting electricity sales volume based on an attention time series network according to an embodiment of the present invention;

[0072] Figure 6 is a flowchart of obtaining a loss function of a network model in a method for predicting electricity sales based on an attention time series network according to an embodiment of the present invention;

[0073] Figure 7 is a flowchart of obtaining a multi-step sequence gradient loss function in a method for predicting power sales based on an attention time series network according to an embodiment of the present invention;

[0074] Figure 8 It is a flowchart of obtaining a sequence trend loss function in a method for predicting electricity sales based on an attention time series network according to an embodiment of the present invention. DETAILED DESCRIPTION

[0075] The specific implementation of the embodiment of the present invention is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described here is only used to illustrate and explain the embodiment of the present invention, and is not used to limit the embodiment of the present invention.

[0076] Figure 1 is a flow chart of a method for predicting electricity sales based on an attention time series network according to an embodiment of the present invention. Figure 1 In the method for predicting power sales volume, the method may include:

[0077] In step S10, the historical electricity sales data in the database of the power grid system is obtained, and the historical electricity sales data is preprocessed. Among them, the historical electricity sales records can be obtained from the power company database, and the time span should be long enough so that the subsequent model can capture seasonal and cyclical characteristics. At the same time, meteorological data is obtained from the meteorological department or a third-party meteorological service provider. Specifically, the meteorological data may include temperature, humidity, rainfall, wind speed, etc. And macroeconomic data is obtained. Specifically, the macroeconomic data may include GDP, consumption index, industrial production index, etc. Therefore, the historical electricity sales data may include electricity sales time / date, electricity sales, meteorological data and macroeconomic data. The corresponding electricity sales, meteorological data and macroeconomic data are aligned according to the electricity sales time / date, and the corresponding data set is constructed to ensure time consistency. In addition, after obtaining the historical electricity sales data / data set, the data set needs to be preprocessed to obtain a clean and standardized data set.

[0078] In step S11, a power sales forecasting network model is constructed, wherein the power sales forecasting network model may include an LSTM network model and an FCN network model. Specifically, the LSTM network model can capture the long-term dependency of the time series, and the FCN network model can extract high-dimensional features / spatial features, thereby achieving high-precision forecasting of power sales.

[0079] In step S12, the electricity sales prediction network model is trained according to the preprocessed historical electricity sales data. For the training of the electricity sales prediction network model, the preprocessed data set can be divided into a training set, a validation set and a test set to ensure data independence and fairness of the evaluation during the training process. Specifically, the training set is used for the training process of the model, the validation set is used for hyperparameter adjustment and early stopping strategy during the training process, that is, to prevent overfitting, and the test set is used to evaluate the final performance of the model to ensure the generalization ability of the model. Training algorithms and hyperparameter adjustment are key steps in model development. The training algorithm adjusts the model parameters by optimizing the objective function so that the model performs best on the training data. Common algorithms include gradient descent and its variants, such as stochastic gradient descent (SGD), Adam, RMSprop, etc. The above algorithms reduce the value of the loss function by calculating the gradient and updating the weights. During the training process, hyperparameter adjustment involves selecting and optimizing the hyperparameters of the model, such as learning rate, batch size, training argument, regularization parameter, etc. These hyperparameters have an important impact on the performance of the model. Hyperparameters are usually adjusted using methods such as grid search, random search, or Bayesian optimization. The performance of the model under different hyperparameter settings can be evaluated through cross-validation to find the best configuration and ensure the generalization ability and prediction accuracy of the model on new data. In addition, after the electricity sales forecast network model is trained, the performance of the model needs to be evaluated. The performance evaluation of the model usually includes multiple aspects. First, the performance of the classification or regression task is evaluated by calculating indicators such as the prediction accuracy, precision, recall rate, and F1 score of the model on the test set. Secondly, the prediction error of the model can be measured using loss functions such as mean square error or cross entropy. In addition, the generalization ability of the model on different data sets and the processing effect on different categories or time series segments can be evaluated by drawing learning curves, validation curves, and using tools such as confusion matrices. After obtaining the evaluation results, the model structure can be adjusted, such as increasing or decreasing the number of LSTM layers, adjusting the size of the convolution kernel, etc., to improve the prediction accuracy and stability of the model.

[0080] In step S13, the real-time electricity sales data of the current power grid system is obtained, wherein the real-time electricity sales data of the current power grid system may include the current time, electricity sales amount, meteorological data and macroeconomic data of the power grid system.

[0081] In step S14, the real-time electricity sales data of the current power grid system is input into the electricity sales prediction network model to obtain the electricity sales forecast value of the power grid system. After obtaining the current real-time electricity sales data of the power grid system, it can be input into the trained electricity sales prediction network model for prediction to obtain the electricity sales forecast value of the power grid system. Specifically, after the electricity sales prediction network model is trained, a server or cloud platform can be selected to deploy the trained LSTM-FCN network model. Online prediction is performed in combination with real-time electricity sales data, and the electricity sales forecast results are updated in time to provide decision support for power companies. The prediction results are integrated with the power sales system of the power company through the API interface to facilitate data acquisition and display. According to the latest electricity sales data and changes in the external environment, the model is retrained and updated regularly to ensure the timeliness of the model. In addition, when the new data accumulates to a certain amount, the model is retrained to improve the prediction accuracy of the model. The prediction quality of the model is monitored by calculating the key indicators of the model in real time or periodically, such as accuracy, recall, precision and F1 score. Establish an early warning system to promptly detect performance degradation or abnormalities by monitoring the fluctuations of the model prediction error or loss function. When an anomaly is detected, it is necessary to deeply analyze the cause, such as changes in data distribution, model overfitting, or feature drift, and take corresponding measures, such as retraining the model, updating the data set, or adjusting model parameters. At the same time, establish a feedback mechanism to adjust the model based on user feedback to improve the actual application effect of the model.

[0082] In step S10 to step S14, the historical electricity sales data in the database of the power grid system is first obtained, and the historical electricity sales data is preprocessed to obtain a clean and standardized data set. Then, a power sales prediction network model composed of an LSTM network model and an FCN network model is constructed, and the power sales prediction network model is trained using the preprocessed data set to correct the model parameters of the power sales prediction network model. After the training is completed, the real-time power sales data of the current power grid system is obtained, and the real-time power sales data is input into the trained power sales prediction network model, so that the power sales forecast value of the current power grid system can be obtained, that is, the power sales forecast of the power grid system can be effectively realized.

[0083] Traditional prediction models may include ARIMA models or simple linear regression models. It is difficult for the above models to effectively capture the long-term dependencies in the electricity sales time series, that is, the impact of long-distance information in historical data on the current forecast value cannot be captured. At the same time, electricity sales are affected by multiple spatial factors such as time, geographical location, weather conditions, and socioeconomic conditions. The above models are less effective in processing such spatial features, resulting in low accuracy in existing electricity sales forecasts. In this embodiment of the present invention, the electricity sales forecasting network model uses a combination of LSTM network model and FCN network model to effectively capture the changing characteristics and spatial characteristics of the electricity sales time series, thereby achieving reliable prediction of electricity sales, that is, effectively improving the prediction accuracy of electricity sales.

[0084] In this embodiment of the present invention, after obtaining the historical electricity sales data of the power grid system, it is necessary to preprocess the historical electricity sales data to improve the reliability of subsequent model training. The specific preprocessing steps can be as follows: Figure 2 Specifically, Figure 2 In the method for predicting power sales volume, the method may further include:

[0085] In step S100, the data set is processed by interpolation. Among them, interpolation, mean filling or deletion of samples with more missing values ​​can be used to ensure the integrity of the data. Specifically, expanding and transforming data samples by different methods helps to improve the generalization ability and robustness of the model. Selecting a suitable data enhancement method can effectively deal with problems such as data scarcity, thereby improving the performance of the time series model.

[0086] In step S101, a box plot is used to identify and process outliers in a data set, wherein outliers may be identified and processed by methods such as a box plot and the 3σ principle to avoid negative impacts on model training.

[0087] In step S102, the data set is standardized by using z-score standardization, wherein data of different dimensions are standardized to eliminate dimension differences, and commonly used methods may include z-score standardization and Min-Max standardization.

[0088] In step S103, the data set is normalized, wherein normalizing the data set, that is, scaling the data to the range of [0, 1], helps to accelerate the model convergence speed and improve the model prediction performance.

[0089] In step S100 to step S103, the preprocessing of the data set may include interpolation processing using an interpolation method to improve the robustness of the data set. A box plot is used to identify and process outliers to determine the impact of outliers in the data set on model training. In addition, the data set is standardized and normalized to eliminate dimensions and speed up model convergence.

[0090] In this embodiment of the present invention, after preprocessing the data set consisting of historical electricity sales data, the preprocessed data set can be used to train the electricity sales prediction network model. The specific training steps can be as follows: Figure 3 Specifically, Figure 3 In the method for predicting power sales volume, the method may further include:

[0091] In step S120, the preprocessed data set is subjected to preliminary feature screening to obtain a data set to be input. In order to improve the accuracy and efficiency of model training, the data set can be subjected to preliminary feature screening. Specifically, the screening step can be as follows: Figure 4 Specifically, Figure 4 In the method for predicting power sales volume, the method may further include:

[0092] In step S1200, the Pearson correlation coefficient is used to obtain the correlation coefficient between each individual in the data set and the electricity sales. The individual in the data set is also a feature / data type. In order to improve the accuracy and efficiency of the model, taking the date and time feature as an example, the month information in the data is extracted to capture seasonal characteristics. The day of the week information in the data is extracted to distinguish between weekdays and weekends.

[0093] In order to facilitate the model to capture the impact of holidays and special events on electricity sales, it is necessary to add holiday data and add holiday marking features to the holiday data to distinguish between weekdays and holidays. Special event markers can also be added, such as large-scale events, emergencies, etc., to capture the impact of these events on electricity sales.

[0094] After feature extraction, the original data contains a large number of features, and only some of these features are helpful for electricity sales forecasting. Therefore, the Pearson correlation coefficient, partial correlation analysis and other methods can be used to calculate the correlation between each feature and electricity sales, and retain features with higher correlation. Principal component analysis (PCA) can also be used to reduce the dimensionality of high-dimensional data, retain the main components, and reduce redundant information.

[0095] In step S1201, it is determined whether the correlation coefficient between the individual in the data set and the power sales amount is greater than or equal to the correlation threshold.

[0096] In step S1202, when it is determined that the correlation coefficient between the individual in the data set and the power sales amount is greater than or equal to the correlation threshold, the individual is retained.

[0097] In step S1203, when it is determined that the correlation coefficient between the individual in the data set and the power sales amount is less than the correlation threshold, the individual is deleted.

[0098] In step S1204, a data set to be input is obtained, wherein the data set to be input is a data set that has been preliminarily screened for features.

[0099] In step S1200 to step S1204, the Pearson correlation coefficient is first used to calculate the correlation coefficient between each individual in the data set and the power sales, that is, to obtain the correlation between each data type and the power sales. Specifically, the data type is also the time series data of meteorological data or macroeconomic data such as temperature, humidity, and consumption index, that is, the value that changes over time. After obtaining the correlation coefficient between each data type and the power sales, it can be compared with the correlation threshold. If the correlation coefficient between the data type and the power sales is greater than the correlation threshold, the data type, that is, the individual in the corresponding data set, can be retained, otherwise the individual is deleted. Finally, after calculating and judging all the individuals / data types in the data set, the final data set to be input can be obtained, and the data set to be input can be used to input into the power sales forecast network model for training. Specifically, before model training, pre-screening data types with high correlation with power sales can effectively reduce the interference of data types with low correlation on model training, thereby ensuring the accuracy and efficiency of subsequent model training.

[0100] In step S121, the data set to be input is input into the input layer of the LSTM network model, wherein the LSTM network model includes a Dropout layer. Specifically, the LSTM network model can capture long-term dependencies in the time series, and the gating mechanism of the LSTM network model can remember and forget information, which helps to deal with long-term time dependencies. In the LSTM network model, a Dropout layer can be added to reduce the risk of overfitting, and L2 regularization can also be used to prevent the model from overfitting and improve the generalization ability of the model.

[0101] In step S122, an attention mechanism is applied to the output layer of the LSTM network model. The attention mechanism can help the model focus more on important information when processing time series data. The attention mechanism is applied to the output of the LSTM layer to calculate the attention weights of each time step, and an attention network can be used to generate these weights. The attention mechanism is used to weight the hidden state output by the LSTM layer, highlighting the time steps that have a greater impact on the prediction results, thereby improving the attention and interpretability of the model.

[0102] In step S123, the output data processed by the attention mechanism is reprocessed. Considering the limitations of the subsequent FCN network model, the LSTM output data processed by the attention mechanism is further processed. Specifically, the reprocessing of the output data processed by the attention mechanism includes the following steps: Figure 5 Specifically, Figure 5 In the data reprocessing step, the data reprocessing step may include:

[0103] In step S1230, the output data processed by the attention mechanism is subjected to a fast Fourier transform, and a preset number of frequency signals with the largest amplitude are selected. In order to more accurately capture the periodic characteristics in the time series data, the fast Fourier transform (FFT) is used to perform frequency domain analysis on the preprocessed data, convert the time series from the time domain to the frequency domain, and calculate the amplitude of the spectrum to identify the main frequency components in the data. Secondly, the first preset number of frequency signals with the largest amplitude / amplitude, that is, the first K frequency signals, are selected to extract the corresponding periodic information. The above main frequency signals represent the most significant periodic changes in the data, and provide an important basis for subsequent feature extraction and model construction.

[0104] In step S1231, the frequency signal is folded into a two-dimensional data structure according to the corresponding period. According to the main period information, the one-dimensional time series data is folded according to the corresponding period length and reorganized into a two-dimensional data structure. The specific operation is to divide the time series into several fragments according to the period length, and then arrange these fragments in sequence to form a two-dimensional matrix. The two-dimensional data processed in this way makes the periodic pattern originally hidden in the one-dimensional sequence more obvious and intuitive in the two-dimensional space, which is conducive to the subsequent use of convolutional neural networks for feature extraction, and can more effectively capture periodic features and local patterns.

[0105] In step S1232, the two-dimensional data structure is convolved to obtain a one-dimensional data structure. The one-dimensional data structure can be obtained after the two-dimensional data structure is convolved, and the one-dimensional data structure is input into the FCN network model for full convolution operation.

[0106] In step S1230 to step S1232, the output data of the attention mechanism is first subjected to a fast Fourier transform to obtain multiple frequency signals with the largest amplitude. The multiple frequency signals are folded into a two-dimensional data structure according to the corresponding period, and the two-dimensional data structure is convolved to obtain a one-dimensional data structure. Finally, the one-dimensional data structure is input into the FCN network model for full convolution operation. This method can capture significant periodic features in time series and effectively improve the accuracy and efficiency of model training.

[0107] In step S124, the reprocessed data is input into the FCN network model. The FCN network model extracts multi-scale features through multi-layer convolution and pooling operations. In order to make full use of these features, the features at different levels are fused by using feature pyramids or skip connections to retain rich spatial information and details. In the feature extraction process of the FCN network model, additional feature enhancement modules (such as residual connections, dilated convolutions, etc.) can be introduced to enhance the representation ability and robustness of the features.

[0108] In step S125, the predicted value is output, where the predicted value is also the predicted value of the electricity sales amount.

[0109] In step S126, the model parameters of the LSTM network model and the FCN network model are corrected according to the predicted value. According to the predicted value and target value of the electricity sales, the loss function of the current network model can be determined, that is, the effect of the network model training can be understood, and then the model parameters of the network model can be continuously iterated to make the predictions of the LSTM network model and the FCN network model more accurate.

[0110] In step S120 to step S126, the preprocessed data set is first subjected to preliminary feature screening, that is, the data type with greater correlation with the time series change of the power sales. After the preliminary feature screening of the data set, the data set to be input can be obtained. The data set to be input is input into the LSTM network model, and the LSTM network model can be trained. Specifically, the LSTM network model includes a Dropout layer and an attention mechanism layer, which can effectively avoid overfitting and improve the focus of feature extraction. The output data of the attention mechanism is reprocessed, that is, further feature extraction. Finally, it is input into the FCN network model for full convolution operation, and the predicted value is output. The model parameters are corrected according to the predicted value and the true value in the data set to be input, so that reliable and accurate training of the power sales prediction network model can be achieved.

[0111] In this embodiment of the present invention, in order to reduce the size of the above network model and improve the reasoning speed, the LSTM-FCN model based on the attention mechanism can be pruned and quantized. Pruning can remove unimportant connections or neurons, and quantization can map model weights and activation values ​​to a limited set of values. Using GPUs or dedicated AI accelerators for parallel computing can significantly accelerate the training and reasoning process of the model. Computational efficiency can be further improved by optimizing data loading, batch size, and computational graph layout.

[0112] In this embodiment of the present invention, after obtaining the predicted value of the power sales, it is compared with the target value to obtain the loss function of the current network model, and the model parameters of the network model are continuously adjusted according to the loss function to obtain the optimal network model. Specifically, the calculation of the loss function of the network model can be as follows: Figure 6 Specifically, Figure 6 In the method for predicting power sales volume, the method may further include:

[0113] In step S1260, the predicted value sequence and the target value sequence are obtained. The predicted value sequence is the predicted value sequence output by the network model, and the target value sequence is the corresponding true value sequence in the training data. Specifically, the predicted value sequence is expressed as The target value sequence is represented as S = {S1, S2, ..., S T}, is the predicted value series The Tth predicted value in S T is the Tth target value in the target value sequence S, T is the sequence length, and T is an integer number, B is the batch size and D is the feature dimension.

[0114] In step S1261, a multi-step sequence gradient loss function is obtained according to the predicted value sequence and the target value sequence. Among them, power consumption data often involves fluctuations and patterns across multiple time steps. These fluctuations may reflect the influence of factors such as daily power consumption peaks and troughs, seasonal changes, and emergencies. Capturing these multi-step time dynamics is crucial for the model to make accurate predictions. However, traditional loss functions such as MSE and mean absolute error (MAE) mainly focus on the numerical difference between the predicted value and the true value of each time step, ignoring the continuity and correlation of sequence data in the time dimension. Specifically, the traditional loss function lacks time-dependent considerations and cannot capture the dynamic relationship between data points, resulting in a limited understanding of the model for time series. At the same time, it is insensitive to multi-step dynamics, and cannot effectively learn and predict short-term fluctuations and long-term trend combinations, and may miss important pattern changes. It may also produce unstable predictions. Since the time dynamics are not considered, the model may be sensitive to noise, resulting in unstable prediction results. Therefore, the multi-step sequence gradient loss function used in this application can improve the sensitivity of the model to time dynamics by comparing the gradients (differentials) of the predicted value sequence and the target value sequence at multiple time steps. Specifically, the multi-step sequence gradient loss function not only considers the difference between the predicted value and the true value, but also focuses on the changing trends of the two on different time scales.

[0115] For the calculation of multi-step sequence gradient loss function, we can use Figure 7 Specifically, Figure 7 In the method for predicting power sales volume, the method may further include:

[0116] In step S12610, the multi-step gradient of the prediction value sequence is obtained according to formula (1):

[0117]

[0118] in, is the gradient value of the t-th prediction value in the prediction value sequence with a step length of k, is the tth predicted value in the predicted value sequence, is the tkth prediction value in the prediction value sequence, t is the sequence number, and t = k+1, k+2,…, T, T is the maximum sequence, k is the step size, k∈{1,2,…,K}, K is the maximum step size.

[0119] In step S12611, the multi-step gradient values ​​of the target value sequence are obtained according to formula (2):

[0120] Δ k S t =S t -S t-k , (2)

[0121] Among them, Δ k S t is the gradient value of the t-th predicted value in the target value sequence with a step length of k, S t is the tth target value in the target value sequence, S t-k is the tkth target value in the target value sequence.

[0122] In step S12612, the step length attenuation weight is obtained according to formula (3):

[0123] w k =exp(-λk), (3)

[0124] Among them, w k is the decay weight of step size k, λ is the decay rate, and λ>0.

[0125] In step S12613, the multi-step sequence gradient loss function is obtained according to formula (4):

[0126]

[0127] Among them, L1 is the multi-step sequence gradient loss function, B is the maximum batch value, D is the maximum feature dimension value, b is the batch number, and d is the dimension number.

[0128] In steps S12610 to S12612, by calculating the multi-step sequence gradient loss function, that is, calculating the gradient difference between the predicted value sequence and the target value sequence at multiple steps, the model can more accurately learn the changing trend and dynamic characteristics of the sequence. The multi-step sequence gradient loss function encourages the model to more accurately simulate the changing speed and direction of the sequence, improve the ability to capture dynamic characteristics, and thus improve the prediction accuracy.

[0129] In step S1262, a sequence trend loss function is obtained according to the predicted value sequence and the target value sequence. Among them, in the prediction of power consumption, understanding the trend direction of consumption, that is, whether the consumption rate increases, decreases or remains stable, is often as important as the numerical value of the prediction accuracy. For example, power companies need to estimate the peak power consumption period in advance to effectively manage the supply and demand balance and power grid scheduling. However, the traditional loss function has limitations in capturing the trend direction. The traditional loss function only focuses on the numerical error without considering the consistency of the predicted value with the true value in the trend. Specifically, the traditional loss function ignores the trend direction error. The model may be close to the true value in numerical value, but opposite in the trend direction, resulting in wrong decision support. At the same time, it will not be able to detect key regional changes, be insensitive to important trend turning points, and may miss the sudden rise or fall of power consumption. It will also affect the efficiency of energy management. Wrong trend prediction may lead to waste of resources or insufficient power supply, increasing operational risks. Therefore, the sequence trend loss function adopted in this application can increase the ability of the model to correctly predict the trend direction by penalizing the difference between the predicted trend and the actual trend. Specifically, the sequence trend loss function compares the trend directions of the predicted value sequence and the target value sequence between adjacent time steps, and imposes a penalty when the predicted trend is inconsistent with the true trend.

[0130] For the calculation of the sequence trend loss function, it can be based on Figure 8 Specifically, Figure 8 In the method for predicting power sales volume, the method may further include:

[0131] In step S12620, the first-order difference values ​​of adjacent time steps of the prediction value sequence are obtained according to formula (5):

[0132]

[0133] in, is the first-order difference value of the adjacent time steps of the predicted value sequence, is the t-1th predicted value in the predicted value sequence, and t=2,3,…,T.

[0134] In step S12621, the first-order difference values ​​of adjacent time steps of the target value sequence are obtained according to formula (6):

[0135] ΔSt =S t -S t-1 , (6)

[0136] Among them, ΔS t is the first-order difference value of the target value sequence in adjacent time steps, S t-1 is the t-1th target value in the target value sequence.

[0137] In step S12622, the sequence trend loss function is obtained according to formula (7):

[0138]

[0139] Among them, L2 is the sequence trend loss function, and sign(·) is the sign function.

[0140] In step S12620 to step S12622, the trend consistency of the predicted value sequence and the target value sequence is paid attention to through the sequence trend loss function, and the difference signs of adjacent time steps are compared to calculate whether the trends of the predicted value sequence and the target value sequence are consistent. If the trend direction is inconsistent, a penalty is imposed on the model. The sequence trend loss function ensures that the model is not only close to the true value in terms of value, but also correctly reflects the growth or decline trend of the data, thereby improving the credibility and practical application value of the prediction results.

[0141] In step S1260 to step S1262, the predicted value sequence output by the model is obtained and combined with the input target value sequence to calculate the multi-step sequence gradient loss function and sequence trend loss function of the current model. The multi-step sequence gradient loss function and sequence trend loss function can effectively improve the progress of electricity sales forecasting, thereby helping power companies to formulate more accurate power supply plans, identify peak and valley electricity consumption in advance, optimize the operation of power generation and energy storage systems, and avoid insufficient or excessive power supply due to trend forecasting errors.

[0142] On the other hand, the present invention further provides a computer-readable storage medium. Specifically, the computer-readable storage medium stores instructions, which are used to be read by a machine so that the machine executes any of the above power sales amount prediction methods.

[0143] Through the above technical scheme, the power sales prediction method based on the attention time series network and the readable storage medium provided by the present invention obtain the historical power sales data in the database of the power grid system, pre-process the historical power sales data, use the pre-processed historical power sales data to train the power sales prediction model, and finally predict the power sales according to the real-time power sales data of the current power grid system; specifically, the power sales prediction network model adopts the LSTM network model and the FCN network model to effectively capture the change characteristics and spatial characteristics of the power sales time series, so as to achieve reliable prediction of power sales, that is, effectively improve the prediction accuracy of power sales. Specifically, by introducing frequency feature extraction, two-dimensional processing of time series and improved loss function into the model, the model can more deeply explore the periodicity and trend characteristics of time series data, and achieve more accurate prediction of power sales. These improvement measures improve the prediction performance of the model and enhance its adaptability to complex time series data.

[0144] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0145] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0146] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0147] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0148] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0149] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0150] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0151] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0152] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A method for predicting electricity sales based on attention time series network, characterized in that: include: Acquire historical electricity sales data from a database of the power grid system, and preprocess the historical electricity sales data; Constructing a power sales forecasting network model, wherein the power sales forecasting network model includes an LSTM network model and an FCN network model; Training the electricity sales prediction network model according to the preprocessed historical electricity sales data; Obtaining real-time electricity sales data of the current power grid system; The real-time electricity sales data of the current power grid system is input into the power sales forecasting network model to obtain the power sales forecast value of the power grid system.

2. The method for predicting electricity sales according to claim 1, characterized in that: The historical electricity sales data includes electricity sales time, electricity sales amount, meteorological data, and macroeconomic data. The corresponding electricity sales amount, meteorological data, and macroeconomic data are aligned according to the electricity sales time, and a corresponding data set is constructed.

3. The method for predicting electricity sales according to claim 2, characterized in that: Preprocessing the historical electricity sales data includes: Processing the data set using an interpolation method; Using box plots to identify and handle outliers in the data set; The data set was standardized using z-score standardization; The data set is normalized.

4. The method for predicting electricity sales according to claim 3, characterized in that: The sales data is trained based on the preprocessed historical power sales data. The electricity forecasting network model includes: Perform preliminary feature screening on the preprocessed data set to obtain the data set to be input; Inputting the data set to be input into the input layer of the LSTM network model, wherein the LSTM network model includes a Dropout layer; Applying an attention mechanism to the output layer of the LSTM network model; Reprocessing the output data processed by the attention mechanism; Input the reprocessed data into the FCN network model; Output the predicted value; The model parameters of the LSTM network model and the FCN network model are modified according to the predicted value.

5. The method for predicting electricity sales according to claim 4, characterized in that: Perform preliminary feature screening on the preprocessed data set to obtain the input data set including: The Pearson correlation coefficient is used to obtain the correlation coefficient between each individual in the data set and the power sales amount; Determine whether the correlation coefficient between the individual in the data set and the power sales amount is greater than or equal to a correlation threshold; In the case where it is determined that the correlation coefficient between the individual in the data set and the power sales volume is greater than or equal to the correlation threshold, retaining the individual; When it is determined that the correlation coefficient between the individual in the data set and the power sales volume is less than a correlation threshold, deleting the individual; Get the data set to be input.

6. The method for predicting electricity sales according to claim 4, characterized in that: Reprocessing the output data processed by the attention mechanism includes: Perform fast Fourier transform on the output data processed by the attention mechanism, and select a preset number of frequency signals with the largest amplitude; Folding the frequency signal into a two-dimensional data structure according to the corresponding period; A convolution process is performed on the two-dimensional data structure to obtain a one-dimensional data structure.

7. The method for predicting electricity sales according to claim 4, characterized in that: Correcting the model parameters of the LSTM network model and the FCN network model according to the predicted value includes: Get the predicted value sequence and target value sequence; Obtain a multi-step sequence gradient loss function according to the predicted value sequence and the target value sequence; A sequence trend loss function is obtained according to the predicted value sequence and the target value sequence.

8. The method for predicting electricity sales according to claim 7, characterized in that: Acquiring a multi-step sequence gradient loss function according to the predicted value sequence and the target value sequence includes: According to formula (1), the multi-step gradient values ​​of the predicted value sequence are obtained. in, is the gradient value of the t-th prediction value with a step length of k in the prediction value sequence, is the tth predicted value in the predicted value sequence, is the tkth prediction value in the prediction value sequence, t is the sequence number, and t=k+1, k+2, ..., T, T is the maximum sequence, k is the step length, k∈{1, 2, ..., K}, K is the maximum step length; According to formula (2), the multi-step gradient values ​​of the target value sequence are obtained. D k S t =S t -S t-k , (2) Among them, Δ k S t is the gradient value of the t-th predicted value with a step length of k in the target value sequence, S t is the tth target value in the target value sequence, S t-k is the tkth target value in the target value sequence; According to formula (3), the attenuation weight of the step length is obtained: w k =exp(-λk), (3) Among them, w k is the decay weight of step size k, λ is the decay rate, and λ>0; According to formula (4), we can obtain the multi-step sequence gradient loss function: Among them, L1 is the multi-step sequence gradient loss function, B is the maximum batch value, D is the maximum feature dimension value, b is the batch number, and d is the dimension number.

9. The method for predicting electricity sales according to claim 8, characterized in that: Acquiring a sequence trend loss function according to the predicted value sequence and the target value sequence includes: According to formula (5), the first-order difference values ​​of adjacent time steps of the predicted value sequence are obtained. in, is the first-order difference value of the adjacent time steps of the predicted value sequence, is the t-1th predicted value in the predicted value sequence, and t=2, 3, ..., T; According to formula (6), the first-order difference values ​​of adjacent time steps of the target value sequence are obtained. ΔS t =S t -S t-1 , (6) Among them, ΔS t is the first-order difference value of the target value sequence in adjacent time steps, S t-1 is the t-1th target value in the target value sequence; According to formula (7), we can obtain the sequence trend loss function: Wherein, L2 is the sequence trend loss function, and sign(·) is the sign function.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and the instructions are used to be read by a machine so that the machine executes the power sales forecasting method according to any one of claims 1-9.