Method and apparatus for determining power consumption, and electronic device
By performing feature classification on electricity consumption data and training a self-attention mechanism model, the problem of capturing fluctuations in electricity consumption forecasting was solved, resulting in more accurate electricity consumption forecasting and improved power system dispatch efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANWEI POWER SUPPLY BUREAU OF GUANGDONG POWER GRID CORP
- Filing Date
- 2023-06-26
- Publication Date
- 2026-05-29
AI Technical Summary
Existing technologies for electricity consumption forecasting struggle to capture periodic fluctuations, leading to inaccurate predictions.
By acquiring and classifying the features of historical electricity consumption data, training an initial self-attention mechanism model, and optimizing the model by combining environmental information until the cross-entropy loss function converges, a target electricity consumption prediction model is established to predict electricity consumption data.
It improves the accuracy of electricity consumption forecasting, effectively captures periodic fluctuations in electricity consumption, and enhances the efficiency of power system dispatching.
Smart Images

Figure CN116975710B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of electricity, and more specifically, to a method, apparatus, computer-readable storage medium, and electronic device for determining electricity consumption. Background Technology
[0002] In the field of power systems, power system staff often work to predict the next electricity consumption based on real-time conditions in order to achieve effective dispatch. However, this work usually consumes a lot of manpower. Therefore, accurate prediction of electricity consumption through machine learning methods can free up manpower and effectively improve the efficiency of power dispatch in the power system.
[0003] Electricity consumption data for a specified area possesses certain statistical characteristics. Electricity consumption data in a fixed area is the result of combined electricity consumption across various industries within that area; it is a superposition of multiple electricity consumption patterns. Different industries exhibit different statistical characteristics: for industrial electricity consumption, industrial electricity consumption in a specified area typically exhibits a certain periodicity, meaning that weekday consumption is relatively stable while weekend consumption decreases significantly. For residential electricity consumption, it is closely related to holidays, weather conditions, and other lifestyle factors, showing significant fluctuations over time. These differences in statistical characteristics pose challenges to modeling the characteristics of electricity consumption sequence data. The total electricity consumption within a region, after superimposing industrial, residential, and commercial electricity consumption, exhibits both a certain periodicity and a certain degree of volatility, making direct prediction of the total electricity consumption within the region relatively difficult.
[0004] Therefore, there is an urgent need for a method to solve the problem of inaccurate electricity consumption forecasting. Summary of the Invention
[0005] The main objective of this application is to provide a method, apparatus, computer-readable storage medium, and electronic device for determining electricity consumption, so as to at least solve the problem that electricity consumption forecasting in the prior art is difficult to capture periodic fluctuations, resulting in inaccurate electricity consumption forecasting.
[0006] According to one aspect of this application, a method for determining electricity consumption is provided, comprising: acquiring first historical electricity consumption data and features corresponding to the first historical electricity consumption data, and classifying the first historical electricity consumption data according to the features corresponding to the first historical electricity consumption data to obtain a classification result corresponding to the first historical electricity consumption data, wherein the first historical electricity consumption data is the electricity consumption data of a user before the current time, and the classification result includes industrial electricity consumption data, residential electricity consumption data, and commercial electricity consumption data; acquiring multi-level intrinsic modal components of the first historical electricity consumption data, and inputting at least the multi-level intrinsic modal components of the first historical electricity consumption data into an initial self-attention mechanism model to obtain initial electricity consumption prediction data; determining electricity consumption based at least one of the classification result corresponding to the first historical electricity consumption data and the initial electricity consumption prediction data. The initial self-attention mechanism model is trained using the second historical electricity consumption data and the corresponding environmental information until the cross-entropy loss function converges. The initial self-attention mechanism model corresponding to the convergence of the cross-entropy loss function is then identified as the target electricity consumption prediction model. The second historical electricity consumption data refers to the electricity consumption data prior to the first historical electricity consumption data. The environmental information includes climate information data and time information data corresponding to the second historical electricity consumption data. The third historical electricity consumption data is then input into the target electricity consumption prediction model to obtain the target electricity consumption data. The third historical electricity consumption data is the user's electricity consumption data before the target time period, and the target electricity consumption data is the user's electricity consumption data within the target time period.
[0007] Optionally, after obtaining the first historical electricity consumption data and before classifying the first historical electricity consumption data, the method further includes: processing the first historical electricity consumption data to remove noise data from the first historical electricity consumption data, thereby obtaining processed first historical electricity consumption data.
[0008] Optionally, the first historical electricity consumption data is processed, including: normalizing the first historical electricity consumption data to obtain normalized first historical electricity consumption data; and regularizing the normalized first historical electricity consumption data to obtain processed first historical electricity consumption data.
[0009] Optionally, obtaining the features corresponding to the first historical electricity consumption data includes: inputting the first historical electricity consumption data into an LSTM neural network to obtain the features corresponding to the first historical electricity consumption data.
[0010] Optionally, the first historical electricity consumption data is classified according to the features corresponding to the first historical electricity consumption data to obtain the classification result corresponding to the first historical electricity consumption data, including: calculating the classification result output1 corresponding to the first historical electricity consumption data according to the formula output1=Sigmoid(W0×f), where Sigmoid is the activation function, W0 is the weight coefficient of the feature corresponding to the first historical electricity consumption data, and f is the feature corresponding to the first historical electricity consumption data.
[0011] Optionally, obtaining the multi-order intrinsic mode components of the first historical electricity consumption data includes: according to the formula Integrated empirical mode decomposition is performed on the first historical electricity consumption data to obtain the multi-order intrinsic mode components of the first historical electricity consumption data, where x(t) is the first historical electricity consumption data, and C j (t) represents the j-th intrinsic mode component of the first historical electricity consumption data, r J (t) represents the residual term of the j-th intrinsic mode component of the first historical electricity consumption data.
[0012] Optionally, the initial self-attention mechanism model is trained using second historical electricity consumption data and the corresponding environmental information, including: according to the formula Similarity ij =Neural(W1f i ,W1f j ), calculate the similarity coefficient (Similarity) of the initial self-attention mechanism model. ij Where Neural is a single-layer feedforward neural network, W1 is a learnable weight coefficient, and f i For the characteristics of the second historical electricity consumption data, f j The characteristics of the environmental information corresponding to the second historical electricity consumption data; according to formula α ij =softmax(Similarity) ij ), calculate the self-attention coefficient α of the initial self-attention mechanism model. ij Where softmax is the normalized exponential function; according to the formula h i =σ(α) ij W1f j ), calculate attention feature h i Where σ is the activation function; according to the formula Out i =ReLU∑ j (Qh j ), determine the initial electricity consumption prediction data Out iWhere ReLU is a linear rectified function and Q is the weight parameter of the attention feature.
[0013] Optionally, the cross-entropy loss function of the initial self-attention mechanism model is determined based on the classification result corresponding to the first historical electricity consumption data, including: calculating the cross-entropy loss function loss of the initial self-attention mechanism model according to the formula loss=-ylogx-(1-y)log(1-x), where y is the classification result corresponding to the second historical electricity consumption data and x is the classification result corresponding to the first historical electricity consumption data.
[0014] Optionally, determining the cross-entropy loss function of the initial self-attention mechanism model based on the initial electricity consumption prediction data includes: calculating the cross-entropy loss function loss of the initial self-attention mechanism model according to the formula loss=-ylogx-(1-y)log(1-x), where y is the second historical electricity consumption data and x is the initial electricity consumption prediction data.
[0015] According to another aspect of this application, an apparatus for determining electricity consumption is provided, comprising: acquiring first historical electricity consumption data and features corresponding to the first historical electricity consumption data, and classifying the first historical electricity consumption data according to the features corresponding to the first historical electricity consumption data to obtain a classification result corresponding to the first historical electricity consumption data, wherein the first historical electricity consumption data is the electricity consumption data of a user before the current time, and the classification result includes industrial electricity consumption data, residential electricity consumption data, and commercial electricity consumption data; acquiring multi-level intrinsic modal components of the first historical electricity consumption data, and inputting at least the multi-level intrinsic modal components of the first historical electricity consumption data into an initial self-attention mechanism model to obtain initial electricity consumption prediction data; and determining, at least according to one of the classification result corresponding to the first historical electricity consumption data and the initial electricity consumption prediction data. The cross-entropy loss function of the initial self-attention mechanism model is determined, and the initial self-attention mechanism model is trained using second historical electricity consumption data and environmental information corresponding to the second historical electricity consumption data until the cross-entropy loss function converges. The initial self-attention mechanism model corresponding to the convergence of the cross-entropy loss function is determined as the target electricity consumption prediction model. Here, the second historical electricity consumption data is the electricity consumption data before the first historical electricity consumption data, and the environmental information includes climate information data and time information data corresponding to the second historical electricity consumption data. The third historical electricity consumption data is input into the target electricity consumption prediction model to obtain the target electricity consumption data. Here, the third historical electricity consumption data is the user's electricity consumption data before the target time period, and the target electricity consumption data is the user's electricity consumption data within the target time period.
[0016] According to another aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform any of the methods described.
[0017] According to another aspect of this application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to perform any of the methods described by the computer program.
[0018] Applying the technical solution of this application, firstly, firstly, the first historical electricity consumption data and the corresponding features are obtained, and the first historical electricity consumption data is classified according to the corresponding features to obtain the classification result. Then, the multi-level intrinsic modal components of the first historical electricity consumption data are obtained, and at least one of the multi-level intrinsic modal components of the first historical electricity consumption data is input into the initial self-attention mechanism model to obtain the initial electricity consumption prediction data. Next, at least one of the classification result and the initial electricity consumption prediction data is used to determine the cross-entropy loss function of the initial self-attention mechanism model, and the initial self-attention mechanism model is trained using the second historical electricity consumption data and the environmental information corresponding to the second historical electricity consumption data until the cross-entropy loss function converges. The initial self-attention mechanism model corresponding to the convergence of the cross-entropy loss function is then determined as the target electricity consumption prediction model. Finally, the third historical electricity consumption data is input into the target electricity consumption prediction model to obtain the target electricity consumption data. By extracting electricity consumption features and determining the industry category to which the electricity consumption data belongs, ensemble empirical mode decomposition (EMD) features are used to obtain multi-order intrinsic mode components at different time scales, and prediction results are obtained based on these components. The cross-entropy between the classification and prediction results is calculated, and the model is trained based on the gradient of the cross-entropy to obtain the target model. Finally, historical electricity consumption data is input into this target model to obtain the final target electricity consumption prediction result. This solves the problem in existing technologies where electricity consumption prediction struggles to capture periodic fluctuations, leading to inaccurate predictions. Attached Figure Description
[0019] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0020] Figure 1 A hardware structure block diagram of a mobile terminal for performing a method for determining power consumption according to an embodiment of this application is shown.
[0021] Figure 2A flowchart illustrating a method for determining electricity consumption according to an embodiment of this application is shown.
[0022] Figure 3 A schematic diagram illustrating the workflow of a power consumption determination model provided according to an embodiment of this application is shown.
[0023] Figure 4 A structural block diagram of a power consumption determination device provided according to an embodiment of this application is shown.
[0024] The above figures include the following reference numerals:
[0025] 102. Processor; 104. Memory; 106. Transmission device; 108. Input / output device. Detailed Implementation
[0026] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0027] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0028] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0029] For ease of description, the following explains some of the nouns or terms used in the embodiments of this application:
[0030] EEMD: Ensemble Empirical Mode Decomposition (EEMD) is an improved method of Empirical Mode Decomposition (EMPD). Compared to EMPD, EEMD can more effectively remove residual simulations by using the average of multiple noisy EMPD decompositions, thus solving this problem more effectively. EEMD has better decomposition efficiency, employing white noise to assist decomposition, thereby avoiding mode mixing as seen in EMPD. EEMD also has better modal synchronization.
[0031] Self-attention mechanism: The self-attention mechanism is an important structure in deep neural networks. It models the sequence by establishing relationships between each node in the sequence and itself. The advantages of the self-attention mechanism are: it can model long-distance dependencies, capture the associations of key information in the sequence, and has high parallel computation efficiency.
[0032] As described in the background section, existing technologies struggle to capture the periodic fluctuations in electricity consumption, leading to inaccurate predictions. To address this issue, embodiments of this application provide a method, apparatus, computer-readable storage medium, and electronic device for determining electricity consumption.
[0033] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0034] The methods and embodiments provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Taking running on a mobile terminal as an example, Figure 1 This is a hardware structure block diagram of a mobile terminal for a method of determining power consumption according to an embodiment of the present invention. For example... Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0035] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the power consumption determination method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. The transmission device 106 is used to receive or send data via a network. Specific examples of the aforementioned networks may include wireless networks provided by the mobile terminal's communication provider. In one example, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0036] This embodiment provides a method for determining the power consumption of a mobile terminal, computer terminal, or similar computing device. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0037] Figure 2 This is a flowchart of a method for determining electricity consumption according to an embodiment of this application. Figure 2 As shown, the method includes the following steps:
[0038] Step S201: Obtain the first historical electricity consumption data and the features corresponding to the first historical electricity consumption data, and classify the first historical electricity consumption data according to the features corresponding to the first historical electricity consumption data to obtain the classification result corresponding to the first historical electricity consumption data. The first historical electricity consumption data is the electricity consumption data of the user before the current time. The classification result includes industrial electricity consumption data, residential electricity consumption data and commercial electricity consumption data.
[0039] Specifically, the aforementioned first historical electricity consumption data can be obtained through power companies, smart meters, and electromagnetic field monitoring equipment. This first electricity consumption data can be specific electricity consumption figures or electricity consumption curves. The characteristic of this first historical electricity consumption data can be its volatility. For electricity consumption data in a specified area, different industries exhibit different statistical characteristics: for industrial electricity consumption, industrial electricity consumption in a specified area typically has a certain periodicity, i.e., electricity consumption is relatively stable on weekdays, while electricity consumption decreases significantly on weekends; while for residential electricity consumption, it is closely related to holidays, weather conditions, and other lifestyle factors, exhibiting greater volatility over time. Therefore, the industry type of the first historical electricity consumption data can be determined based on these characteristics.
[0040] Step S202: Obtain the multi-level intrinsic modal components of the first historical electricity consumption data, and input at least the multi-level intrinsic modal components of the first historical electricity consumption data into the initial self-attention mechanism model to obtain the initial electricity consumption prediction data.
[0041] Specifically, multi-order intrinsic mode components (IMFs) can be obtained by performing joint empirical mode decomposition (EEMD) on the aforementioned first historical electricity consumption data. The workflow of EEMD is as follows: white noise is added to the original signal to generate a noisy signal. The noisy signal is then decomposed using EMPD to obtain several IMFs. This process is repeated multiple times, adding different white noise each time. The resulting IMFs are summed, divided by the number of trials, and the residuals are removed to obtain the final IMF. Summing all the IMFs recovers the original signal. In general, EEMD has advantages such as excellent denoising, high decomposition efficiency, and mode synchronization, making it suitable for decomposing nonlinear and unstable signals. The main working principle of the self-attention mechanism is: each node in the input sequence is compared with other nodes in the sequence, calculating the correlation between them. An attention weight matrix is calculated, where each element represents the degree of correlation between two corresponding nodes. Based on the attention weights, the representation of each node in the sequence is updated to contain key information about the entire sequence.
[0042] Step S203: Based on at least one of the classification results corresponding to the first historical electricity consumption data and the initial electricity consumption prediction data, determine the cross-entropy loss function of the initial self-attention mechanism model, and train the initial self-attention mechanism model using the second historical electricity consumption data and the environmental information corresponding to the second historical electricity consumption data until the cross-entropy loss function converges. Determine the initial self-attention mechanism model corresponding to the convergence of the cross-entropy loss function as the target electricity consumption prediction model. The second historical electricity consumption data refers to the electricity consumption data prior to the first historical electricity consumption data, and the environmental information includes the climate information data and time information data corresponding to the second historical electricity consumption data.
[0043] Specifically, calculating the cross-entropy loss function measures the difference between the expected distribution and the true distribution, or the difference between the predicted result and the actual result; the smaller the difference, the better the model performance. Compared to mean squared error, it has the advantage of faster convergence speed, finding the global optimum more quickly. The cross-entropy loss function can also be used for binary or multi-class classification problems. In deep learning model training, cross-entropy, as a loss function, closely matches the degree of difference between the predicted result and the target, and can better drive model optimization.
[0044] Step S204: Input the third historical electricity consumption data into the target electricity consumption prediction model to obtain the target electricity consumption data, wherein the third historical electricity consumption data is the electricity consumption data of the user before the target time period, and the target electricity consumption data is the electricity consumption data of the user within the target time period.
[0045] Specifically, after obtaining the above target electricity consumption prediction model, since the above target electricity consumption prediction model has good prediction performance, accurate predicted electricity consumption data can be obtained directly based on the third historical electricity consumption data.
[0046] In this embodiment, firstly, firstly, the first historical electricity consumption data and its corresponding features are obtained, and the first historical electricity consumption data is classified according to the corresponding features to obtain the classification results. Next, the multi-level intrinsic modal components of the first historical electricity consumption data are obtained, and at least one of these components is input into the initial self-attention mechanism model to obtain initial electricity consumption prediction data. Then, at least one of the classification results and the initial electricity consumption prediction data is used to determine the cross-entropy loss function of the initial self-attention mechanism model. The initial self-attention mechanism model is trained using the second historical electricity consumption data and the environmental information corresponding to the second historical electricity consumption data until the cross-entropy loss function converges. The initial self-attention mechanism model corresponding to the convergence of the cross-entropy loss function is then determined as the target electricity consumption prediction model. Finally, the third historical electricity consumption data is input into the target electricity consumption prediction model to obtain the target electricity consumption data. By extracting electricity consumption features and determining the industry category to which the electricity consumption data belongs based on these features, ensemble empirical mode decomposition (EMD) is used to obtain multi-level intrinsic mode components at different time scales, and prediction results are obtained based on these components. The cross-entropy between the classification result and the prediction result is calculated, and the model is trained based on the gradient of the cross-entropy to obtain the target model. Finally, historical electricity consumption data is input into the target model to obtain the final target electricity consumption prediction result. This solves the problem in existing technologies where electricity consumption prediction struggles to capture the periodic fluctuations in electricity consumption, leading to inaccurate predictions.
[0047] In specific implementation, step S201 can be achieved through the following steps: Step S2011, process the first historical electricity consumption data to remove noise data from the first historical electricity consumption data, and obtain the processed first historical electricity consumption data. This method, by performing dimensionality reduction on a large number of features, removes irrelevant or redundant features, and retains only the features that contribute to the model performance, which can further facilitate LSTM in extracting features from the first historical data.
[0048] Specifically, the main reasons for data preprocessing before inputting data into a deep learning model include: resolving missing data issues, as real-world data often contains missing values that need to be processed before being input into the model. Common methods include imputation using the mean, sequence imputation, and random sampling imputation. Addressing imbalanced classification problems, where the label distribution of samples in classification problems can be severely imbalanced, requiring sample correction through sampling. Separating and integrating data, as training / validation / test sets need to be separated before standardization and encoding of the overall data. Improving training efficiency, through methods such as data buffering, can reduce computation time in each iteration, thus increasing training speed. Exploring data distribution, analyzing basic statistical characteristics, and observing the distribution helps in subsequent processing and modeling strategies.
[0049] To further improve the training speed and stability of the model, step S2011 of this application can be implemented through the following steps: Step S20111, normalizing the first historical electricity consumption data to obtain normalized first historical electricity consumption data; Step S20112, regularizing the normalized first historical electricity consumption data to obtain processed first historical electricity consumption data. This method, by normalizing and regularizing the data, can further improve the training speed and stability of the model.
[0050] Specifically, data normalization can adjust feature values to the same dimension, avoiding the influence of different dimensions. Data normalization includes transforming data to the range of 0-1 and standardizing it to a mean of 0 and a variance of 1. Data regularization can reduce model overfitting and improve generalization performance. Data regularization includes forcibly scaling weights to a certain range, adding a regularization term to the loss function, directly regularizing the weight matrix, or implementing it directly in the model layer.
[0051] Step S201 above can also be implemented in other ways, for example: in step S2012, the first historical electricity consumption data is input into an LSTM neural network to obtain the features corresponding to the first historical electricity consumption data. This method can quickly and easily extract the features corresponding to the first historical electricity consumption data.
[0052] Specifically, Long Short-Term Memory (LSTM) neural networks are a type of recurrent neural network. By incorporating gating structures, they address the problem of long-term dependencies in recurrent neural network models. The main structure of LSTM includes an input gate, a forget gate, and an output gate. The input gate controls which part of the input is added to the cell state, the forget gate controls which part of the cell state is forgotten, and the output gate controls how many cell states are output. Its working principle is as follows: First, the input gate and forget gate are calculated to determine how to handle the input and how to forget the previous cell state. Then, the forget gate selectively forgets the previous memory. The input gate selects whether to update the cell state at the next time step. Finally, the output gate selects how much of the current cell state is updated for output computation. LSTM can effectively cache long-term dependency information, and through its gating structure, it can selectively remember and forget, thus effectively solving the vanishing and exploding gradient problems.
[0053] Step S201 above can also be implemented in other ways, for example: in step S2013, according to the formula: output1 = Sigmoid(W0 × f), calculate the classification result output1 corresponding to the first historical electricity consumption data, where sigmoid is the activation function, W0 is the weight coefficient of the feature corresponding to the first historical electricity consumption data, and f is the feature corresponding to the first historical electricity consumption data. This method sets the activation function in the hidden layer neurons of the neural network, which can further compress the nonlinear output.
[0054] Specifically, the characteristics of the sigmoid function are: its domain is all real numbers, its value range is between 0 and 1, and as x increases from negative infinity to positive infinity, the function value gradually increases from 0 to 1, presenting an S-shaped curve. The slope of the function is the largest at x = 0, and the slope gradually tends to 0 as the absolute value of x increases.
[0055] In the specific implementation process, the above step S202 can be achieved through the following steps: Step S2021, according to the formula: Integrated empirical mode decomposition was performed on the aforementioned first historical electricity consumption data to obtain the multi-order intrinsic mode components of the aforementioned first historical electricity consumption data, where x(t) represents the aforementioned first historical electricity consumption data, and C j (t) represents the j-th intrinsic mode component of the aforementioned first historical electricity consumption data, r J (t) represents the residual term of the j-th intrinsic mode component of the aforementioned first historical electricity consumption data. This method can further improve the accuracy of integrated empirical mode decomposition.
[0056] Specifically, the residual term refers to the signal remaining after all orthogonal intrinsic mode functions (IMFs) have been decomposed; it represents the portion from which no useful information can be extracted. Through iterative filtering, the individual IMF components in the signal are decomposed. This process is achieved through the following steps: identifying all local extrema (maxima and minima) of the signal; constructing an IMF approximation based on the data between two adjacent extrema; further filtering the signal based on the obtained IMF approximation to eliminate residuals and obtain a more accurate IMF; repeating the above process until the amplitude and frequency of the residual signal are constant or monotonically changing. After decomposition, the obtained IMF components are orthogonal to the original signal. The remaining signal at this point is called the residual term. It may be a constant signal (i.e., the amplitude remains constant) or a monotonically changing signal (i.e., the frequency gradually approaches zero), representing noise.
[0057] The above step S203 can also be implemented in other ways, for example: step S2031, according to the formula Similarity ij =Neural(W1f i ,W1f j ), calculate the similarity coefficient (Similarity) of the above initial self-attention mechanism model. ij Where Neural is a single-layer feedforward neural network, W1 is a learnable weight coefficient, and f i For the characteristics of the aforementioned second historical electricity consumption data, f j The environmental information features corresponding to the aforementioned second historical electricity consumption data; Step S2032, according to formula α ij =softmax(Similarity) ij ), calculate the self-attention coefficient α of the above initial self-attention mechanism model. ij Where softmax is the normalized exponential function; step S2033, according to formula h i =σ(α) ij W1f j ), calculate attention feature h i Where σ is the activation function; Step S2034, according to formula Out i =ReLU∑ j (Qh j ), determine the above initial electricity consumption forecast data Out i Where ReLU is the linear rectified function and Q is the weight parameter of the attention feature mentioned above. This method can further improve the model's fitting ability.
[0058] Specifically, first, the similarity coefficient is calculated; then, based on the similarity coefficient, the self-attention coefficient is obtained; then, based on the self-attention coefficient, the attention feature is obtained; and finally, based on the attention feature, the predicted electricity consumption result is obtained. The ReLU function maps the input to the output, acting as a non-linear transformation. Furthermore, the ReLU function can accelerate model convergence. Compared to other activation functions, the ReLU function has a gradient of 1 at 0, which can transmit gradient signals faster and simplify the network structure, avoiding overfitting. In deep learning models, it is often used as an activation function in hidden layers, which is beneficial for deep structures and has good interpretability and inference capabilities. In summary, the ReLU function incorporates non-linear mapping into the model, enhancing the model's fitting ability, accelerating convergence speed, and facilitating the construction of deeper and more complex networks.
[0059] In some embodiments, step S203 can be implemented through the following steps: Step S2035, calculate the cross-entropy loss function loss of the initial self-attention mechanism model according to the formula loss = -ylogx - (1-y)log(1-x), where y is the classification result corresponding to the second historical electricity consumption data and x is the classification result corresponding to the first historical electricity consumption data. This method determines the cross-entropy loss function based on the classification results of the first and second historical electricity consumption data, which can further drive model optimization.
[0060] Specifically, calculating the cross-entropy loss function measures the difference between the expected distribution and the true distribution, or the difference between the predicted result and the actual result; the smaller the difference, the better the model performance. Compared to mean squared error, it has the advantage of faster convergence speed, finding the global optimum more quickly. The cross-entropy loss function can also be used for binary or multi-class classification problems. In deep learning model training, cross-entropy, as a loss function, closely matches the degree of difference between the predicted result and the target, and can better drive model optimization.
[0061] In some embodiments, step S203 can be implemented using other steps: Step S2036, calculate the cross-entropy loss function loss of the initial self-attention mechanism model according to the formula loss = -ylog x - (1-y)log(1-x), where y is the second historical electricity consumption data and x is the initial electricity consumption prediction data. This method determines the cross-entropy loss function based on the first historical electricity consumption data and the initial electricity consumption prediction data, which can further drive model optimization.
[0062] Specifically, calculating the cross-entropy loss function measures the difference between the expected distribution and the true distribution, or the difference between the predicted result and the actual result; the smaller the difference, the better the model performance. Compared to mean squared error, it has the advantage of faster convergence speed, finding the global optimum more quickly. The cross-entropy loss function can also be used for binary or multi-class classification problems. In deep learning model training, cross-entropy, as a loss function, closely matches the degree of difference between the predicted result and the target, and can better drive model optimization.
[0063] To enable those skilled in the art to better understand the technical solution of this application, the implementation process of the method for determining electricity consumption in this application will be described in detail below with reference to specific embodiments.
[0064] This embodiment relates to a specific method for determining electricity consumption, such as... Figure 3 As shown, it includes the following steps:
[0065] Step S1: Use LSTM to extract features from the electricity consumption data, obtain the features, and then input the prediction results for the industry based on the features;
[0066] Step S2: Then perform EEMD decomposition on the features to obtain multi-order components, residual terms, and additional information;
[0067] Step S3: For each obtained component, design a corresponding SAT model to model the data distribution characteristics of the component, thereby fitting the periodicity and volatility of the data, training each SAT model to fit the components of the real data, and obtaining the predicted values of each order component.
[0068] Step S4: Combine the predicted values of each SAT model for each order component to obtain the final predicted result of electricity consumption data.
[0069] Step S5: Train the model based on the outputs of the electricity consumption prediction results and the industry prediction results, along with their corresponding labels.
[0070] This application also provides a device for determining power consumption. It should be noted that this device can be used to execute the power consumption determination method provided in this application. This device is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0071] The following describes the power consumption determination device provided in the embodiments of this application.
[0072] Figure 4This is a schematic diagram of a power consumption determination device according to an embodiment of this application. Figure 4 As shown, the device includes:
[0073] The first acquisition unit 10 is used to acquire first historical electricity consumption data and features corresponding to the first historical electricity consumption data, and classify the first historical electricity consumption data according to the features corresponding to the first historical electricity consumption data to obtain the classification result corresponding to the first historical electricity consumption data. The first historical electricity consumption data is the electricity consumption data of the user before the current time, and the classification result includes industrial electricity consumption data, residential electricity consumption data and commercial electricity consumption data.
[0074] Specifically, the aforementioned first historical electricity consumption data can be obtained through power companies, smart meters, and electromagnetic field monitoring equipment. This first electricity consumption data can be specific electricity consumption figures or electricity consumption curves. The characteristic of this first historical electricity consumption data can be its volatility. For electricity consumption data in a specified area, different industries exhibit different statistical characteristics: for industrial electricity consumption, industrial electricity consumption in a specified area typically has a certain periodicity, i.e., electricity consumption is relatively stable on weekdays, while electricity consumption decreases significantly on weekends; while for residential electricity consumption, it is closely related to holidays, weather conditions, and other lifestyle factors, exhibiting greater volatility over time. Therefore, the industry type of the first historical electricity consumption data can be determined based on these characteristics.
[0075] The second acquisition unit 20 is used to acquire the multi-order intrinsic modal components of the first historical electricity consumption data, and at least input the multi-order intrinsic modal components of the first historical electricity consumption data into the initial self-attention mechanism model to obtain the initial electricity consumption prediction data.
[0076] Specifically, multi-order intrinsic mode components (IMFs) can be obtained by performing joint empirical mode decomposition (EEMD) on the aforementioned first historical electricity consumption data. The workflow of EEMD is as follows: white noise is added to the original signal to generate a noisy signal. The noisy signal is then decomposed using EMPD to obtain several IMFs. This process is repeated multiple times, adding different white noise each time. The resulting IMFs are summed, divided by the number of trials, and the residuals are removed to obtain the final IMF. Summing all the IMFs recovers the original signal. In general, EEMD has advantages such as excellent denoising, high decomposition efficiency, and mode synchronization, making it suitable for decomposing nonlinear and unstable signals. The main working principle of the self-attention mechanism is: each node in the input sequence is compared with other nodes in the sequence, calculating the correlation between them. An attention weight matrix is calculated, where each element represents the degree of correlation between two corresponding nodes. Based on the attention weights, the representation of each node in the sequence is updated to contain key information about the entire sequence.
[0077] The first determining unit 30 is configured to determine the cross-entropy loss function of the initial self-attention mechanism model based at least one of the classification results corresponding to the first historical electricity consumption data and the initial electricity consumption prediction data, and to train the initial self-attention mechanism model using the second historical electricity consumption data and the environmental information corresponding to the second historical electricity consumption data until the cross-entropy loss function converges, and to determine the initial self-attention mechanism model corresponding to the convergence of the cross-entropy loss function as the target electricity consumption prediction model, wherein the second historical electricity consumption data is the electricity consumption data prior to the first historical electricity consumption data, and the environmental information includes the climate information data and time information data corresponding to the second historical electricity consumption data;
[0078] Specifically, calculating the cross-entropy loss function measures the difference between the expected distribution and the true distribution, or the difference between the predicted result and the actual result; the smaller the difference, the better the model performance. Compared to mean squared error, it has the advantage of faster convergence speed, finding the global optimum more quickly. The cross-entropy loss function can also be used for binary or multi-class classification problems. In deep learning model training, cross-entropy, as a loss function, closely matches the degree of difference between the predicted result and the target, and can better drive model optimization.
[0079] The second determining unit 40 is used to input the third historical electricity consumption data into the target electricity consumption prediction model to obtain the target electricity consumption data, wherein the third historical electricity consumption data is the electricity consumption data of the user before the target time period, and the target electricity consumption data is the electricity consumption data of the user within the target time period.
[0080] Specifically, after obtaining the above target electricity consumption prediction model, since the above target electricity consumption prediction model has good prediction performance, accurate predicted electricity consumption data can be obtained directly based on the third historical electricity consumption data.
[0081] In this embodiment, the first acquisition unit acquires first historical electricity consumption data and the features corresponding to the first historical electricity consumption data, and classifies the first historical electricity consumption data according to the features to obtain the classification result corresponding to the first historical electricity consumption data; the second acquisition unit acquires the multi-level intrinsic modal components of the first historical electricity consumption data, and inputs at least the multi-level intrinsic modal components of the first historical electricity consumption data into the initial self-attention mechanism model to obtain the initial electricity consumption prediction data; the first determination unit determines the cross-entropy loss function of the initial self-attention mechanism model according to at least one of the classification result corresponding to the first historical electricity consumption data and the initial electricity consumption prediction data, and trains the initial self-attention mechanism model using the second historical electricity consumption data and the environmental information corresponding to the second historical electricity consumption data until the cross-entropy loss function converges, and determines the initial self-attention mechanism model corresponding to the convergence of the cross-entropy loss function as the target electricity consumption prediction model; the second determination unit inputs the third historical electricity consumption data into the target electricity consumption prediction model to obtain the target electricity consumption data. By extracting electricity consumption features and determining the industry category to which the electricity consumption data belongs based on these features, ensemble empirical mode decomposition (EMD) is used to obtain multi-level intrinsic mode components at different time scales, and prediction results are obtained based on these components. The cross-entropy between the classification result and the prediction result is calculated, and the model is trained based on the gradient of the cross-entropy to obtain the target model. Finally, historical electricity consumption data is input into the target model to obtain the final target electricity consumption prediction result. This solves the problem in existing technologies where electricity consumption prediction struggles to capture the periodic fluctuations in electricity consumption, leading to inaccurate predictions.
[0082] In specific implementation, the first determining unit includes a processing module for processing the first historical electricity consumption data to remove noise data and obtain processed first historical electricity consumption data. This device performs dimensionality reduction on a large number of features, removing irrelevant or redundant features and retaining only those contributing to the model's performance, which further facilitates LSTM's extraction of features from the first historical data.
[0083] Specifically, the main reasons for data preprocessing before inputting data into a deep learning model include: resolving missing data issues, as real-world data often contains missing values that need to be processed before being input into the model. Common methods include imputation using the mean, sequence imputation, and random sampling imputation. Addressing imbalanced classification problems, where the label distribution of samples in classification problems can be severely imbalanced, requiring sample correction through sampling. Separating and integrating data, as training / validation / test sets need to be separated before standardization and encoding of the overall data. Improving training efficiency, through methods such as data buffering, can reduce computation time in each iteration, thus increasing training speed. Exploring data distribution, analyzing basic statistical characteristics, and observing the distribution helps in subsequent processing and modeling strategies.
[0084] To further improve the training speed and stability of the model, the processing module of this application includes a first processing submodule and a second processing submodule. The first processing submodule normalizes the first historical electricity consumption data to obtain normalized first historical electricity consumption data. The second processing submodule regularizes the normalized first historical electricity consumption data to obtain processed first historical electricity consumption data. This device, by normalizing and regularizing the data, can further improve the training speed and stability of the model.
[0085] Specifically, data normalization can adjust feature values to the same dimension, avoiding the influence of different dimensions. Data normalization includes transforming data to the range of 0-1 and standardizing it to a mean of 0 and a variance of 1. Data regularization can reduce model overfitting and improve generalization performance. Data regularization includes forcibly scaling weights to a certain range, adding a regularization term to the loss function, directly regularizing the weight matrix, or implementing it directly in the model layer.
[0086] The first acquisition unit includes an input module for inputting the first historical electricity consumption data into an LSTM neural network to obtain the features corresponding to the first historical electricity consumption data. This device can quickly and easily extract the features corresponding to the first historical electricity consumption data.
[0087] Specifically, LSTM (Long Short-Term Memory) is a type of recurrent neural network. It addresses the long-term dependency problem in recurrent neural network models by incorporating a gating structure. The main structure of LSTM includes an input gate, a forget gate, and an output gate. The input gate controls which part of the input is added to the cell state, the forget gate controls which part of the cell state is forgotten, and the output gate controls how many cell states are output. Its working principle is as follows: First, the input gate and forget gate are calculated to determine how to handle the input and how to forget the previous cell state. Then, the forget gate selectively forgets the previous memory. The input gate selects whether to update the cell state at the next time step. Finally, the output gate selects how much of the current cell state is updated for output computation. LSTM effectively caches long-term dependency information, and through its gating structure, it selectively remembers and forgets, thus effectively solving the vanishing and exploding gradient problems.
[0088] The first acquisition unit includes a first calculation module, used to calculate the classification result output1 corresponding to the first historical electricity consumption data according to the formula output1 = Sigmoid(W0 × f), where Sigmoid is the activation function, W0 is the weight coefficient of the feature corresponding to the first historical electricity consumption data, and f is the feature corresponding to the first historical electricity consumption data. This device sets the activation function in the hidden layer neurons of the neural network, which can further compress the nonlinear output.
[0089] Specifically, the characteristics of the sigmoid function are: its domain is all real numbers, its value range is between 0 and 1, and as x increases from negative infinity to positive infinity, the function value gradually increases from 0 to 1, presenting an S-shaped curve. The slope of the function is the largest at x = 0, and the slope gradually tends to 0 as the absolute value of x increases.
[0090] In specific implementation, the second acquisition unit mentioned above includes a decomposition module, used to decompose according to the formula. Integrated empirical mode decomposition was performed on the aforementioned first historical electricity consumption data to obtain the multi-order intrinsic mode components of the aforementioned first historical electricity consumption data, where x(t) represents the aforementioned first historical electricity consumption data, and C j (t) represents the j-th intrinsic mode component of the aforementioned first historical electricity consumption data, r J (t) represents the residual term of the j-th intrinsic mode component of the aforementioned first historical electricity consumption data. This device can further improve the accuracy of integrated empirical mode decomposition.
[0091] Specifically, the residual term refers to the signal remaining after all orthogonal intrinsic mode functions (IMFs) have been decomposed; it represents the portion from which no useful information can be extracted. Through iterative filtering, the individual IMF components in the signal are decomposed. This process is achieved through the following steps: identifying all local extrema (maxima and minima) of the signal; constructing an IMF approximation based on the data between two adjacent extrema; further filtering the signal based on the obtained IMF approximation to eliminate residuals and obtain a more accurate IMF; repeating the above process until the amplitude and frequency of the residual signal are constant or monotonically changing. After decomposition, the obtained IMF components are orthogonal to the original signal. The remaining signal at this point is called the residual term. It may be a constant signal (i.e., the amplitude remains constant) or a monotonically changing signal (i.e., the frequency gradually approaches zero), representing noise.
[0092] The aforementioned first determining unit includes a second calculation module, a third calculation module, a fourth calculation module, and a determining module, wherein the second calculation module is used to determine the similarity based on the formula. ij =Neural(W1f i ,W1f j ), calculate the similarity coefficient (Similarity) of the above initial self-attention mechanism model. ij Where Neural is a single-layer feedforward neural network, W1 is a learnable weight coefficient, and f i For the characteristics of the aforementioned second historical electricity consumption data, f j The environmental information features corresponding to the second historical electricity consumption data mentioned above; the third calculation module is used to calculate according to the formula: α ij =softmax(Similarity) ij ), calculate the self-attention coefficient α of the above initial self-attention mechanism model. ij Where softmax is the normalized exponential function; the fourth calculation module is used to calculate h according to the formula. i =σ(α) ij W1f j ), calculate attention feature h i Where σ is the activation function; the determination module is used to determine the formula Out i =ReLU∑ j (Qh j ), determine the above initial electricity consumption forecast data Out i Where ReLU is the linear rectified function and Q is the weight parameter of the attention feature mentioned above. This device can further improve the model's fitting ability.
[0093] Specifically, first, the similarity coefficient is calculated; then, based on the similarity coefficient, the self-attention coefficient is obtained; then, based on the self-attention coefficient, the attention feature is obtained; and finally, based on the attention feature, the predicted electricity consumption result is obtained. The ReLU function maps the input to the output, acting as a non-linear transformation. Furthermore, the ReLU function can accelerate model convergence. Compared to other activation functions, the ReLU function has a gradient of 1 at 0, which can transmit gradient signals faster and simplify the network structure, avoiding overfitting. In deep learning models, it is often used as an activation function in hidden layers, which is beneficial for deep structures and has good interpretability and inference capabilities. In summary, the ReLU function incorporates non-linear mapping into the model, enhancing the model's fitting ability, accelerating convergence speed, and facilitating the construction of deeper and more complex networks.
[0094] In some embodiments, the first determining unit includes a fifth calculation module, used to calculate the cross-entropy loss function `loss` of the initial self-attention mechanism model according to the formula: `loss = -ylogx - (1-y)log(1-x)`, where `y` is the classification result corresponding to the second historical electricity consumption data, and `x` is the classification result corresponding to the first historical electricity consumption data. This device determines the cross-entropy loss function based on the classification results of the first and second historical electricity consumption data, which can further drive model optimization.
[0095] Specifically, calculating the cross-entropy loss function measures the difference between the expected distribution and the true distribution, or the difference between the predicted result and the actual result; the smaller the difference, the better the model performance. Compared to mean squared error, it has the advantage of faster convergence speed, finding the global optimum more quickly. The cross-entropy loss function can also be used for binary or multi-class classification problems. In deep learning model training, cross-entropy, as a loss function, closely matches the degree of difference between the predicted result and the target, and can better drive model optimization.
[0096] In some embodiments, the first determining unit includes a sixth calculation module, used to calculate the cross-entropy loss function loss of the initial self-attention mechanism model according to the formula: loss = -ylogx - (1-y)log(1-x), where y is the second historical electricity consumption data and x is the initial electricity consumption prediction data. This device determines the cross-entropy loss function based on the first historical electricity consumption data and the initial electricity consumption prediction data, which can further drive model optimization.
[0097] Specifically, calculating the cross-entropy loss function measures the difference between the expected distribution and the true distribution, or the difference between the predicted result and the actual result; the smaller the difference, the better the model performance. Compared to mean squared error, it has the advantage of faster convergence speed, finding the global optimum more quickly. The cross-entropy loss function can also be used for binary or multi-class classification problems. In deep learning model training, cross-entropy, as a loss function, closely matches the degree of difference between the predicted result and the target, and can better drive model optimization.
[0098] The aforementioned power consumption determination device includes a processor and a memory. The first acquisition unit, second acquisition unit, first determination unit, and second determination unit are all stored as program units in the memory. The processor executes these program units stored in the memory to achieve the corresponding functions. All of the above modules are located in the same processor; alternatively, the modules may be located in different processors in any combination.
[0099] The processor contains a core, which retrieves the corresponding program unit from memory. One or more cores can be configured, and power consumption is determined by adjusting core parameters.
[0100] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0101] This invention provides a computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device containing the computer-readable storage medium to perform the power consumption determination method.
[0102] Specifically, the methods for determining electricity consumption include:
[0103] Step S201: Obtain the first historical electricity consumption data and the features corresponding to the first historical electricity consumption data, and classify the first historical electricity consumption data according to the features corresponding to the first historical electricity consumption data to obtain the classification result corresponding to the first historical electricity consumption data. The first historical electricity consumption data is the electricity consumption data of the user before the current time. The classification result includes industrial electricity consumption data, residential electricity consumption data and commercial electricity consumption data.
[0104] Specifically, the aforementioned first historical electricity consumption data can be obtained through power companies, smart meters, and electromagnetic field monitoring equipment. This first electricity consumption data can be specific electricity consumption figures or electricity consumption curves. The characteristic of this first historical electricity consumption data can be its volatility. For electricity consumption data in a specified area, different industries exhibit different statistical characteristics: for industrial electricity consumption, industrial electricity consumption in a specified area typically has a certain periodicity, i.e., electricity consumption is relatively stable on weekdays, while electricity consumption decreases significantly on weekends; while for residential electricity consumption, it is closely related to holidays, weather conditions, and other lifestyle factors, exhibiting greater volatility over time. Therefore, the industry type of the first historical electricity consumption data can be determined based on these characteristics.
[0105] Step S202: Obtain the multi-level intrinsic modal components of the first historical electricity consumption data, and input at least the multi-level intrinsic modal components of the first historical electricity consumption data into the initial self-attention mechanism model to obtain the initial electricity consumption prediction data.
[0106] Specifically, multi-order intrinsic mode components (IMFs) can be obtained by performing joint empirical mode decomposition (EEMD) on the aforementioned first historical electricity consumption data. The workflow of EEMD is as follows: white noise is added to the original signal to generate a noisy signal. The noisy signal is then decomposed using EMPD to obtain several IMFs. This process is repeated multiple times, adding different white noise each time. The resulting IMFs are summed, divided by the number of trials, and the residuals are removed to obtain the final IMF. Summing all the IMFs recovers the original signal. In general, EEMD has advantages such as excellent denoising, high decomposition efficiency, and mode synchronization, making it suitable for decomposing nonlinear and unstable signals. The main working principle of the self-attention mechanism is: each node in the input sequence is compared with other nodes in the sequence, calculating the correlation between them. An attention weight matrix is calculated, where each element represents the degree of correlation between two corresponding nodes. Based on the attention weights, the representation of each node in the sequence is updated to contain key information about the entire sequence.
[0107] Step S203: Based on at least one of the classification results corresponding to the first historical electricity consumption data and the initial electricity consumption prediction data, determine the cross-entropy loss function of the initial self-attention mechanism model, and train the initial self-attention mechanism model using the second historical electricity consumption data and the environmental information corresponding to the second historical electricity consumption data until the cross-entropy loss function converges. Determine the initial self-attention mechanism model corresponding to the convergence of the cross-entropy loss function as the target electricity consumption prediction model. The second historical electricity consumption data refers to the electricity consumption data prior to the first historical electricity consumption data, and the environmental information includes the climate information data and time information data corresponding to the second historical electricity consumption data.
[0108] Specifically, calculating the cross-entropy loss function measures the difference between the expected distribution and the true distribution, or the difference between the predicted result and the actual result; the smaller the difference, the better the model performance. Compared to mean squared error, it has the advantage of faster convergence speed, finding the global optimum more quickly. The cross-entropy loss function can also be used for binary or multi-class classification problems. In deep learning model training, cross-entropy, as a loss function, closely matches the degree of difference between the predicted result and the target, and can better drive model optimization.
[0109] Step S204: Input the third historical electricity consumption data into the target electricity consumption prediction model to obtain the target electricity consumption data, wherein the third historical electricity consumption data is the electricity consumption data of the user before the target time period, and the target electricity consumption data is the electricity consumption data of the user within the target time period.
[0110] Specifically, after obtaining the above target electricity consumption prediction model, since the above target electricity consumption prediction model has good prediction performance, accurate predicted electricity consumption data can be obtained directly based on the third historical electricity consumption data.
[0111] This invention provides a processor for running a program, wherein the program executes the method for determining power consumption.
[0112] Specifically, the methods for determining electricity consumption include:
[0113] Step S201: Obtain the first historical electricity consumption data and the features corresponding to the first historical electricity consumption data, and classify the first historical electricity consumption data according to the features corresponding to the first historical electricity consumption data to obtain the classification result corresponding to the first historical electricity consumption data. The first historical electricity consumption data is the electricity consumption data of the user before the current time. The classification result includes industrial electricity consumption data, residential electricity consumption data and commercial electricity consumption data.
[0114] Step S202: Obtain the multi-level intrinsic modal components of the first historical electricity consumption data, and input at least the multi-level intrinsic modal components of the first historical electricity consumption data into the initial self-attention mechanism model to obtain the initial electricity consumption prediction data.
[0115] Step S203: Based on at least one of the classification results corresponding to the first historical electricity consumption data and the initial electricity consumption prediction data, determine the cross-entropy loss function of the initial self-attention mechanism model, and train the initial self-attention mechanism model using the second historical electricity consumption data and the environmental information corresponding to the second historical electricity consumption data until the cross-entropy loss function converges. Determine the initial self-attention mechanism model corresponding to the convergence of the cross-entropy loss function as the target electricity consumption prediction model. The second historical electricity consumption data refers to the electricity consumption data prior to the first historical electricity consumption data, and the environmental information includes the climate information data and time information data corresponding to the second historical electricity consumption data.
[0116] Step S204: Input the third historical electricity consumption data into the target electricity consumption prediction model to obtain the target electricity consumption data, wherein the third historical electricity consumption data is the electricity consumption data of the user before the target time period, and the target electricity consumption data is the electricity consumption data of the user within the target time period.
[0117] This invention provides a device including a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs at least the following steps:
[0118] Step S201: Obtain the first historical electricity consumption data and the features corresponding to the first historical electricity consumption data, and classify the first historical electricity consumption data according to the features corresponding to the first historical electricity consumption data to obtain the classification result corresponding to the first historical electricity consumption data. The first historical electricity consumption data is the electricity consumption data of the user before the current time. The classification result includes industrial electricity consumption data, residential electricity consumption data and commercial electricity consumption data.
[0119] Step S202: Obtain the multi-level intrinsic modal components of the first historical electricity consumption data, and input at least the multi-level intrinsic modal components of the first historical electricity consumption data into the initial self-attention mechanism model to obtain the initial electricity consumption prediction data.
[0120] Step S203: Based on at least one of the classification results corresponding to the first historical electricity consumption data and the initial electricity consumption prediction data, determine the cross-entropy loss function of the initial self-attention mechanism model, and train the initial self-attention mechanism model using the second historical electricity consumption data and the environmental information corresponding to the second historical electricity consumption data until the cross-entropy loss function converges. Determine the initial self-attention mechanism model corresponding to the convergence of the cross-entropy loss function as the target electricity consumption prediction model. The second historical electricity consumption data refers to the electricity consumption data prior to the first historical electricity consumption data, and the environmental information includes the climate information data and time information data corresponding to the second historical electricity consumption data.
[0121] Step S204: Input the third historical electricity consumption data into the target electricity consumption prediction model to obtain the target electricity consumption data, wherein the third historical electricity consumption data is the electricity consumption data of the user before the target time period, and the target electricity consumption data is the electricity consumption data of the user within the target time period.
[0122] The devices mentioned in this article can be servers, PCs, tablets, mobile phones, etc.
[0123] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having at least the following method steps:
[0124] Step S201: Obtain the first historical electricity consumption data and the features corresponding to the first historical electricity consumption data, and classify the first historical electricity consumption data according to the features corresponding to the first historical electricity consumption data to obtain the classification result corresponding to the first historical electricity consumption data. The first historical electricity consumption data is the electricity consumption data of the user before the current time. The classification result includes industrial electricity consumption data, residential electricity consumption data and commercial electricity consumption data.
[0125] Step S202: Obtain the multi-level intrinsic modal components of the first historical electricity consumption data, and input at least the multi-level intrinsic modal components of the first historical electricity consumption data into the initial self-attention mechanism model to obtain the initial electricity consumption prediction data.
[0126] Step S203: Based on at least one of the classification results corresponding to the first historical electricity consumption data and the initial electricity consumption prediction data, determine the cross-entropy loss function of the initial self-attention mechanism model, and train the initial self-attention mechanism model using the second historical electricity consumption data and the environmental information corresponding to the second historical electricity consumption data until the cross-entropy loss function converges. Determine the initial self-attention mechanism model corresponding to the convergence of the cross-entropy loss function as the target electricity consumption prediction model. The second historical electricity consumption data refers to the electricity consumption data prior to the first historical electricity consumption data, and the environmental information includes the climate information data and time information data corresponding to the second historical electricity consumption data.
[0127] Step S204: Input the third historical electricity consumption data into the target electricity consumption prediction model to obtain the target electricity consumption data, wherein the third historical electricity consumption data is the electricity consumption data of the user before the target time period, and the target electricity consumption data is the electricity consumption data of the user within the target time period.
[0128] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0129] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0130] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0131] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0132] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0133] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0134] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, like read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0135] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, 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 technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0136] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0137] As can be seen from the above description, the embodiments of this application achieve the following technical effects:
[0138] 1) The method for determining electricity consumption in this application firstly obtains first historical electricity consumption data and the features corresponding to the first historical electricity consumption data, and classifies the first historical electricity consumption data according to the features corresponding to the first historical electricity consumption data to obtain the classification result corresponding to the first historical electricity consumption data; then, it obtains the multi-level intrinsic modal components of the first historical electricity consumption data, and inputs at least the multi-level intrinsic modal components of the first historical electricity consumption data into an initial self-attention mechanism model to obtain initial electricity consumption prediction data; then, it determines the cross-entropy loss function of the initial self-attention mechanism model according to at least one of the classification result corresponding to the first historical electricity consumption data and the initial electricity consumption prediction data, and trains the initial self-attention mechanism model using second historical electricity consumption data and the environmental information corresponding to the second historical electricity consumption data until the cross-entropy loss function converges, and determines the initial self-attention mechanism model corresponding to the convergence of the cross-entropy loss function as the target electricity consumption prediction model; finally, it inputs the third historical electricity consumption data into the target electricity consumption prediction model to obtain the target electricity consumption data. By extracting electricity consumption features and determining the industry category to which the electricity consumption data belongs based on these features, ensemble empirical mode decomposition (EMD) is used to obtain multi-level intrinsic mode components at different time scales, and prediction results are obtained based on these components. The cross-entropy between the classification result and the prediction result is calculated, and the model is trained based on the gradient of the cross-entropy to obtain the target model. Finally, historical electricity consumption data is input into the target model to obtain the final target electricity consumption prediction result. This solves the problem in existing technologies where electricity consumption prediction struggles to capture the periodic fluctuations in electricity consumption, leading to inaccurate predictions.
[0139] 2) The power consumption determination device of this application comprises: a first acquisition unit acquiring first historical power consumption data and features corresponding to the first historical power consumption data, and classifying the first historical power consumption data according to the features corresponding to the first historical power consumption data to obtain classification results corresponding to the first historical power consumption data; a second acquisition unit acquiring multi-level intrinsic modal components of the first historical power consumption data, and inputting at least the multi-level intrinsic modal components of the first historical power consumption data into an initial self-attention mechanism model to obtain initial power consumption prediction data; a first determination unit determining the cross-entropy loss function of the initial self-attention mechanism model according to at least one of the classification results corresponding to the first historical power consumption data and the initial power consumption prediction data, and training the initial self-attention mechanism model using the second historical power consumption data and the environmental information corresponding to the second historical power consumption data until the cross-entropy loss function converges, and determining the initial self-attention mechanism model corresponding to the convergence of the cross-entropy loss function as the target power consumption prediction model; and a second determination unit inputting third historical power consumption data into the target power consumption prediction model to obtain target power consumption data. By extracting electricity consumption features and determining the industry category to which the electricity consumption data belongs based on these features, ensemble empirical mode decomposition (EMD) is used to obtain multi-level intrinsic mode components at different time scales, and prediction results are obtained based on these components. The cross-entropy between the classification result and the prediction result is calculated, and the model is trained based on the gradient of the cross-entropy to obtain the target model. Finally, historical electricity consumption data is input into the target model to obtain the final target electricity consumption prediction result. This solves the problem in existing technologies where electricity consumption prediction struggles to capture the periodic fluctuations in electricity consumption, leading to inaccurate predictions.
[0140] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for determining electricity consumption, characterized in that, include: Obtain first historical electricity consumption data and the features corresponding to the first historical electricity consumption data, and classify the first historical electricity consumption data according to the features corresponding to the first historical electricity consumption data to obtain the classification result corresponding to the first historical electricity consumption data. The first historical electricity consumption data is the electricity consumption data of the user before the current time. The classification result includes industrial electricity consumption data, residential electricity consumption data and commercial electricity consumption data. The multi-level intrinsic modal components of the first historical electricity consumption data are obtained, and at least the multi-level intrinsic modal components of the first historical electricity consumption data are input into the initial self-attention mechanism model to obtain the initial electricity consumption prediction data. Based on at least one of the classification results corresponding to the first historical electricity consumption data and the initial electricity consumption prediction data, the cross-entropy loss function of the initial self-attention mechanism model is determined. The initial self-attention mechanism model is then trained using the second historical electricity consumption data and the environmental information corresponding to the second historical electricity consumption data until the cross-entropy loss function converges. The initial self-attention mechanism model corresponding to the convergence of the cross-entropy loss function is then determined as the target electricity consumption prediction model. The second historical electricity consumption data refers to the electricity consumption data prior to the first historical electricity consumption data. The environmental information includes climate information data and time information data corresponding to the second historical electricity consumption data. The third historical electricity consumption data is input into the target electricity consumption prediction model to obtain the target electricity consumption data. The third historical electricity consumption data refers to the user's electricity consumption data before the target time period, and the target electricity consumption data refers to the user's electricity consumption data within the target time period. Based on the classification results corresponding to the first historical electricity consumption data, the cross-entropy loss function of the initial self-attention mechanism model is determined, including: according to the formula: Calculate the cross-entropy loss function of the initial self-attention mechanism model. ,in, This is the classification result corresponding to the second historical electricity consumption data. The classification result corresponding to the first historical electricity consumption data. Alternatively, based on the initial electricity consumption prediction data, determine the cross-entropy loss function of the initial self-attention mechanism model, including: according to the formula: Calculate the cross-entropy loss function of the initial self-attention mechanism model. ,in, This is the second historical electricity consumption data. The initial electricity consumption prediction data is provided.
2. The method according to claim 1, characterized in that, After acquiring the first historical electricity consumption data but before classifying the first historical electricity consumption data, the method further includes: The first historical electricity consumption data is processed to remove noise data, resulting in the processed first historical electricity consumption data.
3. The method according to claim 2, characterized in that, Processing the first historical electricity consumption data includes: The first historical electricity consumption data is normalized to obtain the normalized first historical electricity consumption data. The normalized first historical electricity consumption data is subjected to regularization processing to obtain the processed first historical electricity consumption data.
4. The method according to claim 1, characterized in that, Obtain the features corresponding to the first historical electricity consumption data, including: The first historical electricity consumption data is input into an LSTM neural network to obtain the features corresponding to the first historical electricity consumption data.
5. The method according to claim 1, characterized in that, Based on the characteristics corresponding to the first historical electricity consumption data, the first historical electricity consumption data is classified to obtain the classification results corresponding to the first historical electricity consumption data, including: According to the formula Calculate the classification result corresponding to the first historical electricity consumption data. ,in, For activation function, The weighting coefficients are the feature values corresponding to the first historical electricity consumption data. The feature corresponding to the first historical electricity consumption data.
6. The method according to claim 1, characterized in that, Obtaining the multi-order intrinsic modal components of the first historical electricity consumption data includes: According to the formula The first historical electricity consumption data is subjected to integrated empirical mode decomposition to obtain multi-order intrinsic mode components of the first historical electricity consumption data, wherein... This refers to the first historical electricity consumption data. Let j be the j-th intrinsic mode component of the first historical electricity consumption data. It is the residual term of the j-th intrinsic mode component of the first historical electricity consumption data.
7. The method according to claim 1, characterized in that, The initial self-attention mechanism model is trained using second historical electricity consumption data and the corresponding environmental information, including: According to the formula Calculate the similarity coefficient of the initial self-attention mechanism model. ,in, It is a single-layer feedforward neural network. These are learnable weight coefficients. The characteristics of the second historical electricity consumption data, Features of the environmental information corresponding to the second historical electricity consumption data; According to the formula Calculate the self-attention coefficients of the initial self-attention mechanism model. Where softmax is the normalized exponential function; According to the formula Calculate attention features ,in, For activation functions; According to the formula Determine the initial electricity consumption forecast data. ,in, It is a linear rectified function. The weight parameters for the attention feature are denoted as .
8. A device for determining electricity consumption, characterized in that, include: The first acquisition unit is used to acquire first historical electricity consumption data and features corresponding to the first historical electricity consumption data, and classify the first historical electricity consumption data according to the features corresponding to the first historical electricity consumption data to obtain the classification result corresponding to the first historical electricity consumption data. The first historical electricity consumption data is the electricity consumption data of the user before the current time, and the classification result includes industrial electricity consumption data, residential electricity consumption data and commercial electricity consumption data. The second acquisition unit is used to acquire the multi-level intrinsic modal components of the first historical electricity consumption data, and at least input the multi-level intrinsic modal components of the first historical electricity consumption data into the initial self-attention mechanism model to obtain the initial electricity consumption prediction data. The first determining unit is configured to determine the cross-entropy loss function of the initial self-attention mechanism model based at least one of the classification result corresponding to the first historical electricity consumption data and the initial electricity consumption prediction data, and to train the initial self-attention mechanism model using the second historical electricity consumption data and the environmental information corresponding to the second historical electricity consumption data until the cross-entropy loss function converges, and to determine the initial self-attention mechanism model corresponding to the convergence of the cross-entropy loss function as the target electricity consumption prediction model, wherein the second historical electricity consumption data is the electricity consumption data before the first historical electricity consumption data, and the environmental information includes climate information data and time information data corresponding to the second historical electricity consumption data; The second determining unit is used to input the third historical electricity consumption data into the target electricity consumption prediction model to obtain the target electricity consumption data, wherein the third historical electricity consumption data is the user's electricity consumption data before the target time period, and the target electricity consumption data is the user's electricity consumption data within the target time period. The first determining unit includes a fifth calculation module, used to calculate according to the formula: Calculate the cross-entropy loss function of the initial self-attention mechanism model. ,in, This is the classification result corresponding to the second historical electricity consumption data. The classification result corresponding to the first historical electricity consumption data. Alternatively, the first determining unit includes a sixth calculation module, used to calculate according to the formula: Calculate the cross-entropy loss function of the initial self-attention mechanism model. ,in, This is the second historical electricity consumption data. The initial electricity consumption prediction data is provided.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the method according to any one of claims 1 to 7.
10. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method of any one of claims 1 to 7 through the computer program.
Citation Information
Patent Citations
Short-term prediction method for electricity consumption of industrial user based on double-stage attention mechanism
CN113988385A
Power consumption prediction method and device, electronic device and electronic equipment
CN116205382A