A method, device and system for predicting enterprise electricity consumption eliminating weather influence

The Transformers model, improved by a global block self-attention mechanism, eliminates the influence of weather, achieves high-precision forecasting of enterprise electricity consumption, simplifies model complexity, and improves the correlation between electricity consumption and production capacity.

CN116307173BActive Publication Date: 2026-07-24SOUTH CHINA NORMAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SOUTH CHINA NORMAL UNIV
Filing Date
2023-03-15
Publication Date
2026-07-24

AI Technical Summary

Technical Problem

Existing technologies are unable to effectively eliminate the impact of weather, resulting in large errors in enterprise electricity consumption forecasts and high model complexity, making it impossible to intuitively obtain electricity consumption data for enterprises unaffected by weather.

Method used

An improved Transformers model using a global block self-attention mechanism extracts the expected value of enterprise electricity consumption and eliminates the influence of weather by processing vector concatenation, global block self-attention mechanism, masking, and attention mechanism.

Benefits of technology

It improved the accuracy of electricity consumption forecasting, reduced model complexity, simplified the model between enterprise electricity consumption and enterprise production capacity, and obtained a direct correlation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116307173B_ABST
    Figure CN116307173B_ABST
Patent Text Reader

Abstract

The present application relates to a kind of elimination weather influence enterprise electricity consumption prediction method.The present application is according to the influence of weather condition, production mode and non-production mode on enterprise electricity consumption, analyzes the characteristics of enterprise electricity consumption fluctuation with weather condition, uses the Transformers model improved based on global block self-attention mechanism to predict the expected value of enterprise electricity consumption, compared with the traditional attention mechanism, it is more suitable for the improvement of this task.The present application proposes the way of embedding weather characteristics into electricity consumption and using global block self-attention processing mechanism to process electricity consumption data embedded with weather characteristics is more suitable for processing engineering tasks of enterprise electricity consumption, the proposed method takes into account the advantages of segmented method, i.e., the amplitude and shape error of prediction is low, high reliability, greatly simplifies the design complexity of subsequent task.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the intersection of artificial intelligence and electricity consumption forecasting, and in particular to a method and apparatus for forecasting enterprise electricity consumption that eliminates the impact of weather. Background Technology

[0002] With the rapid development of the Internet of Things, big data, and artificial intelligence, smart grids have become deeply integrated into people's production and daily lives. While making significant contributions to ensuring electricity supply, they also play a crucial role and hold immense potential in promoting the development of the micro and small economy, such as credit system construction and banking lending. Due to the timeliness, accuracy, and low cost of smart grid data, building enterprise credit assessment systems based on electricity data, aided by big data and artificial intelligence technologies, has become a research hotspot in recent years. Financial institutions also use credit systems built from electricity big data and real-time electricity data to assess the operational status of loan recipients, thereby providing corresponding financial services and mitigating financial risks.

[0003] A company's electricity consumption reflects its production and operational status; therefore, analyzing this consumption is an indispensable core element in understanding a company's operational status. However, research and applications based on big data in electricity use often encounter external environmental interference, making it difficult to directly reflect a company's electricity consumption and thus hindering the assessment of its operational status. Numerous studies have shown that weather is a major factor influencing electricity consumption among external environmental disturbances. Therefore, the question of how to eliminate weather-related impacts from actual electricity consumption data to obtain weather-independent electricity consumption data has become a research hotspot, and currently, there are two main approaches to address this issue.

[0004] The first type is the end-to-end approach, which simultaneously inputs weather variables into the algorithm, retains their impact, and considers them comprehensively in the task. For example, in 2021, Yizhen Wang et al. proposed a short-term electricity consumption prediction method based on Long Short-Term Memory (LSTM) networks that considers weather characteristics. This method incorporates the impact of weather characteristics into the model and achieves relatively accurate electricity consumption prediction. However, this model cannot intuitively eliminate the impact of weather to obtain the desired electricity consumption data of enterprises without weather characteristics, and it is difficult to explain the effectiveness of removing weather characteristics. In addition, its overall model is complex and requires the construction of different models for different downstream tasks.

[0005] The second approach is a segmented method. This involves first modeling the relationship between weather and enterprise electricity consumption, and then using counterfactual reasoning to eliminate the impact of weather on enterprise electricity consumption before inputting it into the downstream task model. For example, in 2022, Blake Shaffer et al. proposed a method that uses linear regression modeling between multiple variables and electricity consumption. By changing only the temperature factor while keeping other variable factors constant, they performed counterfactual reasoning on electricity demand in Texas, USA. However, this model relies on a large amount of historical data for prediction and is highly dependent on the resolution of weather data. In addition, the results are usually unsatisfactory. Summary of the Invention

[0006] Based on this, the purpose of this invention is to provide a method for predicting enterprise electricity consumption that eliminates the impact of weather. This method can intuitively eliminate the impact of weather to obtain the predicted expected enterprise electricity consumption data. The method has low error and high reliability, and can effectively reduce the model complexity of downstream tasks.

[0007] A method for predicting enterprise electricity consumption that eliminates the impact of weather, comprising:

[0008] Step 10 converts the input actual electricity consumption data into a vector to obtain an actual electricity consumption vector and a weather factor vector. The actual electricity consumption vector and the weather factor vector are then concatenated to obtain an actual electricity consumption vector containing weather features and a concatenated electricity consumption vector containing weather features.

[0009] Step 20: The actual electricity consumption vector containing weather characteristics is processed by a global block self-attention mechanism to obtain an actual electricity consumption feature vector containing self-attention representation;

[0010] Step 30: The spliced ​​electricity consumption vector containing weather features is processed by a masked global block self-attention mechanism to obtain a spliced ​​electricity consumption feature vector containing self-attention representation.

[0011] Step 40 performs attention mechanism processing on the actual power consumption feature vector containing self-attention representation and the concatenated power consumption feature vector containing self-attention representation to obtain the expected power consumption feature vector containing attention representation;

[0012] Step 50 processes the expected power consumption feature vector containing attention representation using a fully connected network and a convolutional network to extract the features of the expected power consumption and obtain the expected power consumption.

[0013] This invention analyzes the characteristics of enterprise electricity consumption fluctuations with weather conditions based on the influence of weather conditions, production modes, and non-production modes. It uses a Transformers model based on a global block self-attention mechanism to predict the expected value of enterprise electricity consumption, which is more suitable for this task than the traditional attention mechanism.

[0014] The prediction method described in this invention, on the one hand, can eliminate the influence of weather and thus predict the desired enterprise electricity consumption data, improve the direct correlation between enterprise electricity consumption and enterprise production capacity, and help simplify the model between enterprise electricity consumption and enterprise production capacity; on the other hand, it effectively reduces the computational complexity while improving the prediction accuracy.

[0015] Furthermore, the actual electricity consumption vector containing weather characteristics is respectively compared with the weight matrix W of the global block self-attention mechanism. Q1 and W K1 Perform a dot product operation to obtain the first query matrix and the first key matrix. Then, use the first query matrix and the first key matrix to calculate the global self-attention intermediate operation matrix corresponding to the weather features and the block self-attention intermediate operation matrix corresponding to the actual electricity consumption.

[0016] Furthermore, the spliced ​​electricity consumption vector containing weather features is respectively compared with the weight matrix W of the global block self-attention mechanism of the mask. Q2 and W K2 Perform a dot product operation to obtain the second query matrix and the second key matrix. Then, use the second query matrix and the second key matrix to calculate the global self-attention intermediate operation matrix of the mask corresponding to the weather features and the block self-attention intermediate operation matrix of the mask corresponding to the electricity consumption.

[0017] Furthermore, the global self-attention intermediate operation matrix G of the global block self-attention mechanism is calculated as follows:

[0018]

[0019] in,

[0020] Where: G ij Let q be the i-th row and j-th column of the global self-attention intermediate operation matrix G. i Let q = {q1, q2, ... q} n The i-th vector component on}, k j Let k = {k1, k2, ... k} n The j-th vector component on}, where n is the length of q, g i For q i The corresponding global self-attention mechanism range, GS represents the number of vector components that use the global self-attention mechanism;

[0021] The intermediate running matrix B of the global block self-attention mechanism is calculated as follows:

[0022]

[0023] in,

[0024] In the formula: B ij Let q be the i-th row and j-th column of the block-based self-attention intermediate operation matrix B. i Let q = {q1, q2, ... q} n The i-th vector component on}, k j Let k = {k1, k2, ... k} n The j-th vector component on}, where n is the length of q, b i For q i The corresponding block self-attention mechanism range, where BS represents the side length of the block.

[0025] Furthermore, the actual electricity consumption data also includes date information, which includes the day, week, month, year, and holiday. The calculation methods for the day code, week code, month code, and holiday code are as follows:

[0026] D = D i / 7

[0027] W = W i / W Y

[0028] M = M i / 12

[0029] J = J i / J Y

[0030] In the formula, D is the day code, D i W represents the week number, where W is the week code. i For which week, W Y M represents the week number for the whole year, and M represents the month code. i J represents the month number, and J represents the holiday code. i For which statutory holiday of the year, J Y This refers to the number of statutory holidays throughout the year.

[0031] Meanwhile, the present invention also provides a forecasting device for enterprise electricity consumption that eliminates the impact of weather, the forecasting device comprising:

[0032] The input unit is used to convert the input actual electricity consumption data into a vector to obtain an actual electricity consumption vector and a weather factor vector. The actual electricity consumption vector and the weather factor vector are then concatenated to obtain an actual electricity consumption vector containing weather features and a concatenated electricity consumption vector containing weather features.

[0033] The first feature extraction unit is used to process the actual electricity consumption vector containing weather features using a global block self-attention mechanism to obtain an actual electricity consumption feature vector containing self-attention representation.

[0034] The second feature extraction unit is used to process the spliced ​​electricity consumption vector containing weather features using a masked global block self-attention mechanism to obtain a spliced ​​electricity consumption feature vector containing self-attention representation.

[0035] The third feature extraction unit is used to perform attention mechanism processing on the actual power consumption feature vector containing self-attention representation and the concatenated power consumption feature vector containing self-attention representation to obtain the expected power consumption feature vector containing attention representation.

[0036] The output unit is used to process the expected power consumption feature vector containing attention representation using a fully connected network and a convolutional network to extract the features of the expected power consumption and obtain the expected power consumption.

[0037] The present invention also provides a forecasting system for enterprise electricity consumption to eliminate the impact of weather. The forecasting system includes a processor, a memory, and a computer program stored in the memory and executable by the processor. When the computer program is executed by the processor, it implements the steps of a forecasting method for enterprise electricity consumption to eliminate the impact of weather.

[0038] To better understand and implement this invention, the following detailed description is provided in conjunction with the accompanying drawings. Attached Figure Description

[0039] Figure 1 A schematic diagram of a predictive model for enterprise electricity consumption to eliminate the impact of weather.

[0040] Figure 2 Flowchart of a predictive model for enterprise electricity consumption to eliminate the impact of weather;

[0041] Figure 3 This is the intermediate operation matrix operation graph for the global block-based self-attention mechanism;

[0042] Figure 4 This is a graph of the self-attention score matrix operation for a global block-based self-attention mechanism.

[0043] Figure 5 This is a weather, date, and location embedding map of the true total electricity consumption vector containing weather features in the dataset.

[0044] Figure 6 This is a comparative experimental chart showing the prediction of a company's daily electricity consumption by using LR, LSTM, and the method of this invention to eliminate the impact of weather.

[0045] Figure 7 This is a comparison chart of the predicted and actual electricity consumption of a company over three quarters after eliminating the impact of weather. Detailed Implementation

[0046] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings of the embodiments of the present invention. It should be understood that some terms and definitions used herein are as follows:

[0047] (1) "Actual electricity consumption"

[0048] The data recorded by the power grid represents the actual electricity consumption of enterprises.

[0049] (2) "Expected electricity consumption"

[0050] By performing the predictive processing described in this invention on the enterprise usage data recorded by the power grid, the expected electricity consumption is obtained after eliminating the impact of weather.

[0051] This invention first constructs an initial predictive model for enterprise electricity consumption that eliminates the impact of weather, and then uses historical electricity consumption data of enterprises to train, verify and test the initial model to obtain a predictive model for enterprise electricity consumption that eliminates the impact of weather.

[0052] Please see Figure 1 This prediction model uses a Transformers model improved based on a global block self-attention mechanism to predict the expected value of enterprise electricity consumption. It includes an input unit, an encoding unit, a decoding unit, and an output unit. The encoding unit includes a global block self-attention layer and a forward propagation layer. The decoding unit includes a masked global block self-attention layer, an attention layer, and a forward propagation layer. Each of these layers is connected to a normalization layer and a residual layer to optimize the output of each layer. The operation of this prediction model includes the following main steps:

[0053] Step 10 converts the input actual electricity consumption data into a vector to obtain the actual electricity consumption vector. and weather factor vector For the actual power consumption vector and weather factor vector Vector concatenation is performed to obtain the actual electricity consumption vector containing weather characteristics. And spliced ​​electricity consumption vector containing weather characteristics

[0054] Step 20: Calculate the actual electricity consumption vector containing weather characteristics. A global block self-attention mechanism is applied to obtain the actual electricity consumption feature vector P1 containing self-attention representation;

[0055] Step 30: The spliced ​​power consumption vector containing weather characteristics A global block self-attention mechanism is applied to the mask to obtain the spliced ​​power consumption feature vector P2 containing self-attention representation.

[0056] Step 40 performs attention mechanism processing on the actual electricity consumption feature vector P1 containing self-attention representation and the concatenated electricity consumption feature vector P2 containing self-attention representation to obtain the expected electricity consumption feature vector P3 containing attention representation.

[0057] Step 50 processes the expected power consumption feature vector P3 containing attention representation using a fully connected network and a convolutional network to extract the features of the expected power consumption and obtain the expected power consumption.

[0058] Step 10 is executed by the input unit; step 20 is executed by the first feature extraction unit, specifically implemented by the encoding unit; step 30 is executed by the second feature extraction unit, specifically implemented by the mask global block self-attention layer of the decoding unit; step 40 is executed by the third feature extraction unit, specifically implemented by the attention layer of the decoding unit; and step 50 is executed by the output unit.

[0059] During the training phase of the predicted model for enterprise electricity consumption to eliminate the impact of weather, the acquired historical electricity consumption dataset of enterprises is divided into a training set, a validation set, and a test set. The initial model is trained using the training set until the loss value tends to stabilize or the training reaches the maximum number of iterations, thus obtaining an optimized model. Then, the optimized model is validated and tested using the validation set and the test set to obtain the optimal model and optimal hyperparameters.

[0060] During the operation phase of the prediction model for enterprise electricity consumption to eliminate the impact of weather, the electricity consumption data of the enterprise to be predicted is input into the optimization model, and the predicted expected electricity consumption of the enterprise is obtained after the optimization model is run.

[0061] The following two examples illustrate the detailed operation of the predictive model for enterprise electricity consumption that eliminates the impact of weather.

[0062] Example 1

[0063] Please see Figure 2 The specific operation mode of the prediction model for enterprise electricity consumption to eliminate the impact of weather in this invention is as follows.

[0064] Step 10 converts the input actual electricity consumption data into a vector to obtain the actual electricity consumption vector. and weather factor vector For the actual power consumption vector and weather factor vector Vector concatenation is performed to obtain the actual electricity consumption vector containing weather characteristics. And spliced ​​electricity consumption vector containing weather characteristics Step 10 specifically includes the following sub-steps.

[0065] Step 11: Convert the input actual electricity consumption data into a vector to obtain the actual electricity consumption vector and the weather factor vector. This step is performed by the input embedding module of the device's input unit.

[0066] Specifically, the input actual electricity consumption data includes actual electricity consumption and weather information, wherein the weather information includes weather category and temperature data, the weather category includes sunny, cloudy, rainy, snowy, foggy, etc.; the temperature data includes the highest temperature of the day, the lowest temperature of the day, and the current temperature at the time of collection.

[0067] The actual electricity consumption input is encoded, standardized, and subjected to one-dimensional convolution to obtain the actual electricity consumption vector. The weather category and temperature data are encoded, normalized, and subjected to one-dimensional convolution to obtain weather category vectors and temperature vectors. These vectors are then concatenated to obtain the weather factor vector. The encoding and calculation method for the temperature data is shown in equation (1):

[0068]

[0069] (1) In the formula, T is the temperature data code, T max It is the maximum temperature, T min It is the minimum temperature, T i This is the current temperature.

[0070] Step 12 is the actual power consumption vector. Set the first position vector The actual power consumption vector With the first position vector Add them together and then combine them with the weather factor vector. By concatenating the data, we obtain a vector of actual electricity consumption that includes weather characteristics. This step is performed by the position encoding module of the device's input unit.

[0071] Wherein, the first position vector The calculation method is as follows:

[0072]

[0073] Step 13: Set a vector with respect to the actual power consumption. A zero vector of the same dimension, and a second position vector is assigned to the zero vector. The zero vector and the second position vector Add them together to get the placeholder vector. The actual electricity consumption vector containing weather characteristics With the placeholder vector By splicing the data, a spliced ​​electricity consumption vector containing weather characteristics is obtained. This step is performed by the position encoding module of the device's input unit.

[0074] Wherein, the second position vector The calculation method is shown in equation (2).

[0075] Step 20: Calculate the actual electricity consumption vector containing weather characteristics. A global block self-attention mechanism is applied to obtain the actual electricity consumption feature vector P1 containing self-attention representation. Step 20 specifically includes the following sub-steps.

[0076] Step 21: Convert the actual electricity consumption vector containing weather characteristics... The weight matrix W of the global block self-attention mechanism is respectively compared with the weight matrix W. Q1 W K1 W V1 Perform a dot product operation to obtain the first query matrix Q1, the first key matrix K1, and the first value matrix V1.

[0077] Step 22 calculates the global self-attention intermediate operation matrix G1 corresponding to the weather features and the block self-attention intermediate operation matrix B1 corresponding to the actual electricity consumption using the first query matrix Q1 and the first key matrix K1. Specifically, this includes the following steps:

[0078] Step 221: Extract the vector components corresponding to the weather features from the first query matrix Q1. Extract the vector components corresponding to the weather features from the first key matrix K1. right and The global self-attention mechanism is used for computation to obtain the global self-attention intermediate operation matrix G1.

[0079] Please see Figure 3 The global self-attention intermediate operation matrix G1 is calculated as follows:

[0080]

[0081]

[0082] In equations (3) and (4), G ij Let q be the i-th row and j-th column of the global self-attention intermediate operation matrix G. i Let q = {q1, q2, ... q} n The i-th vector component on}, k j Let k = {k1, k2, ... k} n The j-th vector component on}, where n is the length of q, g i For q i The corresponding global self-attention mechanism range, GS represents the number of vector components that use the global self-attention mechanism.

[0083] Step 222: Extract the vector components corresponding to the actual electricity consumption from the first query matrix Q1. Extract the vector components corresponding to the actual electricity consumption from the first key matrix K1. right and The block-based self-attention mechanism is used for computation to obtain the block-based self-attention intermediate operation matrix B1.

[0084] The calculation method for the block-based self-attention intermediate operation matrix B1 is as follows:

[0085]

[0086]

[0087] In equations (5) and (6), B ij Let b be the i-th row and j-th column of the block-based self-attention intermediate operation matrix B. i For q i The corresponding block self-attention mechanism range, where BS represents the side length of the block.

[0088] Step 23 involves adding the global self-attention intermediate operation matrix G1 and the block self-attention intermediate operation matrix B1 together and then performing a softmax operation to obtain the first attention distribution matrix S1.

[0089] Please see Figure 4 The attention distribution matrix S1 is calculated as follows:

[0090] S = soft max(G + B) (7)

[0091] Step 24: Perform a dot product operation between the first attention distribution matrix S1 and the first value matrix V1 to obtain the actual electricity consumption feature vector P1 containing self-attention representation, and optimize the actual electricity consumption feature vector P1 containing self-attention representation using a normalization layer and a residual layer.

[0092] Steps 21 to 24 are executed by the global block self-attention module of the first feature unit of the device.

[0093] Step 30: The spliced ​​power consumption vector containing weather characteristics A global block self-attention mechanism is applied to the mask to obtain a spliced ​​power consumption feature vector P2 containing self-attention representation. Step 30 specifically includes the following sub-steps.

[0094] Step 31 involves splicing the electricity consumption vector containing weather characteristics. The weight matrix W of the global block self-attention mechanism of the mask respectively Q2 W K2 W V2 Perform a dot product operation to obtain the second query matrix Q2, the second key matrix K2, and the second value matrix V2.

[0095] Step 32 calculates the global self-attention intermediate operation matrix G2 of the mask corresponding to weather features and the block self-attention intermediate operation matrix B2 of the mask corresponding to spliced ​​electricity consumption using the second query matrix Q2 and the second key matrix K2. Specifically, it includes the following steps:

[0096] Step 321: Extract the vector components corresponding to the weather features from the second query matrix Q2. Extract the vector components corresponding to the weather features from the second key matrix K2. right and The global self-attention mechanism is used for calculation to obtain the global self-attention intermediate operation matrix G2 of the mask. The calculation method is shown in equations (3) and (4).

[0097] Step 322: Extract the vector components corresponding to the spliced ​​electricity consumption from the second query matrix Q2. Extract the vector components corresponding to the spliced ​​electricity consumption from the second key matrix K2. right and The block self-attention mechanism is used for calculation to obtain the block self-attention intermediate operation matrix B2 of the mask. The calculation method is shown in equations (5) and (6).

[0098] Step 33 involves adding the global self-attention intermediate operation matrix G2 of the mask and the block self-attention intermediate operation matrix B2 of the mask together and then performing a softmax operation to obtain the second attention distribution matrix S2. The calculation method is shown in equation (7).

[0099] Step 34: Perform a dot product operation between the second attention distribution matrix S2 and the second value matrix V2 to obtain the spliced ​​power consumption feature vector P2 containing self-attention representation, and optimize the spliced ​​power consumption feature vector P2 containing self-attention representation using a normalization layer and a residual layer.

[0100] Steps 31 to 34 are executed by the global block self-attention module of the mask of the second feature unit of the device.

[0101] Step 40 applies attention mechanism processing to the actual electricity consumption feature vector P1 containing self-attention representation and the concatenated electricity consumption feature vector P2 containing self-attention representation to obtain the expected electricity consumption feature vector P3 containing attention representation. Step 40 specifically includes the following sub-steps.

[0102] Step 41: The optimized actual electricity consumption feature vector P1 containing self-attention representation is compared with the weight matrix W of the attention mechanism. K3 W V3 Perform a dot product operation to obtain the third key matrix K3 and the third value matrix V3; then combine the optimized concatenated electricity consumption feature vector P2 containing self-attention representation with the attention mechanism weight matrix W. Q3 Perform a dot product operation to obtain the third query matrix Q3.

[0103] Step 42: Perform a dot product operation on the third query matrix Q3 and the third key matrix K3 to obtain the relevance matrix α; perform a soft-max operation on the relevance matrix α to obtain the relevance score matrix S3.

[0104] Step 43 involves performing a dot product operation between the correlation score matrix S3 and the third value matrix V3 to obtain the expected electricity consumption feature vector P3 with attention representation, and then optimizing the expected electricity consumption feature vector P3 with attention representation using a normalization layer and a residual layer.

[0105] Steps 41 to 43 are performed by the attention module of the third feature unit of the device.

[0106] Step 50 uses a fully connected network and a convolutional network to process the expected power consumption feature vector P3 containing attention representation, extracts the features of the expected power consumption, and obtains the expected power consumption.

[0107] To obtain a weather-adjusted predictive model for enterprise electricity consumption for engineering applications, it is necessary to train, validate, and test the initial model. A training dataset needs to be established before training, validating, and testing the initial model.

[0108] The training dataset was obtained in the following way:

[0109] (1) Obtain historical daily actual electricity consumption data, which includes daily actual electricity consumption and daily weather information;

[0110] (2) Based on the daily weather information, the daily actual electricity consumption is divided into daily electricity consumption affected by the weather and daily ideal electricity consumption unaffected by the weather. The daily ideal electricity consumption is used to preset the daily expected electricity consumption for the daily actual electricity consumption, so as to obtain the mapping of (daily actual electricity consumption, daily expected electricity consumption).

[0111] The expected electricity consumption is the ideal daily electricity consumption that is unaffected by weather, and is similar to the daily operating status and working hours of the enterprise.

[0112] (3) Combine the mapping of (actual daily electricity consumption, expected daily electricity consumption) and the weather information of the day into a single set of data, construct a dataset from all the historically acquired single sets of data, and divide the dataset into a training set, a validation set, and a test set, wherein the ratio of the training set, the validation set, and the test set is 8:1:1.

[0113] (I) Training Model

[0114] SA1 randomly selects a single set of data from the training set and inputs it into the initial model. In the encoding unit, the data is processed by a global block self-attention layer and then by a forward propagation layer to obtain the error. In the decoding unit, the data is processed by a masked global block self-attention layer and an attention layer, and then by a forward propagation layer to obtain the error. In the output unit, an approximate expected power consumption is output. The weight matrix W of the global block self-attention mechanism used in the initial model is... Q1 W K1 W V1 The weight matrix W of the masked global block self-attention mechanism Q2 W K2 W V2 The weight matrix W of the attention mechanism Q3 W K3 W V3 The parameters of other networks are initialized using the Kaiming distribution;

[0115] SA2 calculates the loss value between the approximate expected electricity consumption and the expected daily labor electricity consumption, and then uses gradient descent and backpropagation algorithms to adjust the weight matrix W of the global block self-attention mechanism in the initial model. Q1 W K1 W V1 The weight matrix W of the masked global block self-attention mechanism Q2 W K2 W V2The weight matrix W of the attention mechanism Q3 W K3 W V3 And correct, update and optimize the parameters of other networks;

[0116] SA3 repeats SA1 and SA2 until the loss value stabilizes or the training reaches the maximum number of iterations, then saves the model.

[0117] (II) Verification and testing of the model

[0118] SC1 trains multiple models using the same training methods as SA1 to SA3, resulting in multiple well-trained models.

[0119] SC2 sets the same hyperparameters for all trained models, runs the models on the data in the validation set, and selects the model with the smallest loss as the optimal model.

[0120] SC3 sets different hyperparameters for the optimal model, runs the optimal model with data from the test set, and selects the hyperparameters of the model with the smallest error as the optimal hyperparameters.

[0121] SC4 saves the optimal model and its corresponding optimal hyperparameters, runs the optimal model on the data in the test set, and evaluates the optimal model.

[0122] Example 2

[0123] The predictive model for enterprise electricity consumption to eliminate the impact of weather provided in this embodiment is basically the same as that in Embodiment 1. The difference is that the actual electricity consumption data obtained also includes date information. Please refer to [link / reference]. Figure 5 .

[0124] Specifically, the differences are as follows:

[0125] Step 11' converts the input actual electricity consumption data into vectors, resulting in an actual electricity consumption vector, a weather factor vector, and a date vector.

[0126] Specifically, the input actual electricity consumption data includes actual electricity consumption, weather information, and date information. The weather information includes weather category and temperature data. The weather category includes sunny, cloudy, rainy, snowy, foggy, etc. The temperature data includes the highest temperature of the day, the lowest temperature of the day, and the current temperature at the time of collection. The date information includes the day, week, month, year, and holiday period.

[0127] The actual electricity consumption is encoded, standardized, and subjected to one-dimensional convolution to obtain the actual electricity consumption vector. The weather category and temperature data are encoded, normalized, and subjected to one-dimensional convolution to obtain weather category vectors and temperature vectors. These vectors are then concatenated to obtain the weather factor vector. The date information is encoded and fully connected to obtain a date vector.

[0128] The encoding calculation method for the temperature data is shown in equation (1.1), and the encoding calculation method for the date information is shown in equation (1.2):

[0129]

[0130]

[0131] In equation (1.1), T is the temperature data code. max It is the maximum temperature, T min It is the minimum temperature, T i The current temperature; (1.2) where D is the day code, D i W represents the week number, where W is the week code. i For which week, W Y M represents the week number for the whole year, and M represents the month code. i J represents the month number, and J represents the holiday code. i For which statutory holiday of the year, J Y This refers to the number of statutory holidays throughout the year.

[0132] Step 12' is the actual power consumption vector. Set the first position vector The actual power consumption vector The first position vector and the date vector Add them together and then combine them with the weather factor vector. By concatenating the data, we obtain a vector of actual electricity consumption containing weather characteristics and date.

[0133] Step 13' Set a vector with the actual power consumption A zero vector of the same dimension, and a second position vector is assigned to the zero vector. The all-zero vector and the second position vector and the date vector Add them together to get the placeholder vector. The actual electricity consumption vector containing weather characteristics With the placeholder vector By concatenating the data, a concatenated electricity consumption vector containing weather characteristics and date is obtained.

[0134] Step 21' converts the actual electricity consumption vector containing weather characteristics and date into a vector. The weight matrix W of the global block self-attention mechanism is respectively compared with the weight matrix W. Q1 W K1 W V1 Perform a dot product operation to obtain the first query matrix Q1, the first key matrix K1, and the first value matrix V1.

[0135] Step 22' calculates the global self-attention intermediate operation matrix G1 corresponding to the weather features and the block self-attention intermediate operation matrix B1 corresponding to the actual electricity consumption including the date using the first query matrix Q1 and the first key matrix K1.

[0136] Step 222' extracts the vector components corresponding to the actual electricity consumption with the date from the first query matrix Q1. Extract the vector component corresponding to the actual electricity consumption for the date from the first key matrix K1. right and The block self-attention mechanism is used for calculation to obtain the block self-attention intermediate operation matrix B1. The calculation method is shown in equations (5) and (6).

[0137] Step 31' concatenates the electricity consumption vector containing weather features and date. The weight matrix W of the global block self-attention mechanism of the mask Q2 W K2 W V2 Perform a dot product operation to obtain the second query matrix Q2, the second key matrix K2, and the second value matrix V2.

[0138] Step 32' calculates the global self-attention intermediate operation matrix G2 of the mask corresponding to the weather features and the block self-attention intermediate operation matrix B2 of the mask corresponding to the spliced ​​electricity consumption containing the date using the second query matrix Q2 and the second key matrix K2.

[0139] Step 322' extracts the vector components corresponding to the spliced ​​electricity consumption containing the date from the second query matrix Q2. Extract the vector components corresponding to the spliced ​​electricity consumption containing the date from the second key matrix K2. right and The block self-attention mechanism is used for calculation to obtain the mask block self-attention intermediate operation matrix B2. The calculation method is shown in equations (5) and (6).

[0140] In this embodiment, the content of the training dataset also differs:

[0141] (1) Obtain historical daily actual electricity consumption data, which includes daily actual electricity consumption, daily weather information and date information;

[0142] (2) Based on the daily weather information, the daily actual electricity consumption is divided into daily electricity consumption affected by the weather and daily ideal electricity consumption unaffected by the weather. The daily ideal electricity consumption is used to preset the daily expected electricity consumption for the daily actual electricity consumption, so as to obtain the mapping of (daily actual electricity consumption, daily expected electricity consumption).

[0143] The artificially expected electricity consumption is the ideal daily electricity consumption that is unaffected by weather and is similar to the daily operating status of the enterprise, the working hours, and the date information (day, week, month, and holiday). This artificially expected electricity consumption is closer to the expected electricity consumption.

[0144] (3) The mapping of (actual daily electricity consumption, expected daily electricity consumption), the weather information of the day and the date information are combined into a single set of data. All the single sets of data acquired in history are used to construct a dataset, and the dataset is divided into a training set, a validation set and a test set, wherein the ratio of the training set, the validation set and the test set is 8:1:1.

[0145] Based on the above-mentioned prediction model for enterprise electricity consumption to eliminate the impact of weather, the present invention also provides a prediction system for enterprise electricity consumption to eliminate the impact of weather. The prediction system includes a processor, a memory, and a computer program stored in the memory and executable by the processor. When the computer program is executed by the processor, it implements the steps of the prediction method for enterprise electricity consumption to eliminate the impact of weather.

[0146] Based on the above-mentioned prediction model for enterprise electricity consumption to eliminate the impact of weather, the present invention also provides a computer-readable storage medium: the computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, it implements the steps of the prediction method for enterprise electricity consumption to eliminate the impact of weather.

[0147] Test application analysis

[0148] Please see Figure 6 As shown in Table 1, the prediction method based on the global block self-attention mechanism of this invention was tested using a test set of a dataset containing date information. The prediction experiments of the LR algorithm and the LSTM algorithm based on logistic regression were compared. The details are shown in Table 1.

[0149] Table 1. Comparison of experimental results of the three methods on data from a certain enterprise.

[0150] LR 2.109 7.193 LSTM 0.867 1.902 Method of the present invention 0.801 1.441

[0151] Experimental results show that the proposed method has a smaller overall amplitude error, followed by LSTM, and then LR. In terms of shape, LR is the best during working hours, followed by the proposed method, and then LSTM. Since LR models the entire dataset, it cannot learn commuting times, and the prediction results for non-working hours are poor. Both LSTM and the proposed method can learn commuting times, but the proposed method is better than LSTM in terms of overall error.

[0152] Please see Figure 7 In practice, the daily power load data of a certain enterprise was tracked and predicted for three quarters. The blue line reflects the actual daily total electricity consumption of the enterprise, while the orange line represents the expected daily total electricity consumption obtained using the prediction method of this invention, unaffected by weather. The prediction method of this invention shows that during non-working periods, weather has almost no impact on the enterprise's total electricity consumption, and the actual and expected values ​​match, indicating high adaptability. During working periods, without significant changes in the enterprise's operating mode, the shape of the enterprise's electricity consumption curve changes very little. The increase in the amplitude of the electricity consumption curve indicates that weather has a significant impact on the enterprise's electricity consumption. This demonstrates that predicting the expected enterprise electricity consumption based on the enterprise's actual total electricity consumption data, while eliminating the influence of weather, can improve the correlation between enterprise electricity consumption and enterprise capacity, and facilitates the simplification of the model between enterprise electricity consumption and enterprise capacity.

[0153] This invention proposes an end-to-end approach, using a model built with a weather-impact embedding (WI) layer and a global block self-attention (GB) mechanism to predict the expected value of enterprise electricity consumption after weather impact is eliminated. The proposed method combines the advantages of segmented methods with low amplitude and shape errors, and intuitively obtains the expected enterprise electricity consumption data after weather impact is eliminated, greatly simplifying the model complexity of subsequent tasks.

[0154] The above-described embodiments are merely examples of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and the present invention is also intended to include these modifications and variations.

Claims

1. A method for predicting enterprise electricity consumption to eliminate the impact of weather, characterized in that, The method includes: Step 10: Convert the input actual electricity consumption data into a vector to obtain an actual electricity consumption vector and a weather factor vector. Perform vector concatenation on the actual electricity consumption vector and the weather factor vector to obtain an actual electricity consumption vector containing weather features and a concatenated electricity consumption vector containing weather features. Step 20: Process the actual electricity consumption vector containing weather features using a global block self-attention mechanism to obtain an actual electricity consumption feature vector containing self-attention representation; Step 30: Perform a masked global block self-attention mechanism on the spliced ​​electricity consumption vector containing weather features to obtain a spliced ​​electricity consumption feature vector containing self-attention representation; Step 40: Perform attention mechanism processing on the actual power consumption feature vector containing self-attention representation and the concatenated power consumption feature vector containing self-attention representation to obtain the expected power consumption feature vector containing attention representation; In step 50, the expected power consumption feature vector containing attention representation is processed by a fully connected network and a convolutional network to extract the features of the expected power consumption and obtain the expected power consumption. Step 20 includes: Step 21: Convert the actual electricity consumption vector containing weather characteristics... The weight matrices of the global block self-attention mechanism are respectively , , Perform the dot product operation to obtain the first query matrix. First key matrix and the first value matrix ; Step 22: Through the first query matrix First key matrix Calculate the global self-attention intermediate operation matrix corresponding to weather features. Block-shaped self-attention intermediate operation matrix corresponding to actual electricity consumption ; Step 23: The global self-attention intermediate operation matrix... and the block-shaped self-attention intermediate operation matrix The first attention distribution matrix is ​​obtained by adding the matrices together and then performing a softmax operation. ; Step 24: Convert the first attention distribution matrix With the first value matrix Perform a dot product operation to obtain the actual electricity consumption feature vector containing self-attention representation. The actual electricity consumption feature vector containing self-attention representation is processed using a normalization layer and a residual layer. Optimize; Step 30 includes: Step 31: The spliced ​​electricity consumption vector containing weather characteristics... The weight matrices of the global block self-attention mechanism of the mask are respectively , , Perform the dot product operation to obtain the second query matrix. Second bond matrix Second-value matrix ; Step 32: Through the second query matrix Second bond matrix Calculate the global self-attention intermediate operation matrix for the mask corresponding to weather features. Block-based self-attention intermediate operation matrix corresponding to the spliced ​​power consumption mask ; Step 33: The global self-attention intermediate operation matrix of the mask... and the block-shaped self-attention intermediate operation matrix of the mask The second attention distribution matrix is ​​obtained by adding the matrices together and then performing a softmax operation. ; Step 34: The second attention distribution matrix... With the second value matrix Performing a dot product operation yields a spliced ​​power consumption feature vector containing self-attention representation. The spliced ​​power consumption feature vector containing self-attention representation is processed using a normalization layer and a residual layer. Optimize.

2. The prediction method according to claim 1, characterized in that, The global self-attention intermediate operation matrix of the global block self-attention mechanism The calculation method is as follows: in, In the formula, Global self-attention intermediate operation matrix The Line number List, for The first Bit vector components for The first Bit vector components for Length, for The corresponding global self-attention mechanism range, This indicates the number of vector components that use the global self-attention mechanism; The intermediate running matrix of the global block self-attention mechanism The calculation method is as follows: in, In the formula, Block-shaped self-attention intermediate operation matrix The Line number List, for The first Bit vector components for The first Bit vector components for Length, for The corresponding range of block-based self-attention mechanisms, This indicates the side length of the block.

3. The prediction method according to claim 2, characterized in that, The attention distribution matrix of the global block self-attention mechanism Through the global self-attention intermediate operation matrix and the block-shaped self-attention intermediate running matrix The matrix is ​​obtained by adding the matrices and then performing a softmax operation on each row of the resulting matrix. Specifically: In the formula, This is the intermediate operation matrix for global self-attention. This is the intermediate operation matrix for block-based self-attention.

4. The prediction method according to claim 1, characterized in that, The weather factor vector is composed of a weather category code and a temperature code, wherein the temperature code is calculated as follows: In the formula, It's a temperature code. That is the maximum temperature. It is the minimum temperature. This is the current temperature.

5. The prediction method according to claim 1, characterized in that, The actual electricity consumption data also includes date information.

6. The prediction method according to claim 5, characterized in that, The date information includes the day, week, month, year, and holiday. The calculation methods for the day code, week code, month code, and holiday code are as follows: In the formula, Encode the sky it is in. It refers to the day of the week. Code for the current week For which week, The number of weeks in a year. Code the month in question. Which month is it? Code the holiday period. For which statutory holiday of the year, This refers to the number of statutory holidays throughout the year.

7. A forecasting device for the enterprise electricity consumption forecasting method for eliminating the impact of weather as described in claim 1, characterized in that, The prediction device includes: The input unit is used to convert the input actual electricity consumption data into a vector to obtain an actual electricity consumption vector and a weather factor vector. The actual electricity consumption vector and the weather factor vector are then concatenated to obtain an actual electricity consumption vector containing weather features and a concatenated electricity consumption vector containing weather features. The first feature extraction unit is used to process the actual electricity consumption vector containing weather features using a global block self-attention mechanism to obtain an actual electricity consumption feature vector containing self-attention representation. The second feature extraction unit is used to process the spliced ​​electricity consumption vector containing weather features using a masked global block self-attention mechanism to obtain a spliced ​​electricity consumption feature vector containing self-attention representation. The third feature extraction unit is used to perform attention mechanism processing on the actual power consumption feature vector containing self-attention representation and the concatenated power consumption feature vector containing self-attention representation to obtain the expected power consumption feature vector containing attention representation. The output unit is used to process the expected power consumption feature vector containing attention representation using a fully connected network and a convolutional network to extract the features of the expected power consumption and obtain the expected power consumption. Specifically, the first feature extraction unit is used for: The actual electricity consumption vector containing weather characteristics The weight matrices of the global block self-attention mechanism are respectively , , Perform the dot product operation to obtain the first query matrix. First key matrix and the first value matrix ; Through the first query matrix First key matrix Calculate the global self-attention intermediate operation matrix corresponding to weather features. Block-shaped self-attention intermediate operation matrix corresponding to actual electricity consumption ; The global self-attention intermediate operation matrix and the block-shaped self-attention intermediate operation matrix The first attention distribution matrix is ​​obtained by adding the matrices together and then performing a softmax operation. ; The first attention distribution matrix With the first value matrix Perform a dot product operation to obtain the actual electricity consumption feature vector containing self-attention representation. The actual electricity consumption feature vector containing self-attention representation is processed using a normalization layer and a residual layer. Optimize; The second feature extraction unit is specifically used for: The spliced ​​power consumption vector containing weather characteristics The weight matrices of the global block self-attention mechanism of the mask are respectively , , Perform the dot product operation to obtain the second query matrix. Second bond matrix Second-value matrix ; Through the second query matrix Second bond matrix Calculate the global self-attention intermediate operation matrix for the mask corresponding to weather features. Block-based self-attention intermediate operation matrix corresponding to the spliced ​​power consumption mask ; The global self-attention intermediate operation matrix of the mask and the block-shaped self-attention intermediate operation matrix of the mask The second attention distribution matrix is ​​obtained by adding the matrices together and then performing a softmax operation. ; The second attention distribution matrix With the second value matrix Performing a dot product operation yields a spliced ​​power consumption feature vector containing self-attention representation. The spliced ​​power consumption feature vector containing self-attention representation is processed using a normalization layer and a residual layer. Optimize.

8. A forecasting system for enterprise electricity consumption that eliminates the impact of weather, characterized in that, The prediction system includes a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, it implements the steps of the prediction method as described in any one of claims 1 to 6.