Abnormal electricity utilization detection method and device
Through the smart meter collecting and processing of the historical load data of power users, building a set of power consumption behavior characteristics and optimizing the detection model, the problem of insufficient detection accuracy and generalization capabilities of existing algorithms in complex scenarios is solved, and more accurate abnormal electricity consumption detection is achieved.
Patent Information
- Application Number
- CN202510475224.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-16
- Publication Date
- 2025-08-01
AI Technical Summary
When faced with complex and changing power application scenarios, existing abnormal electricity detection algorithms have problems such as high data purity dependence and insufficient generalization ability, making it difficult to accurately detect abnormal electricity usage.
The historical load data of power users is collected through a smart meter, and after data preprocessing, a set of power consumption behavior characteristics is constructed, and combined with principal component analysis, feature importance evaluation and deep neural network optimization, an abnormal electricity consumption detection model is generated, and multiple evaluation indicators are calculated using recursive feature elimination algorithm and confusion matrix to improve detection accuracy.
It improves the accuracy of electricity usage behavior detection and the robustness of the model, can more accurately identify the categories of users' electricity usage behavior, meet the power system's needs for abnormal electricity usage detection, and ensures the stable operation of the power system.
Smart Images

Figure CN120408432A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power systems, and particularly to a method and device for detecting abnormal electricity consumption. Background Art
[0002] In the wave of the Internet of Things (IoT) and big data era, with the help of various information sensors, radio frequency identification (RFID) technology, global positioning system (GPS), infrared sensors, laser scanning devices, etc., it is possible to efficiently obtain IoT data widely existing in various production environments. These devices are based on different physical principles and communication protocols. For example, information sensors generate electrical signals according to changes in physical quantities, chemical quantities or biological quantities, RFID identifies targets through radio frequency signals and obtains relevant data, GPS uses satellite positioning to collect position information, etc., jointly constituting a huge IoT data acquisition system.
[0003] With the rapid construction and in-depth promotion of the ubiquitous power IoT, a large amount of terminal data continuously pours in, driving the explosive growth of power IoT data. At all stages of the power system, information is obtained through diverse devices, thus forming power IoT data. Taking the power consumption side as an example, smart meters have been widely popularized and applied. Based on advanced metering chips and communication modules, they can continuously collect and store various types of user-side data. These data provide an important basis for behavioral analysis on the user side. Among them, the power consumption acquisition data is the most typical power IoT data on the power consumption side, which is closely related to user electricity consumption behaviors and covers key electrical data such as load, current, and voltage.
[0004] However, there are certain limitations in the current data mining algorithms for detecting abnormal electricity consumption. On the one hand, most abnormal detection algorithms highly rely on the purity of data. In actual applications, due to various factors affecting electricity consumption data, such as differences in electricity consumption habits of different users, fluctuations in the grid operation state, and external environmental interference, the complexity is relatively high. This makes it difficult for existing algorithms to effectively process, greatly affecting the final detection effect of the model. On the other hand, most current abnormal electricity consumption detection algorithms are modeled for specific industries or specific data. When actually facing the electricity consumption behaviors of users with cross-industry hybrids, the generalization ability of the model is insufficient, and it is unable to accurately detect abnormal electricity consumption situations, making it difficult to meet the requirements of complex and changeable power application scenarios. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide a method and device for detecting abnormal electricity consumption to improve the accuracy of detecting abnormal electricity consumption.
[0006] To solve the above technical problem, the present invention provides a method for detecting abnormal electricity consumption, including:
[0007] Step S1, collect the historical load data of power users through smart meters and perform data preprocessing to obtain power load data;
[0008] Step S2, construct features for the power load data to obtain a set of electricity consumption behavior features, and perform electricity consumption behavior detection on the set of electricity consumption behavior features to obtain an electricity consumption behavior detection model;
[0009] Step S3, evaluate the feature importance degree of the electricity consumption behavior detection model, and classify the electricity consumption behavior of power users according to the feature importance degree to obtain a user classification result;
[0010] Step S4, perform hyperparameter optimization on the electricity consumption behavior detection model to obtain an abnormal electricity consumption detection model, and obtain an abnormal electricity consumption classification detection result based on the abnormal detection model and the user classification result.
[0011] Preferably, the specific steps of Step S2 for constructing features for the power load data to obtain a set of electricity consumption behavior features include:
[0012] Step S21, obtain power collection data according to the electricity consumption data collected by the smart meter, and construct data-driven electricity consumption behavior features according to the power collection data, where the power collection data includes voltage, current, active power, electric energy, power factor, phase angle, and electricity load;
[0013] Step S22, fuse the data-driven electricity consumption behavior features and the service-driven electricity consumption behavior features to obtain a set of electricity consumption behavior features, where the construction process of the set of electricity consumption behavior features includes data acquisition, data extraction, and feature construction.
[0014] Preferably, the specific steps of Step S2 for performing electricity consumption behavior detection on the set of electricity consumption behavior features to obtain an electricity consumption behavior detection model include:
[0015] Preset an electricity load sample set and perform centering processing on it;
[0016] Set a new coordinate system after projection transformation, convert it into a standard orthogonal basis to obtain the projection of the sample points in the new space, and determine the optimization objective by maximizing the variance;
[0017] Use the Lagrange multiplier method for the optimization objective to obtain the relationship between eigenvalues and eigenvectors;
[0018] Sort the obtained eigenvalues in descending order, determine the number of principal components according to the cumulative variance contribution rate, and calculate the variance contribution rate and the cumulative variance contribution rate;
[0019] Take the eigenvectors corresponding to the first several eigenvalues to form a coordinate system after dimensionality reduction, and use the dimensionality reduction result as the solution of the principal component analysis.
[0020] Preferably, step S3 specifically includes:
[0021] Using the feature importance of the maximum information coefficient and variance to evaluate the feature importance degree of the electricity consumption behavior detection model, where the evaluation method of the maximum information coefficient is:
[0022] Divide the random variable equally to obtain a grid, use the ratio of the grid to the dataset as the probability density, and obtain the mutual information through dynamic adjustment;
[0023] Normalize the obtained maximum mutual information, adjust the internal grid size, and use the internal maximum value as the maximum mutual information between two features;
[0024] Judge the correlation between two features according to the value of the maximum information coefficient. When the maximum information coefficient is 0, there is no correlation between the two features. When the maximum information coefficient is close to 1, there is a definite relationship between the two features.
[0025] Preferably, step S3 uses the peak density algorithm and determines the feature importance degree through three parameters: feature local density, feature distance, and feature importance index. The calculation process of each parameter is as follows:
[0026] The feature local density is used to describe whether a certain feature can describe the physical quantity of the feature, and its calculation method is:
[0027]
[0028] Among them, MIC i,j represents the maximum information coefficient between feature i and feature j, and j takes the i,j k with the largest MIC, and k is a hyperparameter;
[0029] The feature distance is used to describe the physical quantity of the distance between features, and its calculation method is:
[0030]
[0031] Among them, the smaller the maximum information coefficient, the farther the distance between the two features, indicating that the two features are less relevant;
[0032] The feature importance index is a physical quantity that considers the feature local density and the feature distance, and its calculation method is:
[0033]
[0034] Among them, represents the feature fluctuation degree.
[0035] Preferably, step S3 classifies the user's electricity consumption behavior according to the feature importance degree to obtain the user classification result, which specifically includes:
[0036] The features are selected using the recursive feature elimination algorithm, and the worst features are selected according to the importance degree of the features, and the electricity consumption behavior feature set is divided into the remaining feature set and the eliminated feature set;
[0037] In the electricity consumption behavior optimization strategy, the following physical quantities are calculated: the information entropy of the electricity consumption behavior features, the information entropy of the user categories, the joint information entropy of the electricity consumption behavior features and the user categories, and the amount of information of the user categories reflected in the electricity consumption behavior features; the correlation coefficient between the electricity consumption behavior features is calculated;
[0038] Based on the above calculation results, the value of the features reflecting the user categories and the value of the eliminated feature set reflecting the user categories are further calculated;
[0039] The iteration stop condition is set. When the iteration stop condition is not satisfied, the iteration continues, and finally the features in the remaining feature set are used as the finally retained features.
[0040] Preferably, in step S4, hyperparameter optimization is performed on the electricity consumption behavior detection model to obtain the abnormal electricity consumption detection model, which specifically includes:
[0041] The deep neural network is used as the base learner of the AdaBoost model, and its processing process is as follows:
[0042] Weights are set for each row of the electricity load data line. In the first round of iteration, the weights of each row of data are evenly distributed, and the initial weight of each row of data is set to the reciprocal of the data volume;
[0043] In the r-th round of iteration, the machine learning algorithm is used to learn the training set under the current weights, and multiple independent classifiers are generated. The weighted error rates of these classifiers under the current training data weights are calculated respectively, and the classifier with the smallest weighted error rate is retained as the DNN weak classifier finally trained in this round of iteration, and its weighted error rate and the corresponding electricity load are recorded;
[0044] The weight of the DNN weak classifier is generated according to its weighted error rate. This weight is negatively correlated with the weighted error rate. During the iteration process, the weights of the correctly classified data are adjusted so that the algorithm can fully learn each data to obtain different DNN weak classifiers;
[0045] After the iteration ends, the DNN weak classifiers are weighted linearly combined, and the sign is taken to generate the final strong classifier.
[0046] Preferably, after the abnormal electricity consumption detection model is generated, the confusion matrix is used to calculate multiple evaluation indicators to judge the classification performance of the model, which specifically includes:
[0047] The confusion matrix consists of true positives (TP), false positives (FP), true negatives (TN), and false negatives (FN). Among them, TP represents the number of samples whose true category is the target category and are predicted as the target category; FP represents the number of samples whose true category is non-target category and are predicted as non-target category; TN represents the number of samples whose true category is non-target category and are predicted as non-target category; FN represents the number of samples whose true category is the target category and are predicted as non-target category;
[0048] Based on the above elements, multiple evaluation metrics are calculated, including:
[0049] The accuracy rate for evaluating the performance of the classification model is obtained by dividing the number of correctly classified samples by the total number of samples;
[0050] The geometric mean index for evaluating the overall classification performance of the classifier on an imbalanced dataset is calculated through the recall rate (TPR) and the true negative rate (TNR);
[0051] The F1 score for measuring the precision of the binary classification model is obtained through the harmonic mean of the precision rate and the recall rate.
[0052] The present invention also provides an abnormal electricity consumption detection device, including:
[0053] A data preprocessing unit, configured to collect historical load data of power users through smart meters and perform data preprocessing to obtain power load data;
[0054] An electricity consumption behavior detection unit, which constructs features from the power load data to obtain an electricity consumption behavior feature set, and performs electricity consumption behavior detection on the electricity consumption behavior feature set to obtain an electricity consumption behavior detection model;
[0055] An electricity consumption behavior classification unit, which evaluates the importance degree of features of the electricity consumption behavior detection model, and classifies the electricity consumption behavior of power users according to the importance degree of features to obtain a user classification result;
[0056] An abnormal electricity consumption detection unit, which optimizes the hyperparameters of the electricity consumption behavior detection model to obtain an abnormal electricity consumption detection model, and obtains an abnormal electricity consumption classification detection result based on the abnormal detection model and the user classification result.
[0057] The present invention also provides an abnormal electricity consumption detection device, including:
[0058] One or more processors;
[0059] A memory;
[0060] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the abnormal power consumption detection method.
[0061] Implementing the present invention has the following beneficial effects: In the data processing stage, historical load data is collected by an intelligent meter and preprocessed, and a power consumption behavior feature set is constructed by combining principal component analysis, improving the accuracy of power consumption behavior detection and laying a solid foundation for subsequent analysis. In terms of feature importance evaluation and user classification, the maximum information coefficient and variance are used to evaluate feature importance, the peak density algorithm is used to define the degree of feature importance, and then the recursive feature elimination algorithm is used for feature selection, effectively improving the robustness and classification accuracy of model training and accurately identifying the categories of user power consumption behavior. In the model optimization stage, a deep neural network is used as the base learner of the AdaBoost model for hyperparameter optimization. By initializing sample weights, iterative learning, generating weak classifier weights, and combining strong classifiers, the model performance is improved. At the same time, multiple evaluation indicators are calculated using the confusion matrix to judge the model performance, making the abnormal power consumption detection more accurate and reliable, better meeting the power system's requirements for abnormal power consumption detection, and ensuring the stable operation of the power system. Brief Description of the Drawings
[0062] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0063] Figure 1 It is a schematic flowchart of an abnormal power consumption detection method according to Embodiment 1 of the present invention.
[0064] Figure 2 It is a specific schematic flowchart of constructing a power consumption behavior feature set by performing feature construction on the power load data in the embodiments of the present invention.
[0065] Figure 3 It is a schematic structural diagram of an abnormal power consumption detection device according to Embodiment 2 of the present invention. Detailed Embodiments
[0066] The following descriptions of the embodiments are with reference to the drawings, which are used to exemplify specific embodiments in which the present invention can be implemented.
[0067] Please refer to Figure 1 As shown, Embodiment 1 of the present invention provides an abnormal power consumption detection method, including:
[0068] Step S1: Collect historical load data of power users through smart meters and perform data preprocessing to obtain power load data;
[0069] Step S2: Construct features from the power load data to obtain a set of electricity consumption behavior features, and perform electricity consumption behavior detection on the set of electricity consumption behavior features to obtain an electricity consumption behavior detection model;
[0070] Step S3: Evaluate the feature importance degree of the electricity consumption behavior detection model, and classify the electricity consumption behaviors of power users according to the feature importance degree to obtain a user classification result;
[0071] Step S4: Optimize the hyperparameters of the electricity consumption behavior detection model to obtain an abnormal electricity consumption detection model, and obtain an abnormal electricity consumption classification detection result based on the abnormal detection model and the user classification result.
[0072] Specifically, in the embodiments of the present invention, compared with the electricity consumption behavior feature model constructed based on business statistical indicators widely used in the power industry, introducing data-driven electricity consumption behavior features can make up for the lack of description of data trends in the electricity consumption behavior features constructed based on business statistical indicators, and thus provide a richer basis for classifying users' electricity consumption behaviors. Power Internet of Things data is a typical type of time series data, which has time dimension characteristics such as continuity, periodicity, and trend lines. At the same time, electricity consumption behavior features have obvious time periodicity. Information related to electricity consumption behavior is contained in the Power Internet of Things data, especially the power IoT data on the power consumption side. The power consumption data collection data is data used to record users' electricity consumption conditions and is closely related to users' electricity consumption behaviors. The business features of electricity consumption behaviors are discrete numerical types. To fuse data-driven electricity consumption behavior features with business-driven electricity consumption behavior features, it is necessary to convert time series power consumption data collection data into discrete data. Continuous functions in time can convert continuous data into discrete data through sampling. The power consumption data collection data is processed using time-frequency conversion methods, and frequency domain data is used to describe time domain data.
[0073] It should be noted that features can be divided into relevant features and irrelevant features. The help of relevant features for classification effects is weaker than that of irrelevant features. The features describing users' electricity consumption behaviors are diverse. Business features are constructed based on business rules, and data features are directly extracted from the power IoT data representing electricity consumption behaviors. The degrees of relevance of the two types of features to electricity consumption behaviors are different, and there may be relevant features among each feature. Therefore, it is necessary to select the constructed features to achieve better classification effects.
[0074] In Step S1, the data preprocessing includes cleaning, missing value interpolation, outlier screening, and standardization processing of the historical load data.
[0075] For another example Figure 2As shown, step S2 constructs features for the power load data to obtain an electricity consumption behavior feature set, which specifically includes:
[0076] Step S21, obtain the power consumption data collected by the smart meter to get the power consumption data, and construct data-driven electricity consumption behavior features based on the power consumption data. Among them, the power consumption data includes voltage, current, active power, electric energy, power factor, phase angle, and power load;
[0077] Step S22, fuse the data-driven electricity consumption behavior features with the business-driven electricity consumption behavior features to obtain an electricity consumption behavior feature set. Among them, the construction process of the electricity consumption behavior feature set includes data acquisition, data extraction, and feature construction.
[0078] It should be noted that data acquisition is to obtain the power consumption data collected by the voltmeter, ammeter, and smart meter. Data extraction is to extract the power Internet of Things data of the relevant power department and the power consumption data in the power Internet of Things data. Feature construction uses the fast Fourier transform to generate frequency domain data to describe the trend and periodicity of time series data.
[0079] Furthermore, step S2 performs electricity consumption behavior detection on the electricity consumption behavior feature set to obtain an electricity consumption behavior detection model, including:
[0080] Preset the electricity load sample set X = {x1, x2,..., x m}, perform centering processing on the electricity load sample set to obtain ∑ i x i = 0;
[0081] The new coordinate system after projection transformation is W = {w1, w2,..., w m}, where w i is the eigenvector corresponding to the eigenvalue λ i , and convert it into a standard orthogonal basis ‖w i ‖2 = 1. Then the projection of the sample point x i in the new space is W T x i . To maximize the variance, it is expressed as Then the optimization objective is:
[0082] max w tr(W T XX T W)s.t.W T W = 1 (1)
[0083] Using the Lagrange multiplier method for formula (1) gives:
[0084] XX T W = λW (2)
[0085] The obtained eigenvalues are sorted by size. The number of principal components depends on the setting of the cumulative variance contribution rate. The number of principal components is determined to be P. The calculation formulas for the variance contribution rate and the cumulative variance contribution rate are:
[0086]
[0087]
[0088] Take the eigenvectors corresponding to the first P eigenvalues to form the coordinate system V after dimensionality reduction P =(v1,v2,...,v p ), which is the solution of principal component analysis, thereby improving the accuracy of electricity consumption behavior detection.
[0089] Step S3 specifically uses the maximum information coefficient and variance feature importance to evaluate the feature importance of the electricity usage behavior detection model, as described below:
[0090] The maximum information coefficient is a physical quantity used to characterize the degree of correlation between information. The maximum information coefficient is calculated by dividing the random variable into equal parts to form a grid, using the ratio of the grid to the data set as the probability density, and dynamically adjusting the mutual information. The calculation formula is:
[0091]
[0092] Here, X and Y represent two variables, p(·) represents probability, x and y represent features, and I(x,y) represents mutual information operation.
[0093] Normalize the maximum mutual information obtained, adjust the internal grid size, and the internal maximum value is the maximum mutual information between the two features. The calculation formula is:
[0094]
[0095] When MIC(X,Y)=0, there is no correlation between the two features; when MIC(X,Y) is close to 1, there is a definite relationship between the two features.
[0096] In the embodiment of the present invention, the peak density algorithm is used to define the feature importance degree, and three parameters are given: feature local density, feature distance, and feature importance index. The parameter calculation process is:
[0097] Feature local density: Feature local density is used to describe whether a feature can describe the physical quantity of the feature. Its calculation expression is:
[0098]
[0099] Among them, MIC i,jDenote the maximum information coefficient between feature i and feature j, where j takes MIC i,j The top k ones, where k is a hyperparameter; if the mean of the maximum information coefficients of features is larger, it indicates that the features are strongly correlated features;
[0100] Feature distance: Feature distance is a physical quantity used to describe the distance between features, and its calculation expression is:
[0101]
[0102] Among them, the smaller the maximum information coefficient, the farther the distance between the two features, indicating that the two features are less relevant;
[0103] Feature importance index: Feature importance index is a physical quantity used to consider the local density of features and feature distance, and the degree of data fluctuation is added to assist in calculating feature importance. Its calculation formula is:
[0104]
[0105] Among them, represents the degree of feature fluctuation.
[0106] It should be noted that in step S3, the user's electricity consumption behavior is classified according to the feature importance degree to obtain the user classification result, including:
[0107] The recursive feature elimination algorithm is used to select features. The worst features are selected according to the feature importance degree, and the set composed of the remaining features in the electricity consumption behavior feature set is the remaining feature set, which is represented by the set as:
[0108] Ω = A + Q (10)
[0109] Among them, Ω represents the electricity consumption behavior feature set, A represents the remaining feature set, and Q represents the eliminated feature set;
[0110] In the electricity consumption behavior optimization strategy, calculate the following physical quantities. The information entropy of electricity consumption behavior feature n is H(n), and p(n) is the probability density function of n. The calculation formula is:
[0111] H(n) = -∑ n p(n)log2p(n) (11)
[0112] The information entropy H(m) of user category m, where p(m) is the probability density function of m. The calculation formula is:
[0113] H(m) = -∑ m p(m)log2p(m) (12)
[0114] The joint information entropy H(n, m) of electricity consumption behavior feature n and user category m. The calculation formula is:
[0115] H(n,m) = -∫∫p(n,m)log2p(n,m)dndm (13)
[0116] The calculation formula for the amount of information I(n,m) of user category m reflected in the electricity consumption behavior feature n is:
[0117] I(n,m) = H(n) + H(m) - H(n,m) (14)
[0118] Among them, the correlation coefficient p(n,q) represents the degree of correlation between the electricity consumption behavior feature n and the electricity consumption behavior q. q is the electricity consumption behavior feature eliminated from the feature set Q. When Q does not contain any features, p(n,q) = 0. cov(n,q) is the covariance between feature n and feature q, and σ(n) and σ(q) are the standard deviations of feature n and feature q respectively. The calculation formula is:
[0119]
[0120] Among them, J(n) is the value of feature n reflecting user category m, and I(n,m) is the result after normalizing the mutual information of n and m. The calculation formula is:
[0121] J(n) = I(n,m)∏ q (1 - |p(n,q)|) (16)
[0122] Among them, J(Q) is the value of the elimination feature set Q reflecting user category m. The calculation formula is:
[0123] J(Q) = ∑ q J(q) (17)
[0124] The calculation formula for the iteration stop condition ψ is:
[0125]
[0126] Among them, T is a variable parameter. When ψ is less than or equal to T, T means that the removed feature has a lower effective information weight compared to the elimination feature set, and iteration needs to continue until ψ meets the iteration stop condition. The features in the final remaining feature set are the finally retained features, which improves the robustness and classification accuracy of model training.
[0127] Thus, in step S4, hyperparameter optimization of the electricity consumption behavior detection model to obtain an abnormal electricity consumption detection model includes:
[0128] Taking the deep neural network as the base learner of the AdaBoost model. The processing process of the AdaBoost model is:
[0129] Sample weight initialization: A weight value is set for each row of the electricity load data line. In the first round of iteration, the weight values evenly distributed among all rows of data are as follows:
[0130]
[0131] where w 1i represents the weight of the electricity load data in the i-th row in the first round of iteration. The weight value of each row of data is initialized to 1 / T, where T is the size of the data volume;
[0132] In the r-th round of iteration, use the machine learning algorithm to learn the training set under the current weight D r and generate an independent classifier y rk (x) for each data set. A total of j classifiers are generated:
[0133] y rk (x): X → {-1, 1}, k = 1, 2,..., j (20)
[0134] Calculate the weighted error rate e r of the j classifiers under the current training data weight D rk respectively. The weighted error rate represents the sum of the weight values of all misclassified training data:
[0135]
[0136] where w ri represents the weight of the electricity load data in the i-th row in the r-th round of iteration, and X i represents the i-th row data of the electricity load sequence matrix.
[0137] In this embodiment, retain a classifier with the smallest weighted error rate as the DNN weak classifier finally trained in this round of iteration, denoted as y r (x), record the weighted error rate e r of y r and the corresponding electricity load k r . The DNN weak classifier makes a judgment considering the corresponding electricity load in the ledger;
[0138] Generate the weight of the DNN weak classifier y r (x) as a r :
[0139]
[0140] where the weight of the DNN weak classifier is negatively correlated with its weighted error rate, that is, the higher the classification accuracy, the lower the weight; during the iteration process, the weight of the correctly classified data is reduced to the original e r / (1 - e r) times to enable the algorithm to fully learn each data to obtain different DNN weak classifiers;
[0141] After the iteration ends, the DNN weak classifiers are linearly combined with weights, and the sign is taken to generate the final strong classifier y(x):
[0142]
[0143] where R is the total number of iteration rounds, and the trained R DNN weak classifiers are combined into the final strong classifier through a certain strategy to improve the model performance.
[0144] Optionally, multiple evaluation metrics are calculated using the confusion matrix. The confusion matrix consists of four elements: true positive (TP), false positive (FP), true negative (TN), and false negative (FN). Among them, TP represents the number of samples whose true class is the target class and is predicted as the target class; FP represents the number of samples whose true class is non-target class and is predicted as non-target class; TN represents the number of samples whose true class is non-target class and is predicted as non-target class; FN represents the number of samples whose true class is the target class and is predicted as non-target class.
[0145] In this embodiment, the multiple evaluation metrics include accuracy, geometric mean index (G-mean), and F1-score (F1-Score) to judge the performance of the model classification;
[0146] Accuracy is an index used to evaluate the performance of a classification model, indicating the number of correctly classified samples divided by the total number of samples. The expression of accuracy is:
[0147]
[0148] G-mean is used to evaluate the performance of a classifier and can evaluate the overall classification performance of the classifier on an unbalanced dataset. The formula of G-mean is:
[0149]
[0150] where TPR is the recall rate, representing the proportion of the actual positive class samples in the samples predicted as positive by the classifier, describing the sensitivity of the classifier to positive class data; TNR is the true negative rate, representing the proportion of negative class samples in the actual negative class samples, describing the sensitivity of the classifier to negative class data;
[0151] F1-Score is a metric used to measure the precision of a binary classification model, taking into account both the precision and recall of the model. It can be regarded as a harmonic mean of the model's precision and recall. The formula of F1-Score is:
[0152]
[0153] Among them, Precious is the accuracy rate, which represents the proportion of correctly classified positive class samples among all samples classified as positive class.
[0154] It should be noted that the accuracy rate is an evaluation index in classification problems. However, when facing an imbalanced data set, there is a large deviation in the evaluation of the detection results by the accuracy rate. In order to effectively evaluate the performance in imbalanced and balanced data sets, a set of evaluation indexes based on the confusion matrix are used to more comprehensively evaluate the classification results. The confusion matrix is a situation analysis table that summarizes the prediction results of a classification model in machine learning. It summarizes the records in the data set in the form of a matrix according to two criteria: the true class and the class predicted by the classification model.
[0155] As Figure 3 shown, corresponding to the abnormal power consumption detection method described in the first embodiment of the present invention, the second embodiment of the present invention further provides an abnormal power consumption detection device, including:
[0156] A data preprocessing unit, configured to collect historical load data of power users through an intelligent electricity meter and perform data preprocessing to obtain power load data;
[0157] A power consumption behavior detection unit, configured to construct features of the power load data to obtain a power consumption behavior feature set, and perform power consumption behavior detection on the power consumption behavior feature set to obtain a power consumption behavior detection model;
[0158] A power consumption behavior classification unit, configured to evaluate the feature importance degree of the power consumption behavior detection model, and classify the power consumption behavior of power users according to the feature importance degree to obtain a user classification result;
[0159] A power consumption data anomaly detection unit, configured to optimize the hyperparameters of the power consumption behavior detection model to obtain an abnormal power consumption detection model, and obtain an abnormal power consumption classification detection result based on the abnormal detection model and the user classification result.
[0160] Corresponding to the abnormal power consumption detection method described in the first embodiment of the present invention, the third embodiment of the present invention further provides an abnormal power consumption detection device, including:
[0161] One or more processors;
[0162] A memory;
[0163] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the abnormal power consumption detection method described above.
[0164] Corresponding to the abnormal power consumption detection method described in the first embodiment of the present invention, the fourth embodiment of the present invention further provides a computer program product, including computer instructions, where the computer instructions instruct a computer device to perform operations corresponding to the abnormal power consumption detection method described in the first embodiment of the present invention.
[0165] Preferably, the processor may be a central processing unit (CPU), or may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor, or the processor may also be any conventional processor. The processor is the control center of the device, and connects various parts of the device through various interfaces and lines.
[0166] The memory mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function, etc., and the data storage area can store relevant data, etc. In addition, the memory may be a high-speed random access memory, or may also be a non-volatile memory, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., or the memory may also be other volatile solid-state storage devices.
[0167] It should be noted that the above device may include but is not limited to a processor and a memory, which can be understood by those skilled in the art.
[0168] For the working principle and process of this embodiment, please refer to the description of the first embodiment of the present invention, which will not be repeated here.
[0169] Compared with the prior art, the beneficial effects brought by the embodiments of the present invention are as follows. In the data processing stage, historical load data is collected by an intelligent electricity meter and preprocessed, and an electricity consumption behavior feature set is constructed by combining principal component analysis, which improves the accuracy of electricity consumption behavior detection and lays a solid foundation for subsequent analysis. In terms of feature importance evaluation and user classification, the maximum information coefficient and variance are used to evaluate the feature importance, the peak density algorithm is used to define the feature importance degree, and then the recursive feature elimination algorithm is used for feature selection, effectively improving the robustness and classification accuracy of model training and accurately identifying the electricity consumption behavior categories of users. In the model optimization stage, a deep neural network is used as the base learner of the AdaBoost model for hyperparameter optimization. By initializing sample weights, iterative learning, generating weak classifier weights and combining strong classifiers, the model performance is improved. At the same time, multiple evaluation indicators are calculated using the confusion matrix to judge the model performance, making the abnormal electricity consumption detection more accurate and reliable, better meeting the requirements of the power system for abnormal electricity consumption detection, and ensuring the stable operation of the power system.
[0170] The above-disclosed are only the preferred embodiments of the present invention. Of course, the scope of the rights of the present invention cannot be limited thereby. Therefore, equivalent changes made according to the claims of the present invention still fall within the scope covered by the present invention.
Claims
1. An abnormal power consumption detection method, characterized in that, Including: Step S1: Collect the historical load data of power users through a smart meter and perform data preprocessing to obtain power load data; Step S2: Construct features for the power load data to obtain an electricity consumption behavior feature set, and perform electricity consumption behavior detection on the electricity consumption behavior feature set to obtain an electricity consumption behavior detection model; Step S3: Evaluate the feature importance degree of the electricity consumption behavior detection model, and classify the electricity consumption behavior of power users according to the feature importance degree to obtain a user classification result; Step S4: Optimize the hyperparameters of the electricity consumption behavior detection model to obtain an abnormal electricity consumption detection model, and obtain an abnormal electricity consumption classification detection result based on the abnormal detection model and the user classification result.
2. The method according to claim 1, characterized in that, The specific process of step S2 for constructing features for the power load data to obtain an electricity consumption behavior feature set includes: Step S21: Obtain acquisition data according to the electricity consumption data collected by the smart meter, and construct data-driven electricity consumption behavior features based on the acquisition data. The acquisition data includes voltage, current, active power, electric energy, power factor, phase angle, and electricity load; Step S22: Fuse the data-driven electricity consumption behavior features with the service-driven electricity consumption behavior features to obtain an electricity consumption behavior feature set. The construction process of the electricity consumption behavior feature set includes data acquisition, data extraction, and feature construction.
3. The method according to claim 1, wherein The specific process of step S2 for performing electricity consumption behavior detection on the electricity consumption behavior feature set to obtain an electricity consumption behavior detection model includes: Preset an electricity load sample set and perform centering processing on it; Set a new coordinate system after projection transformation, convert it into a standard orthogonal basis to obtain the projection of the sample points in the new space, and determine the optimization objective by maximizing the variance; Use the Lagrange multiplier method for the optimization objective to obtain the relationship between eigenvalues and eigenvectors; Sort the obtained eigenvalues in descending order, determine the number of principal components according to the cumulative variance contribution rate, and calculate the variance contribution rate and the cumulative variance contribution rate; Take the eigenvectors corresponding to the first several eigenvalues to form a coordinate system after dimensionality reduction, and use the dimensionality reduction result as the solution of principal component analysis.
4. The method according to claim 1, wherein The specific process of step S3 includes: Use the maximum information coefficient and variance to evaluate the feature importance degree of the electricity consumption behavior detection model. The evaluation method of the maximum information coefficient is: Divide the random variables equally to obtain a grid, use the ratio of the grid to the data set as the probability density, and obtain the mutual information through dynamic adjustment; Perform normalization processing on the obtained maximum mutual information, adjust the internal grid size, and use the internal maximum value as the maximum mutual information between two features; Judge the correlation between two features according to the value of the maximum information coefficient. When the maximum information coefficient is 0, there is no correlation between the two features; when the maximum information coefficient is close to 1, there is a definite relationship between the two features.
5. The method according to claim 4, characterized in that Step S3 uses the peak density algorithm and determines the feature importance degree through three parameters: feature local density, feature distance, and feature importance index. The calculation process of each parameter is: The feature local density is used to describe whether a certain feature can describe the physical quantity of the feature. Its calculation method is: Among them, MIC i,j represents the maximum information coefficient between feature i and feature j, and j takes the i,j largest k ones, where k is a hyperparameter; The feature distance is a physical quantity used to describe the distance between features, and its calculation method is as follows: Among them, the smaller the maximum information coefficient, the farther the distance between the two features, indicating that the two features are less relevant; The feature importance index is a physical quantity used to consider the local density of features and the feature distance, and its calculation method is as follows: Among them, represents the degree of feature fluctuation.
6. The method according to claim 1, characterized in that, In step S3, the user's electricity consumption behavior is classified according to the feature importance degree to obtain the user classification result, which specifically includes: The recursive feature elimination algorithm is used to select features, and the worst features are selected according to the feature importance degree, and the electricity consumption behavior feature set is divided into the remaining feature set and the eliminated feature set; In the electricity consumption behavior optimization strategy, the following physical quantities are calculated: the information entropy of the electricity consumption behavior features, the information entropy of the user categories, the joint information entropy of the electricity consumption behavior features and the user categories, and the amount of information of the user categories reflected in the electricity consumption behavior features; calculate the correlation coefficient between the electricity consumption behavior features; Based on the above calculation results, further calculate the value of the features reflecting the user categories and the value of the eliminated feature set reflecting the user categories; Set the iteration stop condition. When the iteration stop condition is not met, continue the iteration, and finally use the features in the remaining feature set as the finally retained features.
7. The method according to claim 1, characterized in that In step S4, the hyperparameters of the electricity consumption behavior detection model are optimized to obtain the abnormal electricity consumption detection model, which specifically includes: The deep neural network is used as the base learner of the AdaBoost model, and its processing process is as follows: Weights are set for each row of electricity load data lines. In the first round of iteration, the weights of each row of data are evenly distributed, and the initial weight of each row of data is set to the reciprocal of the data volume; In the r-th round of iteration, the machine learning algorithm is used to learn the training set under the current weights, generate multiple independent classifiers, calculate the weighted error rates of these classifiers under the current training data weights respectively, and retain the classifier with the smallest weighted error rate as the DNN weak classifier finally trained in this round of iteration, and record its weighted error rate and the corresponding electricity load; Generate its weight according to the weighted error rate of the DNN weak classifier. This weight is negatively correlated with the weighted error rate. During the iteration process, adjust the weights of the correctly classified data so that the algorithm can fully learn each data to obtain different DNN weak classifiers; After the iteration ends, linearly combine the weighted DNN weak classifiers and take their signs to generate the final strong classifier.
8. The method according to claim 7, wherein After generating the abnormal electricity consumption detection model, a confusion matrix is used to calculate multiple evaluation indicators to judge the classification performance of the model, which specifically includes: The confusion matrix consists of true positives (TP), false positives (FP), true negatives (TN), and false negatives (FN). Among them, TP represents the number of samples whose true category is the target category and is predicted as the target category; FP represents the number of samples whose true category is the non-target category and is predicted as the non-target category; TN represents the number of samples whose true category is the non-target category and is predicted as the non-target category; FN represents the number of samples whose true category is the target category and is predicted as the non-target category; Based on the above elements, multiple evaluation indicators are calculated, including: The accuracy rate for evaluating the performance of the classification model is obtained by dividing the number of correctly classified samples by the total number of all samples; The geometric mean index for evaluating the overall classification performance of a classifier on an imbalanced dataset is calculated through the true positive rate (TPR) and the true negative rate (TNR). The F1 score for measuring the precision of a binary classification model is obtained through the harmonic mean of precision and recall.
9. An abnormal power consumption detection device, characterized in that, It includes: A data preprocessing unit, configured to collect historical load data of power users through smart meters and perform data preprocessing to obtain power load data. An electricity consumption behavior detection unit, configured to construct features from the power load data to obtain an electricity consumption behavior feature set, and perform electricity consumption behavior detection on the electricity consumption behavior feature set to obtain an electricity consumption behavior detection model. An electricity consumption behavior classification unit, configured to evaluate the feature importance degree of the electricity consumption behavior detection model, and classify the electricity consumption behavior of power users according to the feature importance degree to obtain a user classification result. An abnormal electricity consumption detection unit, configured to optimize the hyperparameters of the electricity consumption behavior detection model to obtain an abnormal electricity consumption detection model, and obtain an abnormal electricity consumption classification detection result based on the abnormal detection model and the user classification result.
10. An abnormal power consumption detection device, characterized in that, It includes: One or more processors; A memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the abnormal electricity consumption detection method according to any one of claims 1 to 9.