A method for reconstructing and extracting electricity consumption behavior features based on XGBoost and CNN
By using XGBoost and CNN methods in the power system to reconstruct and extract user electricity usage behavior, the problem of difficulty in exploring user electricity usage laws is solved, and personalized services and grid service quality is improved.
Patent Information
- Application Number
- CN202111359833.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-17
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2041-11-17
AI Technical Summary
Traditional methods are difficult to effectively explore the electricity usage behavior patterns of different types of users, resulting in low operating efficiency of power equipment and impact on the economic and safe operation of the power system.
The power consumption behavior feature reconstruction and extraction method based on XGBoost and CNN is used to preprocess the influencing factor data and load data of different users, sort the feature importance, reconstruct the feature matrix and feature extraction, and identify the user's power consumption behavior pattern and provide personalized services.
It effectively improves the quality of power grid services, provides personalized services, improves the coupling between the feature extraction process and the physical background, enhances the interpretability of the extracted features, and supports high-accurate user electricity prediction models and real-time identification of power theft behavior.
Smart Images

Figure CN114065857B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data mining and power system operation analysis and planning, and in particular to a method for reconstructing and extracting power consumption behavior features based on XGBoost and CNN. Background Art
[0002] The power system has developed into a huge network that provides energy and power to countries around the world. Its function is to provide reliable, continuous and high-quality electricity to various users as economically as possible, so as to meet the requirements of various users at any time, that is, to meet the load requirements.
[0003] In recent years, with the development of the Internet of Things and the advancement of informatization, massive user data has been introduced, which contains rich internal laws and derivative information of user electricity consumption behavior. For different types of users, electricity consumption is related to multiple factors, and the relationship between the relevant factors affecting their electricity consumption and the load is generally different. If traditional methods are used to extract electricity consumption features for different users according to the same rules, it will lead to the inability to mine effective user electricity consumption patterns, reduce the operating efficiency of power equipment, and affect the economic and safe operation of the power system and the refined operation of the power service department. Summary of the invention
[0004] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a method for reconstructing and extracting electricity consumption behavior features based on XGBoost and CNN, identify user electricity consumption behavior patterns according to the electricity consumption characteristics and potential electricity consumption habits of different users, and mine the electricity consumption behavior characteristics of different types of users, so as to provide users with personalized services and effectively improve the quality of power grid services.
[0005] The object of the present invention is to achieve the following technical solution: a method for reconstructing and extracting electricity consumption behavior features based on XGBoost and CNN, comprising the following steps:
[0006] S1. For different target users, multiple influencing factor data and load data are collected respectively, and after data preprocessing, a data set for feature extraction is obtained; wherein the target users are different electricity consumption areas or different electricity consumption industries.
[0007] Preferably, the step S1 comprises:
[0008] S101. For different target users, select multiple influencing factors related to the target user's power consumption, collect the influencing factor data and load data of the target user as the original data of the target user;
[0009] S102. Use the CLOF algorithm to detect outliers on the original data, and replace the data of each dimension with the average value of the data of that dimension for the detected outliers.
[0010] S2: Use the XGBoost model to train each type of user data separately, give an importance score to each feature (i.e., influencing factor) during the training process, and rank the feature importance accordingly.
[0011] S3: Arrange all features of each type of user from high to low according to the calculated feature importance, and reconstruct multiple feature matrices.
[0012] S4. For each type of feature matrix obtained, CNN is used to extract features to obtain an extracted feature matrix.
[0013] S5. Find the time point when the concept drift occurs in each target user load curve, divide the time into multiple time periods, and repeat the above steps S2 to S4 in different time periods;
[0014] S6: Input the extracted feature matrix into the fully connected layer to predict the load of each region or industry. Use the K-means clustering algorithm to cluster the extracted features, and identify the electricity consumption behavior by classifying the electricity consumption data; after obtaining the user classification results, the cluster center is the normal electricity consumption pattern of this type of user;
[0015] A vector-based similarity algorithm is used to calculate the matching degree between the power consumption characteristics of the user to be detected and the cluster center of this type of user, that is, the Euclidean distance between the power consumption characteristics extracted from the user and the cluster center is calculated. If it is greater than the threshold, it can be judged as an electricity theft user.
[0016] The beneficial effects of the present invention are as follows: the electricity consumption behavior feature reconstruction and extraction method based on XGBoost and CNN of the present invention identifies the user's electricity consumption behavior pattern according to the electricity consumption characteristics and potential electricity consumption habits of different users, mines out the electricity consumption behavior characteristics of different types of users, provides personalized services for users, and effectively improves the service quality of the power grid. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a flow chart of the method of the present invention;
[0018] Figure 2 This is a schematic diagram of the principle of using the CLOF algorithm to detect outliers on raw data in an embodiment;
[0019] Figure 3 It is a characteristic matrix schematic diagram in the embodiment;
[0020] Figure 4 It is a schematic diagram for comparing the features extracted in the embodiment;
[0021] Figure 5 Schematic diagram of the principle of feature extraction using convolutional neural network. DETAILED DESCRIPTION
[0022] The technical solution of the present invention is further described in detail below in conjunction with the accompanying drawings, but the protection scope of the present invention is not limited to the following.
[0023] In order to mine the electricity consumption behavior characteristics of different types of users, the present invention designs a strategy for reconstructing and extracting electricity consumption behavior characteristics based on XGBoost and CNN, thereby overcoming the drawbacks of traditional feature extraction according to the same rules for different regions or industries, analyzing the factors affecting their electricity consumption for each type of user, and establishing different feature matrices for different users, thereby mining the electricity consumption characteristics and potential electricity consumption habits of different users to identify the user's electricity consumption behavior pattern. On the one hand, it can provide personalized services to users and improve the quality of power grid services. On the other hand, it is conducive to improving the coupling degree between the feature extraction process and the physical background of the research object and enhancing the interpretability of the extracted features. The features extracted based on the strategy of this article can provide a theoretical basis and data support for the establishment of a high-accuracy user electricity consumption prediction model, real-time identification of electricity theft, and other applications, and further ensure the safety and availability of the power system. Specifically, in order to make the purpose, features, and advantages of the invention more obvious and easy to understand, the scheme of the present invention will be further explained in combination with the embodiments of the present invention below:
[0024] like Figure 1 As shown, a method for reconstructing and extracting electricity consumption behavior features based on XGBoost and CNN includes the following steps:
[0025] Step S1: Collect multiple influencing factor data and load data from each region or industry respectively, and obtain a data set for feature extraction after data preprocessing such as outlier detection and replacement of abnormal values.
[0026] Step S101: selecting n influencing factors related to the power consumption of each region or industry respectively, collecting the influencing factor data and load data of the region or industry, and obtaining a data set;
[0027] Step S102: Use the CLOF algorithm to detect outliers on the original data. First, use the k-means clustering algorithm to cluster the original data set to obtain the centers (particles) of k classes, and then find the average distance from all points in the class to the particle. This average is recorded as the radius R. For all points in the class, if the distance from the point to the particle is greater than or equal to R, it is placed in the outlier candidate set. Use the LOF algorithm to calculate the outlier factor LOF for each point in the outlier candidate set, and determine whether the data point is an outlier by judging whether the LOF is close to 1. If the LOF is much larger than 1, it is considered to be an outlier, and if it is close to 1, it is considered to be a normal data point. The flowchart of the algorithm is shown below. Figure 2 As shown;
[0028] The calculation formula of the outlier factor is as follows:
[0029]
[0030] where ρ k (O) and ρ k (P) represents the local reachable density of O and P respectively. N k (p) is called the k-th distance neighborhood of object P, which means the set of objects whose distance to object P is less than or equal to the k-th distance. The k-th distance is the distance from the k-th point closest to the point to the point.
[0031]
[0032] Among them, d k (P, O) = max{d k (O), d(P, O)} represents the kth reachable distance from point P to point O with O as the center. That is, if object P is far away from object O, the reachable distance between the two is the actual distance between them, but if they are close enough, the actual distance is replaced by the kth distance of O.
[0033] For the detected outliers, the data of each dimension is replaced by the average value of the data of that dimension.
[0034] Step S2: Use the XGBoost model to train the data sets of each type of user separately. XGBoost is a tree boosting model based on ensemble learning. The idea is to continuously add different trees to the model, grow the tree model by feature splitting, and each tree fits the residual of the sum of the predictions of all previous trees.
[0035] During the training process, the total information gain brought by a feature (i.e., influencing factor) each time a node is split in all trees can be considered as the importance score of the feature, reflecting its correlation with the model output (i.e., load).
[0036] Each time you try to split an existing leaf node in the tree, you calculate the gain θ of the selected feature:
[0037]
[0038] Among them, the subscripts L and R represent the left subtree and the right subtree respectively. is the information score of the left subtree, is the information score of the right subtree, is the current unsplit information fraction; G=∑ i∈I g i , H = ∑ i∈I h i , g i is the first-order derivative of the prediction error with respect to the current model, hi is the second-order derivative of the prediction error with respect to the current model, I is the set of samples on each leaf; γ is the complexity cost introduced by adding a new leaf node.
[0039] When t trees are generated, for n features, the information gain of each feature when each tree node is split is accumulated, and the total information gain brought by the feature each time the node is split in all trees is obtained, that is, the importance score of the feature. That is, for the i-th feature, the total information gain is expressed as:
[0040]
[0041] Step S3: The n features {x1, x2, x3, ..., x n} According to the calculated feature importance from high to low, each feature is regarded as a row of the matrix, arranged from top to bottom, and c feature matrices are obtained. Figure 3 As shown. Among them, x1 is the most important feature, x2 is the second most important feature, ..., x n is the feature ranked nth in importance.
[0042] After the arrangement, the feature matrix concentrates all the important features in the upper part of the matrix, so that the weights when extracting features using the neural network are also concentrated in the upper part, and the features related to the load in the extracted feature matrix are also more concentrated, such as Figure 4 As shown, the left side is the feature matrix extracted from the arranged matrix, and the right side is the feature matrix extracted from the unarranged matrix, where the grayscale depth represents the degree of correlation between the feature and the load.
[0043] Step S4: In order to extract the most significant features in the feature matrix, the c-type feature matrices obtained are subjected to feature extraction using a convolutional neural network (CNN), and the extracted feature matrix is obtained;
[0044] For the obtained n*m matrix, first perform a two-dimensional convolution on it, and use k d*d convolution kernels to convolve it (i.e., dot multiplication operation) to obtain k l*s matrices. Then pass it through the maximum pooling layer to obtain k w*r matrices. After the convolution layer and pooling layer, the important information in the features is extracted, and the final matrix will be used as the input feature of the prediction model. The specific process is as follows Figure 5 shown.
[0045] Step S5: As time goes by, the potential distribution of load data will change dynamically, that is, concept drift will occur. For load curves with different distributions, the relationship between them and influencing factors will also change. Therefore, it is necessary to extract features before and after the concept drift occurs.
[0046] The PH (Page-Hinckley) method is a detection technique based on sequence analysis. This is a continuous analysis technique used to detect concept changes in signal processing. It can effectively detect concept changes in normal behavior of model establishment. This test involves two variables, the test variable m and the T The cumulative difference between the observed values so far and the mean is defined as follows:
[0047]
[0048] in δ is the tolerable variation. m T The minimum value of is defined as
[0049] M T =min(m t , t=1,...,T). PH detection m T and M T The difference between PH T =m T -M T , when this difference is higher than a threshold η, the mark is changed.
[0050] Use the PH method to find the time point when concept drift occurs in the load curve of each region or industry, divide the time into multiple time periods, and repeat the above feature reconstruction and extraction steps in different time periods.
[0051] Step S6: Input each extracted feature matrix into the fully connected layer to predict the load of each region or industry. Cluster the extracted features using the K-means clustering algorithm, and identify the power consumption behavior by classifying the power consumption data; after obtaining the user classification results, the cluster center is the normal power consumption pattern of this type of user;
[0052] A vector-based similarity algorithm is used to calculate the matching degree between the power consumption characteristics of the user to be detected and the cluster center of this type of user, that is, the Euclidean distance between the power consumption characteristics extracted from the user and the cluster center is calculated. If it is greater than the threshold, it can be judged as an electricity theft user.
[0053] Table 1 shows the load forecast results for 10 regions. By comparing the prediction error of features arranged in descending order of importance with the prediction error of features arranged in a staggered order of importance, it can be seen that 8 regions have lower MAPE values when arranged in descending order of importance, which illustrates the effectiveness of arranging highly correlated features together.
[0054] Table 1
[0055]
[0056] Through the above description, the present invention provides a strategy for reconstructing and extracting electricity consumption behavior features based on XGBoost and CNN. In order to make full use of the correlation between influencing factors and load, the present invention proposes to use the XGBoost model to train each region or industry data, obtain the feature importance ranking, and reconstruct the feature matrix using the feature importance. For each type of feature matrix obtained, a convolutional neural network is used to extract features and select the features with the greatest impact on the predicted object.
[0057] The invention adopts a power consumption behavior feature reconstruction and extraction strategy based on XGBoost and CNN to overcome the drawbacks of traditional feature extraction according to the same rules for different regions or industries. It analyzes the factors affecting the power consumption of each type of user and establishes different feature matrices for different users, thereby exploring the power consumption characteristics and potential power consumption habits of different users to identify the user's power consumption behavior pattern. On the one hand, it can provide personalized services for users and improve the quality of power grid services. On the other hand, it is conducive to improving the coupling degree between the feature extraction process and the physical background of the research object and enhancing the interpretability of the extracted features. The features extracted based on the strategy of this article can provide a theoretical basis and data support for the establishment of a high-accuracy user power consumption prediction model, real-time identification of power theft behavior and other applications, and further ensure the safety and availability of the power system.
[0058] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the modules described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0059] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for reconstructing and extracting electricity consumption behavior features based on XGBoost and CNN, characterized by: The following steps are involved: S1. For different target users, multiple influencing factor data and load data are collected respectively, and after data preprocessing, a data set for feature extraction is obtained; S2. Use the XGBoost model to train each user's data set, calculate the feature importance during the training process, and obtain the feature importance ranking; S3. Reconstruct the features of each target user in order of importance to obtain multiple feature matrices; S4. For each type of feature matrix obtained, use CNN to extract features and obtain an extracted feature matrix; S5. Find the time point when the concept drift occurs in each target user load curve, divide the time into multiple time periods, and repeat the above steps S2 to S4 in different time periods; S6. Based on the extracted features, the feature matrix is input into the fully connected layer to predict the power load, the power consumption data is classified through the clustering algorithm, the power consumption behavior is identified, and the power theft detection is performed by calculating the matching degree between the power consumption characteristics of the user to be detected and the cluster center of this type of user.
2. According to claim 1, a method for reconstructing and extracting electricity consumption behavior features based on XGBoost and CNN is characterized in that: The target users are different electricity consumption areas or different electricity consumption industries.
3. The method for reconstructing and extracting electricity consumption behavior features based on XGBoost and CNN according to claim 2, characterized in that: The step S1 comprises: S101. For different target users, select multiple influencing factors related to the target user's power consumption, collect the influencing factor data and load data of the target user as the original data of the target user; S102. Use the CLOF algorithm to detect outliers on the original data, and replace the data of each dimension with the average value of the data of that dimension for the detected outliers.
4. The method for reconstructing and extracting electricity consumption behavior features based on XGBoost and CNN according to claim 1, characterized in that: The step S2 comprises: The XGBoost model is used to train various types of user data separately, and the importance score of each feature is given during the training process, and the feature is the influencing factor.
5. The method for reconstructing and extracting electricity consumption behavior features based on XGBoost and CNN according to claim 1, characterized in that: The step S3 comprises: All features of each type of user are arranged from high to low according to the calculated feature importance, and multiple feature matrices are reconstructed.
6. The method for reconstructing and extracting electricity consumption behavior features based on XGBoost and CNN according to claim 2, characterized in that: In step S5, the PH method is used to find the time point at which the concept drift occurs in the load curve of each region or industry.
7. The method for reconstructing and extracting electricity consumption behavior features based on XGBoost and CNN according to claim 2, characterized in that: In step S6, the load of each region or industry is predicted by inputting the extracted feature matrix into the fully connected layer; The extracted features are clustered using the K-means clustering algorithm, and the electricity consumption behavior is identified by classifying the electricity consumption data. After obtaining the user classification results, the cluster center is the normal electricity consumption pattern of this type of user; A vector-based similarity algorithm is used to calculate the matching degree between the power consumption characteristics of the user to be detected and the cluster center of this type of user, that is, the Euclidean distance between the power consumption characteristics extracted from the user and the cluster center is calculated. If it is greater than the threshold, it can be judged as an electricity theft user.
Citation Information
Patent Citations
Intelligent power grid electric energy usage amount predication method
CN106295877A
industrial user short-term load prediction method based on morphological clustering and LightGBM
CN109766950A