Electric charge abnormal data detection method and system, medium and equipment

By combining Affinity Propagation clustering and the isolation forest algorithm, an anomaly detection model was constructed to solve the problem of low accuracy in detecting abnormal electricity charges in complex electricity usage scenarios, and to achieve efficient identification and precise positioning of dynamic electricity usage behaviors.

CN120671007APending Publication Date: 2025-09-19GUANGDONG POWER GRID CO LTD CUSTOMER SERVICE CENT
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510801844.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-16
Publication Date
2025-09-19

Smart Images

  • Figure CN120671007A_ABST
    Figure CN120671007A_ABST
Patent Text Reader

Abstract

The invention discloses a method, a system, a medium and equipment for detecting abnormal data of electric charge, and belongs to the field of machine learning, and the method comprises the steps: collecting a historical power utilization data set of a user; based on a preset Affinity Propagation clustering algorithm, clustering division is carried out on the historical electricity consumption data set, and clustering clusters representing different electricity consumption behavior modes and clustering center parameters of the clustering clusters are obtained; recursively constructing an isolated tree for each cluster through a preset isolated forest algorithm, and obtaining a segmentation rule parameter of each isolated tree; integrating each clustering center parameter and a segmentation rule parameter of the isolated tree, and constructing an anomaly detection model; and detecting the current power consumption data according to the anomaly detection model, and outputting a detection result. Therefore, by implementing the method and the device, the problem of low abnormal electricity charge detection precision in a complex electricity consumption scene in the prior art can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of machine learning and relates to a method, system, medium and equipment for detecting abnormal electricity charge data. Background Art

[0002] As the power industry's digital transformation deepens, smart meters, IoT devices, and big data platforms are widely used in power grids, enabling real-time collection of massive amounts of user electricity usage data. This data, encompassing multiple dimensions such as voltage, current, power, and timestamps, reflects the complex dynamics of user electricity usage (such as seasonal fluctuations and regional variations), providing a data foundation for refined operations.

[0003] Current mainstream methods rely primarily on manually preset static rules (such as fixed electricity consumption thresholds) or simple statistical models (such as outlier detection based on mean and standard deviation). However, static rules cannot adapt to the dynamic changes in electricity consumption behavior of different user groups (for example, sudden increases in electricity consumption during holidays are misclassified as abnormal), and they rely heavily on manual experience to adjust. Simple statistical models have poor generalization capabilities for high-dimensional, nonlinear electricity consumption data, making it difficult to capture hidden abnormal patterns such as electricity theft or equipment failure. Therefore, there is an urgent need for an abnormal electricity bill detection technology that can improve detection accuracy and address the shortcomings of existing technologies for complex electricity usage scenarios. Summary of the Invention

[0004] The present application provides a method, system, medium and equipment for detecting abnormal electricity charge data, which can solve the problem of low accuracy in detecting abnormal electricity charges in complex electricity usage scenarios in the prior art.

[0005] To achieve the above objectives, in a first aspect, the present invention provides a method for detecting abnormal electricity charge data, comprising:

[0006] Collect users' historical electricity consumption data sets;

[0007] Based on a preset Affinity Propagation clustering algorithm, the historical electricity consumption dataset is clustered to obtain clusters representing different electricity consumption behavior patterns and their cluster center parameters;

[0008] The preset isolation forest algorithm is used to recursively construct an isolation tree for each cluster, and the segmentation rule parameters of each isolation tree are obtained;

[0009] Integrating the cluster center parameters and the segmentation rule parameters of the isolation tree to construct an anomaly detection model;

[0010] According to the anomaly detection model, the current electricity usage data is detected and the detection result is output.

[0011] Compared with the existing technology, the embodiments of the present application have the following beneficial effects: collecting historical electricity consumption data sets to provide a comprehensive data basis for model training and improve the generalization ability of anomaly detection; dividing electricity consumption behavior patterns based on the AP clustering algorithm to generate cluster clusters and cluster center parameters, and solving the problem of traditional solutions confusing different electricity consumption characteristics in complex environments through group difference modeling; independently constructing isolated trees for homogeneous cluster clusters through the isolation forest algorithm and forming segmentation rule parameters, and using local data characteristics to accurately locate single user anomalies (such as sudden increases in electricity consumption); integrating cluster centers and tree segmentation rules to construct a detection model, and detecting current data; the overall solution solves the problem of poor adaptability of traditional single models to dynamic electricity consumption behaviors (such as seasonal fluctuations and regional differences) through the fusion of AP clustering and isolation forests, and breaks through the accuracy bottleneck of static rules and simple statistical models in complex scenarios.

[0012] In some embodiments of the first aspect of the present application, collecting a user's historical electricity usage dataset includes:

[0013] Collect users' original historical electricity consumption data;

[0014] Preprocessing the original historical electricity consumption data to obtain historical electricity consumption data; wherein the preprocessing includes one or more combinations of the following: data cleaning, data deduplication, data standardization, data logic unification, and missing value filling;

[0015] Performing data mining on the historical electricity consumption data to obtain historical characteristic data;

[0016] The historical electricity usage data and the historical characteristic data are combined to obtain the historical electricity usage data set.

[0017] Compared with the existing technology, the above embodiment has the following beneficial effects: cleaning, deduplication, standardization, logical unification and missing value filling of the original historical electricity consumption data, eliminating noise and data contradictions, and improving data quality; extracting historical feature data through data mining, and enhancing the feature expression; merging historical electricity consumption data and feature data to form a comprehensive data set, and further enhancing the model's recognition sensitivity to hidden anomalies (such as the gradual change pattern of electricity theft) through feature complementarity.

[0018] In some embodiments of the first aspect of the present application, the performing data mining on the historical electricity usage data to obtain historical feature data includes:

[0019] Filtering and scaling the historical electricity consumption data, eliminating invalid data and standardizing the value range to obtain first data;

[0020] Extracting and classifying the first data to obtain original features;

[0021] Binarizing the continuous variables in the original features to obtain binary features;

[0022] Performing one-hot encoding or label encoding on the categorical data in the binary features to obtain encoded features;

[0023] A dimensionality reduction operation is performed on the coding features to obtain historical feature data.

[0024] Compared with the existing technology, the above embodiment has the following beneficial effects: screening and scaling to eliminate invalid data and standardize the numerical range to prevent outliers from interfering with the stability of model training; feature extraction and classification focus on key electricity consumption behavior indicators (such as peak-to-valley electricity consumption ratio) to improve feature discriminability; binary segmentation of continuous variables simplifies computational complexity; unique-hot encoding of categorical data eliminates semantic ambiguity and enhances the computability of discrete features; dimensionality reduction operations compress redundant dimensions and accelerate model inference efficiency.

[0025] In some embodiments of the first aspect of the present application, clustering the historical electricity consumption dataset based on a preset Affinity Propagation clustering algorithm to obtain clusters representing different electricity consumption behavior patterns and their cluster center parameters includes:

[0026] Calculating the similarity between each data sample in the historical electricity consumption data set and constructing a similarity matrix; wherein each diagonal element in the similarity matrix is ​​a preference parameter;

[0027] updating each of the preference parameters according to the average value of all off-diagonal element values ​​in the similarity matrix to obtain a first similarity matrix;

[0028] Initialize the attraction matrix and the attribution matrix, and iteratively update the attraction matrix and the attribution matrix according to the first similarity matrix until convergence, complete clustering, and output the parameters of each cluster center and the corresponding cluster cluster.

[0029] Compared with the prior art, the above embodiment has the following beneficial effects: when automatically setting the cluster center through the improved AffinityPropagation algorithm, the similarity between each pair of samples in the data set is first calculated to construct a similarity matrix to quantify the differences in electricity consumption samples; then, the diagonal elements (i.e., preference parameters) are set to the average value of all non-diagonal similarities, which automatically adapts and improves the adaptability of the cluster center to the distribution of electricity consumption data, replacing the empirical operation of manually presetting the preference; further, by setting the attraction matrix and the attribution matrix and iteratively updating the clustering results, automatic clustering division without a preset number of clusters is achieved, providing high-quality cluster clusters and center parameters for subsequent isolation forests.

[0030] In a second aspect, the present invention further provides a detection system for abnormal electricity charge data, comprising: a data acquisition module, a clustering module, a segmentation module, a model building module and a detection module;

[0031] Wherein, the data acquisition module is used to collect the user's historical electricity consumption data set;

[0032] The clustering module is used to cluster the historical electricity consumption dataset based on a preset Affinity Propagation clustering algorithm to obtain clusters representing different electricity consumption behavior patterns and their cluster center parameters;

[0033] The segmentation module is used to recursively construct an isolation tree for each cluster using a preset isolation forest algorithm to obtain segmentation rule parameters for each isolation tree;

[0034] The model building module is used to integrate the cluster center parameters and the segmentation rule parameters of the isolation tree to construct an anomaly detection model;

[0035] The detection module is used to detect the current power consumption data according to the abnormality detection model and output the detection result.

[0036] Compared with the prior art, the above embodiments of the present application have the following beneficial effects: collecting historical electricity consumption data sets to provide a comprehensive data basis for model training and improve the generalization ability of anomaly detection; dividing electricity consumption behavior patterns based on the AP clustering algorithm to generate cluster clusters and cluster center parameters, and solving the problem of traditional solutions confusing different electricity consumption characteristics in complex environments through group difference modeling; independently constructing isolated trees for homogeneous cluster clusters through the isolation forest algorithm and forming segmentation rule parameters, and using local data characteristics to accurately locate single user anomalies (such as sudden increases in electricity consumption); integrating cluster centers and tree segmentation rules to construct a detection model, and detecting the current data; the overall solution solves the problem of poor adaptability of traditional single models to dynamic electricity consumption behaviors (such as seasonal fluctuations and regional differences) through the fusion of AP clustering and isolation forests, and breaks through the accuracy bottleneck of static rules and simple statistical models in complex scenarios.

[0037] In some embodiments of the second aspect of the present application, the data acquisition module includes: a collection unit, a preprocessing unit, a data mining unit, and an integration unit;

[0038] Wherein, the collection unit is used to collect the user's original historical electricity consumption data;

[0039] The preprocessing unit is configured to preprocess the original historical electricity consumption data to obtain historical electricity consumption data; wherein the preprocessing includes one or more combinations of the following: data cleaning, data deduplication, data standardization, data logic unification, and missing value filling;

[0040] The data mining unit is used to perform data mining on the historical electricity consumption data to obtain historical feature data;

[0041] The integration unit is configured to merge the historical electricity usage data and the historical characteristic data to obtain the historical electricity usage data set.

[0042] Compared with the existing technology, the above embodiment has the following beneficial effects: cleaning, deduplication, standardization, logical unification and missing value filling of the original historical electricity consumption data, eliminating noise and data contradictions, and improving data quality; extracting historical feature data through data mining, and enhancing the feature expression; merging historical electricity consumption data and feature data to form a comprehensive data set, and further enhancing the model's recognition sensitivity to hidden anomalies (such as the gradual change pattern of electricity theft) through feature complementarity.

[0043] In some embodiments of the second aspect of the present application, the data mining unit includes: a screening subunit, a feature extraction subunit, a binary processing subunit, an encoding subunit, and a dimensionality reduction subunit;

[0044] The screening subunit is configured to screen and scale the historical electricity consumption data, remove invalid data, and standardize the value range to obtain first data;

[0045] The feature extraction subunit is used to extract and classify the first data to obtain original features;

[0046] The binary processing subunit is used to perform binary segmentation on the continuous variables in the original features to obtain binary features;

[0047] The encoding subunit is used to perform one-hot encoding or label encoding on the categorical data in the binary features to obtain encoding features;

[0048] The dimensionality reduction subunit is used to perform dimensionality reduction operations on the coding features to obtain historical feature data.

[0049] Compared with the existing technology, the above embodiment has the following beneficial effects: screening and scaling to eliminate invalid data and standardize the numerical range to prevent outliers from interfering with the stability of model training; feature extraction and classification focus on key electricity consumption behavior indicators (such as peak-to-valley electricity consumption ratio) to improve feature discriminability; binary segmentation of continuous variables simplifies computational complexity; unique-hot encoding of categorical data eliminates semantic ambiguity and enhances the computability of discrete features; dimensionality reduction operations compress redundant dimensions and accelerate model inference efficiency.

[0050] In some embodiments of the second aspect of the present application, the clustering module includes: a similarity calculation unit, a preference parameter updating unit, and an iteration unit;

[0051] The similarity calculation unit is used to calculate the similarity between each data sample in the historical electricity consumption data set and construct a similarity matrix; wherein each diagonal element in the similarity matrix is ​​a preference parameter;

[0052] The preference parameter updating unit is configured to update each preference parameter according to an average value of all off-diagonal element values ​​in the similarity matrix to obtain a first similarity matrix;

[0053] The iterative unit is used to initialize the attraction matrix and the attribution matrix, and iteratively update the attraction matrix and the attribution matrix according to the first similarity matrix until convergence, complete clustering, and output the parameters of each cluster center and the corresponding cluster cluster.

[0054] Compared with the prior art, the above embodiment has the following beneficial effects: when automatically setting the cluster center through the improved AffinityPropagation algorithm, the similarity between each pair of samples in the data set is first calculated to construct a similarity matrix to quantify the differences in electricity consumption samples; then, the diagonal elements (i.e., preference parameters) are set to the average value of all non-diagonal similarities, which automatically adapts and improves the adaptability of the cluster center to the distribution of electricity consumption data, replacing the empirical operation of manually presetting the preference; further, by setting the attraction matrix and the attribution matrix and iteratively updating the clustering results, automatic clustering division without a preset number of clusters is achieved, providing high-quality cluster clusters and center parameters for subsequent isolation forests.

[0055] In a third aspect, the present invention also provides a device for detecting abnormal electricity charge data, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is loaded into the processor, the device implements the steps of any one of the methods for detecting abnormal electricity charge data of the present invention.

[0056] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any one of the methods for detecting abnormal electricity charge data of the present invention are implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] Figure 1 : A flow chart of a method for detecting abnormal electricity charge data provided in some embodiments of the present invention.

[0058] Figure 2 : A structural diagram of a system for detecting abnormal electricity charge data provided in some embodiments of the present invention.

[0059] Figure 3 : A structural diagram of a device for detecting abnormal electricity charge data provided in some embodiments of the present invention.

[0060] Figure 4 : A schematic diagram of a data preprocessing process provided in some embodiments of the present invention.

[0061] Figure 5 : A schematic diagram of a data mining process provided in some embodiments of the present invention.

[0062] Figure 6 : A schematic diagram of a process for constructing a model provided in some embodiments of the present invention.

[0063] Figure 7 : A schematic diagram of a data detection process provided in some embodiments of the present invention. DETAILED DESCRIPTION

[0064] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0065] Example 1:

[0066] Please refer to Figure 1 To solve the problem of low accuracy in detecting abnormal electricity charges in complex electricity usage scenarios in the prior art, an embodiment of the present invention provides a method for detecting abnormal electricity charge data, including steps S1 to S5:

[0067] Step S1: Collect the user's historical electricity consumption data set.

[0068] Furthermore, the step S1 can be implemented by the following preferred implementation, including steps S11-S14, as follows:

[0069] S11: Collect the user's original historical electricity consumption data.

[0070] S12: Preprocessing the original historical electricity consumption data to obtain historical electricity consumption data; wherein the preprocessing includes one or more combinations of the following: data cleaning, data deduplication, data standardization, data logic unification, and missing value filling.

[0071] S13: Performing data mining on the historical electricity consumption data to obtain historical feature data.

[0072] S14: Merging the historical electricity usage data and the historical feature data to obtain the historical electricity usage data set.

[0073] In specific implementation, Figure 4The flowchart of a data preprocessing is shown. For data with coding errors or incorrect formats, corrections are made according to the correct coding and formatting rules, including correcting the date format, numerical type or coding specifications, and the corrected data replaces the original erroneous data. For data items that cannot be corrected, they are directly deleted to avoid affecting subsequent analysis.

[0074] Then, the entire data set is arranged and merged, all data items are arranged in a certain order, and by comparing each data item, duplicate data is screened and deleted to ensure the uniqueness and accuracy of the data set.

[0075] When processing data from different sources or of different types, to ensure the consistency of the data set, it is necessary to uniformly convert different types of fields in the data set into standard types. For electricity consumption or electricity bill data in different units, it is necessary to uniformly convert them into standard units and unify the data formats such as date, time, and value to ensure the uniformity of data specifications.

[0076] In addition, in the data, for discrete and continuous variables, the data range needs to be constrained, and the unified standards of data from different systems need to be clarified. Various types of electricity bill data from different sources need to be adjusted according to the same logic and establish unified calculation logic and logical rules.

[0077] Finally, for missing values ​​in the data, depending on the data type and characteristics, you can use the median to fill continuous data, use the mean to fill regular values, or use the k-nearest neighbor algorithm to fill missing data.

[0078] In this preferred embodiment, steps S11-S14 clean, deduplicate, standardize, logically unify, and fill in missing values ​​on the original historical electricity consumption data to eliminate noise and data inconsistencies and improve data quality; extract historical feature data through data mining to enhance feature expression; merge historical electricity consumption data and feature data to form a comprehensive data set, and further enhance the model's recognition sensitivity to hidden anomalies (such as the gradual change pattern of electricity theft) through feature complementarity.

[0079] Furthermore, the step S13 can be implemented by the following preferred implementation, including steps S131-S135, as follows:

[0080] S131: Filtering and scaling the historical electricity consumption data, eliminating invalid data and standardizing the value range to obtain first data;

[0081] S132: Extracting and classifying the first data to obtain original features;

[0082] S133: performing binary segmentation on the continuous variables in the original features to obtain binary features;

[0083] S134: Perform one-hot encoding or label encoding on the categorical data in the binary features to obtain encoding features;

[0084] S135: Performing a dimensionality reduction operation on the coding features to obtain historical feature data.

[0085] In specific implementation, Figure 5 The flowchart of a data mining process shown in FIG. 1 first cleans and filters the data set to identify and discard samples or data fields with a high proportion of abnormal missing data. The remaining data set is scaled according to a specific ratio, and normalization or standardization methods are used to adjust the extreme values ​​(maximum and minimum values) of the data to a preset range (such as between 0 and 1) to facilitate subsequent feature extraction.

[0086] Next, through data analysis, representative and important information features from different sources are extracted from the dataset. This includes simplifying the names of the extracted features, such as simplifying "user category" to "YHLB" and "electricity consumption" to "YDL." Next, the features are categorized and organized based on their nature and purpose, grouping features of the same category together.

[0087] After grouping, categorical features (such as "YHLB" and "YDL") are converted into binary form and binarized according to a specific threshold. For example, "YHLB" is encoded as "0" and "YDL" is encoded as "1"; for continuous features, they can be binarized by binning or threshold processing; for multi-category features, the one-hot encoding strategy is adopted to convert them into multiple binary features.

[0088] Finally, use linear methods such as principal component analysis (PCA) to reduce the dimensionality of the data, extract the most representative principal components, and reduce the dimension of the data; among them, if it is some more complex data structure, nonlinear dimensionality reduction methods can be used to simplify the data through nonlinear mapping to retain the main features and structural information of the data.

[0089] In this preferred embodiment, steps S131-S135 screen and scale to eliminate invalid data and standardize the numerical range to prevent outliers from interfering with the stability of model training; feature extraction and classification focus on key electricity consumption behavior indicators (such as peak-to-valley electricity consumption ratio) to improve feature discriminability; binary segmentation of continuous variables simplifies computational complexity; unique-hot encoding of categorical data eliminates semantic ambiguity and enhances the computability of discrete features; dimensionality reduction operations compress redundant dimensions and accelerate model inference efficiency.

[0090] Step S2: Based on a preset Affinity Propagation clustering algorithm, cluster the historical electricity consumption dataset to obtain clusters representing different electricity consumption behavior patterns and their cluster center parameters.

[0091] Furthermore, step S2 can be implemented by the following preferred implementation, including steps S21-S23, as follows:

[0092] S21: Calculate the similarity between each data sample in the historical electricity consumption data set and construct a similarity matrix; wherein each diagonal element in the similarity matrix is ​​a preference parameter;

[0093] S22: updating each preference parameter according to the average value of all off-diagonal element values ​​in the similarity matrix to obtain a first similarity matrix;

[0094] S23: Initialize the attraction matrix and the attribution matrix, and iteratively update the attraction matrix and the attribution matrix according to the first similarity matrix until convergence, complete clustering, and output the parameters of each cluster center and the corresponding cluster cluster.

[0095] In the specific implementation, the improved Affinity Propagation algorithm is used to automatically set the cluster center, calculate the similarity value between each pair of samples in the data set, and construct a similarity matrix, as follows:

[0096] For n electricity consumption data x, these data points form an n*n similarity matrix S, where each element S(i,j)=-||x i -x j || 2 Represents the data point x i with x j The similarity between them, and where S(i,j)∈(-∞,0].

[0097] In the similarity matrix, the element value on the diagonal is called the preference parameter. The algorithm uses the preference parameter to judge the cluster center. The calculation method is:

[0098]

[0099] Next, set the attraction matrix R(i,k) and the attribution matrix A(i,k), and the iteration method is as follows:

[0100]

[0101] Combining the attraction matrix and the affiliation matrix, the AP clustering algorithm is iterated to complete the clustering division of the data.

[0102] In this preferred embodiment, when steps S21-S23 automatically set the cluster center through the improved Affinity Propagation algorithm, the similarity between each pair of samples in the data set is first calculated to construct a similarity matrix to quantify the differences in electricity consumption samples; then, the diagonal elements (i.e., preference parameters) are set to the average of all non-diagonal similarities, which automatically adapts and improves the adaptability of the cluster center to the distribution of electricity consumption data, replacing the empirical operation of manually presetting the preference; further, by setting the attraction matrix and the attribution matrix and iteratively updating the clustering results, automatic clustering division without a preset number of clusters is achieved, providing high-quality cluster clusters and center parameters for subsequent isolation forests.

[0103] Step S3: recursively construct an isolation tree for each cluster using a preset isolation forest algorithm to obtain segmentation rule parameters for each isolation tree.

[0104] In specific implementation, Figure 6 The flowchart of a model construction is shown in FIG. 1 . After the clustering is completed, the data set is divided into multiple clusters, and each cluster contains several similar sample data.

[0105] Next, for each cluster, the sample set X={x1,x2,...,x m}, build an isolation tree, and recursively split X by randomly selecting an attribute value q and a split value p until the isolation tree reaches the height limit and the child node has only one data, as follows:

[0106] Randomly select a value within the selected feature range as the split value. Use this split value to divide the sample set into two parts, placing them in the left subtree and right subtree respectively; Repeat the iterative split according to the sample data assigned to the left subtree or right subtree of the isolated tree until each sample is fully isolated;

[0107] After constructing each isolation tree, the anomaly score is calculated based on the node path length, and the data points are sorted by the anomaly score to obtain the anomaly data. Here, the path length h(x) of sample x is the number of edges from the root node to the leaf node where sample x is located, which is equal to the path length of the failed query in the binary search tree, that is, c(n) = 2H(n-1)-(2(n-1) / n); where c(n) is the average value of h(x) for a given n. Next, the anomaly score of sample x is calculated as follows: Where E(h(x)) represents the average path length of sample x across all isolated trees. If the anomaly score is close to 1, the corresponding sample point is likely an outlier; if the anomaly score is much less than 0.5, it is likely normal data; and if the anomaly score is approximately 0.5, the sample is not significantly abnormal.

[0108] After segmentation and construction of isolated trees, the segmentation rule parameters of each isolated tree are extracted for subsequent model construction.

[0109] Step S4: Integrate the cluster center parameters and the segmentation rule parameters of the isolation tree to construct an anomaly detection model.

[0110] Step S5: Detect the current power consumption data according to the anomaly detection model and output the detection result.

[0111] In specific implementation, Figure 7 The following is a data detection process diagram. The current data collected in real time is processed through preprocessing and data mining according to the model training steps, and then input into the model for recognition. After the recognition results are output, a confusion matrix can be constructed by comparing the model's predictions with the true labels. The four elements in the confusion matrix include true positives (TP), false positives (FP), true negatives (TN), and false negatives (FN). The model's accuracy A is calculated as follows:

[0112]

[0113] Calculate the different thresholds and In two-dimensional space, the horizontal axis represents the false positive rate FPR, the vertical axis represents the true positive rate TPR, and the ROC curve is drawn to show the classification performance of the model at different thresholds;

[0114] Finally, the area under the ROC curve is calculated as the AUC value by numerical integration method, and the effect of the model is evaluated according to the AUC value: an AUC value of around 0.5 indicates that the model performance is equivalent to random guessing; the larger the AUC value, the better the detection effect of the model; the smaller the AUC value, the worse the detection effect of the model.

[0115] In summary, compared with the existing technology, the above embodiments of the present application have the following beneficial effects: collecting historical electricity consumption data sets to provide a comprehensive data basis for model training and improve the generalization ability of anomaly detection; dividing electricity consumption behavior patterns based on the AP clustering algorithm to generate cluster clusters and cluster center parameters, and solving the problem of traditional solutions confusing different electricity consumption characteristics in complex environments through group difference modeling; independently constructing isolated trees for homogeneous cluster clusters through the isolation forest algorithm and forming segmentation rule parameters, and using local data characteristics to accurately locate single user anomalies (such as sudden increases in electricity consumption); integrating cluster centers and tree segmentation rules to construct a detection model, and detecting the current data; the overall solution solves the problem of poor adaptability of traditional single models to dynamic electricity consumption behaviors (such as seasonal fluctuations and regional differences) through the fusion of AP clustering and isolation forests, and breaks through the accuracy bottleneck of static rules and simple statistical models in complex scenarios.

[0116] Example 2:

[0117] Please refer to Figure 2 Based on the same inventive concept, an embodiment of the present invention discloses a detection system for abnormal electricity charge data, comprising: a data acquisition module M1, a clustering module M2, a segmentation module M3, a model building module M4 and a detection module M5;

[0118] The data acquisition module M1 is used to collect the user's historical electricity consumption data set.

[0119] Furthermore, the data acquisition module M1 includes: a collection unit, a pre-processing unit, a data mining unit and an integration unit;

[0120] Wherein, the collection unit is used to collect the user's original historical electricity consumption data;

[0121] The preprocessing unit is configured to preprocess the original historical electricity consumption data to obtain historical electricity consumption data; wherein the preprocessing includes one or more combinations of the following: data cleaning, data deduplication, data standardization, data logic unification, and missing value filling;

[0122] The data mining unit is used to perform data mining on the historical electricity consumption data to obtain historical feature data;

[0123] The integration unit is configured to merge the historical electricity usage data and the historical characteristic data to obtain the historical electricity usage data set.

[0124] In this preferred embodiment, the original historical electricity consumption data is cleaned, deduplicated, standardized, logically unified, and missing value filled to eliminate noise and data contradictions and improve data quality; historical feature data is extracted through data mining to enhance feature expression; historical electricity consumption data and feature data are merged to form a comprehensive data set, and the model's recognition sensitivity to hidden anomalies (such as gradual patterns of electricity theft) is further enhanced through feature complementarity.

[0125] Furthermore, the data mining unit includes: a screening subunit, a feature extraction subunit, a binary processing subunit, an encoding subunit and a dimensionality reduction subunit;

[0126] The screening subunit is configured to screen and scale the historical electricity consumption data, remove invalid data, and standardize the value range to obtain first data;

[0127] The feature extraction subunit is used to extract and classify the first data to obtain original features;

[0128] The binary processing subunit is used to perform binary segmentation on the continuous variables in the original features to obtain binary features;

[0129] The encoding subunit is used to perform one-hot encoding or label encoding on the categorical data in the binary features to obtain encoding features;

[0130] The dimensionality reduction subunit is used to perform dimensionality reduction operations on the coding features to obtain historical feature data.

[0131] In this preferred embodiment, invalid data is filtered and scaled to eliminate and the numerical range is standardized to prevent outliers from interfering with the stability of model training; feature extraction and classification focus on key electricity consumption behavior indicators (such as peak-to-valley electricity consumption ratio) to improve feature discriminability; continuous variables are binarized to simplify computational complexity; categorical data is one-hot encoded to eliminate semantic ambiguity and enhance the computability of discrete features; dimensionality reduction operations compress redundant dimensions and accelerate model inference efficiency.

[0132] The clustering module M2 is used to cluster the historical electricity consumption data set based on a preset Affinity Propagation clustering algorithm to obtain clusters representing different electricity consumption behavior patterns and their cluster center parameters.

[0133] Furthermore, the clustering module M2 includes: a similarity calculation unit, a preference parameter updating unit and an iteration unit;

[0134] The similarity calculation unit is used to calculate the similarity between each data sample in the historical electricity consumption data set and construct a similarity matrix; wherein each diagonal element in the similarity matrix is ​​a preference parameter;

[0135] The preference parameter updating unit is configured to update each preference parameter according to an average value of all off-diagonal element values ​​in the similarity matrix to obtain a first similarity matrix;

[0136] The iterative unit is used to initialize the attraction matrix and the attribution matrix, and iteratively update the attraction matrix and the attribution matrix according to the first similarity matrix until convergence, complete clustering, and output the parameters of each cluster center and the corresponding cluster cluster.

[0137] In this preferred embodiment, when automatically setting the cluster center through the improved Affinity Propagation algorithm, the similarity between each pair of samples in the data set is first calculated to construct a similarity matrix to quantify the differences in electricity consumption samples; then, the diagonal elements (i.e., preference parameters) are set to the average of all non-diagonal similarities, which automatically adapts and improves the adaptability of the cluster center to the distribution of electricity consumption data, replacing the empirical operation of manually presetting the preference; further, by setting the attraction matrix and the attribution matrix and iteratively updating the clustering results, automatic clustering division without a preset number of clusters is achieved, providing high-quality cluster clusters and center parameters for subsequent isolation forests.

[0138] The segmentation module M3 is used to recursively construct an isolation tree for each cluster using a preset isolation forest algorithm to obtain segmentation rule parameters of each isolation tree.

[0139] The model building module M4 is used to integrate the cluster center parameters and the segmentation rule parameters of the isolation tree to build an anomaly detection model.

[0140] The detection module M5 is used to detect the current power consumption data according to the abnormality detection model and output the detection result.

[0141] In summary, compared with the existing technology, the embodiments of the present application have the following beneficial effects: collecting historical electricity consumption data sets to provide a comprehensive data basis for model training and improve the generalization ability of anomaly detection; dividing electricity consumption behavior patterns based on the AP clustering algorithm to generate cluster clusters and cluster center parameters, and solving the problem of traditional solutions confusing different electricity consumption characteristics in complex environments through group difference modeling; independently constructing isolated trees for homogeneous cluster clusters through the isolation forest algorithm and forming segmentation rule parameters, and using local data characteristics to accurately locate single user anomalies (such as sudden increases in electricity consumption); integrating cluster centers and tree segmentation rules to construct a detection model, and detecting the current data; the overall solution solves the problem of poor adaptability of traditional single models to dynamic electricity consumption behaviors (such as seasonal fluctuations and regional differences) through the fusion of AP clustering and isolation forests, and breaks through the accuracy bottleneck of static rules and simple statistical models in complex scenarios.

[0142] Example 3:

[0143] Figure 3 The structural diagram of a device for detecting abnormal electricity bill data in this application is presented. Figure 3 As shown, the device for detecting abnormal electricity charge data may include: a processor N1, a memory N2, a data interface N3 and a communication bus N4.

[0144] Among them: the processor N1, the memory N2, and the data interface N3 communicate with each other through the communication bus N4; the data interface N3 is used for data communication with other devices such as input devices or output devices; the processor N1 is used to execute the program N5, which can specifically execute the relevant steps in any of the above-mentioned embodiments of the method for detecting abnormal electricity charge data.

[0145] Specifically, the program N5 may include program code, which includes computer-executable instructions.

[0146] Processor N1 may be a central processing unit (CPU), an affinity propagation specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the device for detecting abnormal electricity charge data may be processors of the same type, such as one or more CPUs, or may be processors of different types, such as one or more CPUs and one or more ASICs.

[0147] The memory N2 is used to store the program N5. The memory N2 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0148] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system, or other device. In addition, the embodiments of the present application are not directed to any particular programming language.

[0149] Example 4:

[0150] An embodiment of the present invention also provides a computer-readable storage medium, which stores at least one executable instruction. When the executable instruction is executed on a device / system for detecting abnormal electricity charge data, the device / system for detecting abnormal electricity charge data executes a method for detecting abnormal electricity charge data in any of the above-mentioned method embodiments.

[0151] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. Similarly, in order to streamline the application and help understand one or more of the various inventive aspects, in the above description of the exemplary embodiments of the application, the various features of the embodiments of the application are sometimes grouped together into a single embodiment, figure, or description thereof. Wherein, the claims that follow the specific embodiment are hereby clearly incorporated into the specific embodiment, wherein each claim itself serves as a separate embodiment of the application.

[0152] Those skilled in the art will appreciate that the modules in the devices of the embodiments can be adaptively changed and installed in one or more devices different from the embodiments. The modules, units, or components in the embodiments can be combined into one module, unit, or component, and furthermore, they can be divided into multiple submodules, subunits, or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive.

Claims

1. A method for detecting abnormal electricity charge data, characterized in that: include: Collect users' historical electricity consumption data sets; Based on a preset Affinity Propagation clustering algorithm, the historical electricity consumption dataset is clustered to obtain clusters representing different electricity consumption behavior patterns and their cluster center parameters; The preset isolation forest algorithm is used to recursively construct an isolation tree for each cluster, and the segmentation rule parameters of each isolation tree are obtained; Integrating the cluster center parameters and the segmentation rule parameters of the isolation tree to construct an anomaly detection model; According to the anomaly detection model, the current electricity usage data is detected and the detection result is output.

2. The method for detecting abnormal electricity charge data according to claim 1, wherein: The collected user's historical electricity consumption data set includes: Collect users' original historical electricity consumption data; Preprocessing the original historical electricity consumption data to obtain historical electricity consumption data; wherein the preprocessing includes one or more combinations of the following: data cleaning, data deduplication, data standardization, data logic unification, and missing value filling; Performing data mining on the historical electricity consumption data to obtain historical characteristic data; The historical electricity usage data and the historical characteristic data are combined to obtain the historical electricity usage data set.

3. The method for detecting abnormal electricity charge data according to claim 2, wherein: The data mining of the historical electricity consumption data to obtain historical characteristic data includes: Filtering and scaling the historical electricity consumption data, eliminating invalid data and standardizing the value range to obtain first data; Extracting and classifying the first data to obtain original features; Binarizing the continuous variables in the original features to obtain binary features; Performing one-hot encoding or label encoding on the categorical data in the binary features to obtain encoded features; A dimensionality reduction operation is performed on the coding features to obtain historical feature data.

4. The method for detecting abnormal electricity charge data according to claim 1, wherein: The historical electricity consumption dataset is clustered based on the preset Affinity Propagation clustering algorithm to obtain clusters representing different electricity consumption behavior patterns and their cluster center parameters, including: Calculating the similarity between each data sample in the historical electricity consumption data set and constructing a similarity matrix; wherein each diagonal element in the similarity matrix is ​​a preference parameter; updating each of the preference parameters according to the average value of all off-diagonal element values ​​in the similarity matrix to obtain a first similarity matrix; Initialize the attraction matrix and the attribution matrix, and iteratively update the attraction matrix and the attribution matrix according to the first similarity matrix until convergence, complete clustering, and output the parameters of each cluster center and the corresponding cluster cluster.

5. A detection system for abnormal electricity charge data, characterized in that: include: Data acquisition module, clustering module, segmentation module, model building module and detection module; The data acquisition module is used to collect the user's historical electricity consumption data set; The clustering module is used to cluster the historical electricity consumption dataset based on a preset Affinity Propagation clustering algorithm to obtain clusters representing different electricity consumption behavior patterns and their cluster center parameters; The segmentation module is used to recursively construct an isolation tree for each cluster using a preset isolation forest algorithm to obtain segmentation rule parameters for each isolation tree; The model building module is used to integrate the cluster center parameters and the segmentation rule parameters of the isolation tree to construct an anomaly detection model; The detection module is used to detect the current power consumption data according to the abnormality detection model and output the detection result.

6. The system for detecting abnormal electricity charge data according to claim 5, wherein: The data acquisition module includes: a collection unit, a pre-processing unit, a data mining unit and an integration unit; Wherein, the collection unit is used to collect the user's original historical electricity consumption data; The preprocessing unit is configured to preprocess the original historical electricity consumption data to obtain historical electricity consumption data; wherein the preprocessing includes one or more combinations of the following: data cleaning, data deduplication, data standardization, data logic unification, and missing value filling; The data mining unit is used to perform data mining on the historical electricity consumption data to obtain historical feature data; The integration unit is configured to merge the historical electricity usage data and the historical characteristic data to obtain the historical electricity usage data set.

7. The system for detecting abnormal electricity charge data according to claim 6, wherein: The data mining unit includes: a screening subunit, a feature extraction subunit, a binary processing subunit, an encoding subunit and a dimension reduction subunit; The screening subunit is configured to screen and scale the historical electricity consumption data, remove invalid data, and standardize the value range to obtain first data; The feature extraction subunit is used to extract and classify the first data to obtain original features; The binary processing subunit is used to perform binary segmentation on the continuous variables in the original features to obtain binary features; The encoding subunit is used to perform one-hot encoding or label encoding on the categorical data in the binary features to obtain encoding features; The dimensionality reduction subunit is used to perform dimensionality reduction operations on the coding features to obtain historical feature data.

8. The system for detecting abnormal electricity charge data according to claim 5, wherein: The clustering module includes: a similarity calculation unit, a preference parameter updating unit and an iteration unit; The similarity calculation unit is used to calculate the similarity between each data sample in the historical electricity consumption data set and construct a similarity matrix; wherein each diagonal element in the similarity matrix is ​​a preference parameter; The preference parameter updating unit is configured to update each preference parameter according to an average value of all off-diagonal element values ​​in the similarity matrix to obtain a first similarity matrix; The iterative unit is used to initialize the attraction matrix and the attribution matrix, and iteratively update the attraction matrix and the attribution matrix according to the first similarity matrix until convergence, complete clustering, and output the parameters of each cluster center and the corresponding cluster cluster.

9. A device for detecting abnormal electricity charge data, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the computer program is loaded into a processor, the steps of the method for detecting abnormal electricity charge data according to any one of claims 1 to 4 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method for detecting abnormal electricity charge data according to any one of claims 1 to 4 are implemented.

Citation Information

Cited By

  • Hydroelectric energy consumption data monitoring method and system based on edge calculation

    CN120951019A

  • Hydropower energy consumption data monitoring method and system based on edge computing

    CN120951019B