Electric energy meter fault classification method and system based on confrontation comparison
By adopting an adversarial comparison-based power meter fault classification method in smart meter fault detection, the target-nearest neighbor sample combination is constructed and feature extraction is used using neural networks. Combined with the generation of adversarial network balanced data sets, the defects of unbalanced data processing in the existing methods are solved, and higher classification accuracy and robustness are achieved.
Patent Information
- Application Number
- CN202411416014.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-11
- Publication Date
- 2025-03-04
AI Technical Summary
Existing smart meter fault detection methods can easily lead to overfitting and poor universality when processing unbalanced data. Data-level methods may cause information loss and noise introduction, making it difficult to effectively mine differential information between different categories of samples.
Adopting an adversarial comparison-based fault classification method, the target-nearest neighbor sample combination set is constructed by determining the weight calculation strategy of the sample close to the overlapping area of the data, and a neural network is used to perform feature extraction and category matching determination. At the same time, based on the generation of adversarial network balanced data sets, the neural network binary classifier is trained, and the prediction results of the two methods are integrated.
It improves attention to a few types of samples in the data overlap area, fully explores the relationship information between sample neighborhoods, improves the accuracy and robustness of classification tasks, and reduces the risk of overfitting.
Smart Images

Figure CN119557756A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electric energy metering, and more specifically, to an electric energy meter fault classification method and system based on confrontation comparison. Background Art
[0002] The demand for smart meters is increasing as my country's power grid transformation continues to advance. The types of smart meter failures are diverse and complex, and the reasons include internal factors of the meter itself and external factors of the environment in which it is located. Different smart meter manufacturers use different design schemes, process flows, and choose different basic components when producing smart meters, so there are many types of smart meters themselves, and the types of failures that are prone to occur are also different; coupled with the large differences in the external operating conditions of smart meters such as the geographical environment and climate in different regions of my country, the diversity and complexity of smart meter failure types are further increased. In addition, the current power grid system maintenance mainly relies on operation and maintenance personnel. Due to the complexity of smart meter failure types, it is difficult to quickly and accurately determine the fault type based on the experience of operation and maintenance personnel alone, which may lead to inaccurate and untimely handling of faults, and even lead to unreasonable maintenance plans, and sometimes lead to unnecessary meter replacement, resulting in increased operation and maintenance costs.
[0003] With the rapid development of computer technology and the advent of the big data era, the processing power and hardware performance of computers have been significantly improved. The vigorous development of artificial intelligence has provided strong technical support for extracting useful information from the surging amount of data in smart meters. In recent years, deep learning has become a major focus in the field of artificial intelligence and has made breakthrough progress in many tasks. The fault classification of smart meters is essentially an unbalanced classification problem, and the frequency of occurrence of different fault types in actual use is also different. The fault data as a whole presents the characteristics of multi-modal distribution, which further increases the difficulty of correctly predicting various types of faults in smart meters. If the above data is not processed and directly learned based on traditional machine learning methods, the classifier will often be biased towards the majority class during the learning process due to the uneven number of samples, which will make it difficult for the model to correctly identify the minority class, seriously reducing the generalization ability of the model.
[0004] At present, there are two main methods for dealing with such problems, namely the algorithm level and the data level. The algorithm level method directly improves the classification algorithm to make it applicable to the original data set to avoid the negative impact of the class imbalance problem, but these methods usually do not take into account the problem of classifier performance degradation and are often subject to specific problems, lacking good transferability and versatility. The data level methods are mainly divided into sampling-based sample synthesis methods and deep learning-based sample generation methods. By increasing the number of minority class samples or reducing the number of majority class samples, the imbalance of the data set is reduced, thereby reducing the impact of data imbalance on the classification model. However, the sampling method does not learn the characteristics of the data itself, and the quality of the generated samples cannot be guaranteed. Although the generation method mines the feature information of the data itself based on the deep model, when the number of samples is limited, the sample size is difficult to support the huge training parameters of the deep network, and the difference information between samples is not fully mined. At the same time, the overlap of features between samples of different classes further increases the difficulty of the model to learn the features, which greatly affects the performance of the classifier. Summary of the invention
[0005] According to the present invention, a method and system for classifying electric energy meter faults based on adversarial comparison are provided to solve the technical problems existing in the current fault detection methods of smart electric energy meters. The technical problems are that in the existing methods for processing unbalanced data, the algorithm-level methods are prone to overfitting and have poor universality; the undersampling methods at the data level will cause information loss, and the oversampling and generation methods cannot reliably guarantee the authenticity of the constructed new samples, which will lead to the introduction of noise, and it is difficult to mine the difference information between samples of different categories after balancing the data set.
[0006] According to a first aspect of the present invention, there is provided a method for classifying electric energy meter faults based on confrontation comparison, comprising:
[0007] Determine a weight calculation strategy that describes the degree to which a sample is close to a data overlap region, adjust the number of target-nearest neighbor sample combinations according to the weight calculation strategy, and construct a target-nearest neighbor sample combination set;
[0008] Build a neural network, extract features from the constructed target-neighbor sample combination, compare the target sample with the neighbor sample in the target-neighbor sample combination, determine the degree of category matching, and obtain the label prediction probability of the target sample for the first time;
[0009] Based on the generation of an adversarial network to balance the number of minority class samples and majority class samples of the target-neighbor sample combination set, a balanced data set is determined, a neural network binary classifier is trained based on the balanced data set, label prediction is performed on the test set data, and the label prediction probability of the target sample is obtained for the second time through the neural network binary classifier;
[0010] The label prediction probabilities of the target samples obtained twice are integrated proportionally to obtain the label prediction results of the sample to be tested;
[0011] Based on the label prediction results of the samples to be tested, the smart meter fault samples are classified.
[0012] Optionally, determining a weight calculation strategy that describes the degree to which a sample is close to a data overlap region, adjusting the number of target-nearest neighbor sample combinations according to the weight calculation strategy, and constructing a target-nearest neighbor sample combination set, including:
[0013] Randomly sample N times in the neighbor pool M of the target sample, sampling K (K≤M) samples each time, to obtain N target-neighbor sample combinations;
[0014] If the dimension of the original sample is d, then the data dimension of each target-neighbor combination is determined to be ((1+K), d), and the dimension of its label is (1+K), where the first dimension is the true label label of the target sample target The remaining K dimensions are the reconstructed comparison labels of the sampled neighbors and whether they are of the same type. compare ;
[0015] Assume that there are a samples in the minority class sample set X and b samples in the majority class sample set Y. Calculate the inverse of the average Euclidean distance between each minority class sample and all majority class samples as its weight. The calculation process is as follows:
[0016]
[0017] Among them, x i and i Represent the minority class samples and the majority class samples respectively, D i Represents x i The average Euclidean distance to all majority class samples, D i The reciprocal of f i That is the weight of each minority sample.
[0018] Optionally, a neural network is constructed to extract features from the constructed target-neighbor sample combination, including:
[0019] Build a neural network to reconstruct and compare the labels of the K nearest neighbors of the target sample compare To make a prediction, the loss function of the neural network is defined as follows:
[0020]
[0021] Where m represents the batch size, pred represents the predicted label of the network output, label compareRepresents the reconstruction comparison label. By optimizing the loss function, the neural network has the ability to predict the similarities and differences between the neighboring samples and the target samples.
[0022] Optionally, the target sample and the neighbor sample in the target-neighbor sample combination are compared to determine the degree of category matching, and the label prediction probability of the target sample is obtained for the first time, including:
[0023] The target sample to be tested is compared with K neighboring samples respectively, and the matching degree between the target sample to be tested and each neighboring sample is predicted. The n groups of matching degrees are integrated and divided according to the threshold to obtain the predicted category label of the target sample. Taking the test sample x as an example, its M neighboring samples are found in the original training set as its neighboring sample pool, and random sampling is performed n times in the neighboring sample pool to obtain n target-neighboring sample groups, which are input into the trained label prediction network. The label of the target sample is predicted by the obtained reconstructed comparison label. The prediction value calculation process is as follows:
[0024]
[0025]
[0026] Among them, prob cl Represents the label prediction probability of the target sample, label represents the true category of the control neighbor sample, pred represents the category matching degree predicted by the model, the closer pred is to 0, the greater the difference between the test sample and the control neighbor sample, that is, the more likely they belong to different categories; similarly, the closer pred is to 1, the more likely the test sample and the control neighbor sample are to belong to the same category. At this time, the predicted category matching degree of the minority class sample with the true label of 1 in the control neighbor sample is close to 1, and the predicted category matching degree of the majority class sample with the true label of 0 is close to 0, indicating that the test sample is a minority class; conversely, the predicted category matching degree of the minority class sample with the true label of 1 in the control neighbor sample is close to 0, and the predicted category matching degree of the majority class sample with the true label of 0 is close to 1, indicating that the test sample is a majority class. Based on this, the above formula is used to compare the true label and predicted matching degree of the neighbor sample to obtain the label probability prediction prob of the target sample cl , and then according to the set threshold θ cl =0.45 to classify the target samples, prob cl When the value is close to 1, it is a minority class, prob cl Values close to 0 represent the majority class.
[0027] Optionally, balancing the number of minority class samples and majority class samples based on a generative adversarial network, determining a balanced data set, training a neural network binary classifier based on the balanced data set, performing label prediction on the test set data, and obtaining the label prediction probability of the target sample for the second time through the neural network binary classifier, including:
[0028] Based on the generative adversarial network, the number of minority class samples and majority class samples is balanced to determine the balanced data set;
[0029] Based on the balanced data set, a neural network binary classifier is trained to predict the labels of the test set data to obtain the label prediction probability prob of the test sample. clf ;
[0030]
[0031] Get Prob clf Then according to the above formula, the threshold value θ is set clf Classify the target sample, prob clf When the value is close to 1, it is a minority class, prob clf When the value is close to 0, it is the majority class.
[0032] Optionally, the label prediction probabilities of the target samples obtained twice are integrated proportionally to obtain the label prediction result of the sample to be tested, including:
[0033] The label prediction probability prob of the target sample obtained for the first time cl And the label prediction probability prob of the target sample obtained for the second time clf The weighted sum is used to obtain the label prediction result prob of the sample to be tested. The calculation formula is as follows:
[0034] prob=λ×prob cl +(1-λ)×prob clf
[0035]
[0036] Among them, λ is the value of prob cl The weight assigned is prob cl Then, the target samples are classified according to the set threshold θ according to the above formula.
[0037] Optionally, classifying the smart meter fault samples based on the label prediction results of the samples to be tested includes:
[0038] The smart meter fault data set is processed. The samples in the data set contain a variety of characteristic variables, namely: working hours, arrival batch number, power supply unit number, electric energy meter category, fault identification month, installation month, province, equipment specifications and communication method; its fault category labels include multiple categories, namely: appearance fault, power supply unit fault, software fault, clock unit fault, communication unit fault, metering unit fault, storage unit fault;
[0039] Traverse each category of samples in the fault data set, take all samples under this category as the minority class sample set, and take the remaining fault category samples as the majority class sample set, and transform the original data set into multiple second-category data sets. For each of the second-category data sets, the data set is described as:
[0040] X i =[X min ,X maj ]
[0041] Among them, X i is any one of the transformed two-category datasets, i∈[1,7]; X min For the second-class dataset X i The minority class sample set in X, where each sample class label is set to 1; maj For the second-class dataset X i The majority class sample set in X, where each sample class label is set to 0; i The size is G i =len(X i ), len(X i ) represents the second-class dataset X i The number of samples in ;
[0042] For the multiple data sets divided, one of them is taken as the minority class and the rest as the majority class, multiple binary classification fault data sets are determined, multiple models are trained, and the fault category with the highest probability is selected as the final prediction result.
[0043] According to another aspect of the present invention, there is also provided an electric energy meter fault classification system based on confrontation comparison, comprising:
[0044] Constructing a sample combination module, used to determine a weight calculation strategy that describes the degree of proximity of a sample to a data overlap region, adjusting the number of target-nearest neighbor sample combinations according to the weight calculation strategy, and constructing a target-nearest neighbor sample combination set;
[0045] The label prediction probability module is obtained for the first time, which is used to build a neural network, extract features from the constructed target-neighbor sample combination, compare the target sample with the neighbor sample in the target-neighbor sample combination, determine the degree of category matching, and obtain the label prediction probability of the target sample for the first time;
[0046] A label prediction probability module is obtained for the second time, which is used to balance the number of minority class samples and majority class samples based on the generative adversarial network, determine a balanced data set, train a neural network binary classifier based on the balanced data set, perform label prediction on the test set data, and obtain the neural network binary classifier to obtain the label prediction probability of the target sample for the second time;
[0047] The module for calculating the label prediction result of the sample to be tested is used to integrate the label prediction probability of the target sample and the label prediction probability of the test sample obtained twice in proportion to obtain the label prediction result of the sample to be tested;
[0048] The meter fault sample module is used to classify the smart meter fault samples based on the label prediction results of the samples to be tested.
[0049] Therefore, the target-neighbor sample combination is constructed by combining the contrastive learning idea, and the sampling times are adjusted according to the weight calculated by the inverse of the average Euclidean distance between each minority class sample and all majority class samples, so as to increase the attention to the minority class samples in the data overlap area. The constructed sample combination is feature extracted by using a neural network, and the relationship information of the same or different neighbor samples and the target sample is learned. Then, in the test phase, the true label of the sample can be analyzed by comparing the similarities and differences between the sample to be classified and its neighbors. This part fully explores the relationship information between the sample neighborhoods, focusing on the difficult-to-classify samples in the data overlap area, and improving the accuracy of the classification task. In order to supplement the use of the characteristic information of the sample itself, a neural network classifier is designed to assist in the discrimination of the results after the balanced data set is generated by the adversarial network. The sample labels predicted by the two methods are integrated to obtain the final classification result, which further enhances the overall accuracy and robustness of the classification task. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] A more complete understanding of exemplary embodiments of the present invention may be obtained by referring to the following drawings:
[0051] Figure 1 A schematic diagram of a flow chart of an electric energy meter fault classification method based on confrontation comparison described in this embodiment;
[0052] Figure 2 A schematic diagram of redefining a problem based on the comparison idea described in this embodiment;
[0053] Figure 3 This is a schematic diagram of the model network structure described in this implementation mode;
[0054] Figure 4 Schematic diagram of an electric energy meter fault classification system based on confrontation comparison described in this embodiment. DETAILED DESCRIPTION
[0055] Now, exemplary embodiments of the present invention are described with reference to the accompanying drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. These embodiments are provided to disclose the present invention in detail and completely and to fully convey the scope of the present invention to those skilled in the art. The terms used in the exemplary embodiments shown in the accompanying drawings are not intended to limit the present invention. In the accompanying drawings, the same units / elements are marked with the same reference numerals.
[0056] Unless otherwise specified, the terms (including technical terms) used herein have the commonly understood meanings to those skilled in the art. In addition, it is understood that the terms defined in commonly used dictionaries should be understood to have the same meanings as those in the context of the relevant fields, and should not be understood as idealized or overly formal meanings.
[0057] According to a first aspect of the present invention, a method 100 for classifying electric energy meter faults based on confrontation comparison is provided. Figure 1 As shown, the method 100 includes:
[0058] S101: Determine a weight calculation strategy that describes the degree to which a sample is close to a data overlap region, and adjust the number of constructed target-nearest neighbor sample combinations according to the weight calculation strategy to obtain a target-nearest neighbor sample combination set;
[0059] S102: Build a neural network, extract features from the constructed target-neighbor sample combination, compare the target sample with the neighbor sample in the target-neighbor sample combination, determine the degree of category matching, and obtain the label prediction probability of the target sample for the first time;
[0060] S103: Based on the number of minority class samples and majority class samples of the target-nearest neighbor sample combination set balanced by the generative adversarial network, a balanced data set is determined, a neural network binary classifier is trained based on the balanced data set, label prediction is performed on the test set data, and the label prediction probability of the target sample is obtained for the second time through the neural network binary classifier;
[0061] S104: Integrate the label prediction probabilities of the target samples obtained twice in proportion to obtain the label prediction result of the sample to be tested;
[0062] S105: Classify the smart meter fault samples based on the label prediction results of the samples to be tested.
[0063] Specifically, the traditional classification method models the features of the input training data, and finds a model that can classify the data into different categories by analyzing the relationship between the features and the labels, so as to predict the classification results of the test samples. By introducing the idea of contrastive learning, the traditional classification problem can be transformed into a multi-label matching problem. The k-nearest neighbor idea is combined to realize the construction of the target-neighbor sample combination. x is the target sample, p(x) is a set of control neighbor samples sampled from the target sample neighbor pool, and (x, p(x)) is the constructed target-neighbor sample combination. By comparing the similarities and differences between the neighbor samples and the target sample labels, the neighbor samples can be assigned reconstructed contrast labels, and the relationship combination p(same class or not|(x, p(x))) between the target sample and the neighbor samples can be obtained. In the process from the original data set sample to the sample combination, any target sample x can be sampled multiple times in its neighbor pool, so as to construct multiple groups of neighbor samples p(x). Therefore, in the new multi-label matching problem, not only can the number of target-neighbor sample combinations be multiplied compared to the number of original samples, but the relationship information between sample neighborhoods can also be focused on, which is conducive to improving model accuracy and reducing the risk of overfitting. Figure 2 shown.
[0064] Based on the above redefinition of the classification task, the present invention proposes an unbalanced classification algorithm based on neighbor relationship analysis. In order to adapt the input data to the comparison task, the original data is combined by the k-nearest neighbor method. First, for each target sample, find its M nearest neighbors as the neighbor pool, and then randomly sample N times in the neighbor pool, sampling K (K≤M) samples each time, and you can get N target-neighbor sample combinations, thereby achieving N times the expansion of the original training data. If the dimension of the original sample is d, the data dimension of each target-neighbor combination is ((1+K), d), and the dimension of its label is (1+K), where the first dimension is the true label label of the target sample target The remaining K dimensions are the reconstructed comparison labels of the sampled neighbors and whether they are of the same type. compare The sample combination method not only introduces the relational information contained in the sample neighborhood, but also does not introduce additional noise in the process of data expansion, solving the problem of additional noise introduced by traditional data-level methods.
[0065] Considering that for samples in the safe zone, the samples in its neighbor pool are very likely to be of the same type, that is, after forming the target-neighbor sample group, the probability that the reconstructed label of the neighbor sample is 1 is very high, which may affect the subsequent model performance; and for samples in the data overlap area, multiple random sampling in its neighbor pool can obtain richer sample and label information. In order to increase the attention to minority class samples in the data overlap area, the reciprocal of the average Euclidean distance between each minority class sample and all majority class samples is used as its weight, and the weight is geometrically expanded and rounded to facilitate the subsequent adjustment of the number of sampling times. Assuming that there are a samples in the minority class sample set X and b samples in the majority class sample set Y, the sample weight calculation process is as follows:
[0066]
[0067] Among them, x i and i Represent the minority class samples and the majority class samples respectively, D i Represents x i The average Euclidean distance to all majority class samples, D i The reciprocal of f i That is the weight of each minority class sample.
[0068] In order to extract high-dimensional features of the target-neighbor sample combination and better learn the category differences between samples, a neural network is built to reconstruct and compare the labels of the K nearest neighbors of the target sample. compare Make a prediction. The loss function of the network is defined as follows:
[0069]
[0070] Where m represents the batch size, and pred represents the predicted label output by the network. By optimizing the loss function, the neural network can predict the similarities and differences between neighboring samples and target samples.
[0071] In the testing process of the algorithm, for a target sample in the test set, first obtain its neighbor sample pool in the training set, and then perform n random sampling in the neighbor sample pool, sampling K neighbor samples each time. The target sample to be tested is compared with the K neighbor samples respectively, and the matching degree between the target sample to be tested and each neighbor sample is predicted. The n groups of matching degrees are integrated and calculated according to the threshold θ cl = 0.45 to obtain the predicted category label of the target sample. Taking the test sample x as an example, find its M nearest neighbor samples in the original training set as its nearest neighbor sample pool, and randomly sample n times in the nearest neighbor sample pool to obtain n target-nearest neighbor sample groups, which are input into the trained label prediction network, and the label of the test sample is predicted by the obtained reconstructed contrast label. The prediction value calculation process is as follows:
[0072]
[0073]
[0074] Where label represents the true category of the control neighbor sample, and pred represents the category matching degree predicted by the model. The closer pred is to 0, the greater the difference between the test sample and the control neighbor sample, that is, the more likely they are to belong to different categories; similarly, the closer pred is to 1, the more likely the test sample and the control neighbor sample are to belong to the same category. At this time, when the predicted category matching degree of the minority class sample (the true label is 1) in the control neighbor sample is close to 1, and the predicted category matching degree of the majority class sample (the true label is 0) is close to 0, it means that the test sample is a minority class; conversely, when the predicted category matching degree of the minority class sample (the true label is 1) in the control neighbor sample is close to 0, and the predicted category matching degree of the majority class sample (the true label is 0) is close to 1, it means that the test sample is a majority class. Based on this, the present invention compares the true label and predicted matching degree of the neighbor sample through the above formula to obtain the label prediction probability prob of the target sample. cl , and then according to the set threshold θ cl Classify the target samples, prob cl When the value is close to 1, it is a minority class, prob cl Values close to 0 represent the majority class.
[0075] The present invention is based on the idea of contrastive learning. It analyzes the sample neighbor relationship by constructing a target-neighbor sample combination, and transforms the traditional classification problem into a multi-label matching problem. By constructing multiple neighbor groups through multiple random sampling in the neighbor sample pool, not only can the number of sample combinations be multiplied compared to the original number of samples, but also the lack of information caused by too few neighbors and the additional noise caused by too many neighbors can be avoided. By integrating the category matching degree predicted by multiple groups of neighbors, the effective information contained in the samples in the neighbor pool is utilized to the greatest extent, thereby improving the accuracy and robustness of the model.
[0076] Taking into account that the above-mentioned multi-label matching task based on contrastive learning focuses on the relationship information between samples and samples in the data overlapping area, in order to improve the robustness of the overall classification model, a deep neural network is added on the basis of balancing the original data set through the generative adversarial network, and the balanced data set is sent to the network for sample category label prediction, which supplements the model's attention to the characteristics of the samples themselves and typical samples in the safe zone, and makes more effective use of the information of the data set.
[0077] Use the balanced training data to train a neural network binary classifier, perform label prediction on the test set data, and obtain the label prediction probability prob of the classifier clf .
[0078]
[0079] Get Prob clf Then according to the above formula, the threshold value θ is set clf Classify the target sample, prob clf When the value is close to 1, it is a minority class, prob clf When the value is close to 0, it is the majority class.
[0080] Get the label prediction probability prob of the above two methods respectively cl and prob clf After that, the two predicted labels are weighted and summed to obtain the label prediction result prob of the overall model, and then the target sample is classified according to the set threshold θ, realizing the integration of the label prediction method based on contrastive learning and the method of using neural network for classification after balancing the data. The calculation formula is as follows:
[0081] prob=λ×prob cl +(1-λ)×prob clf
[0082]
[0083] Network structure diagram reference for the overall model Figure 3 shown.
[0084] The historical data of smart meters under different fault categories are divided to obtain multiple second-class data sets as input data, specifically:
[0085] The actual fault data set of smart meters is processed. The samples in the data set contain 9 characteristic variables, namely: working time, arrival batch number, power supply unit number, electric energy meter category, fault identification month, installation month, province, equipment specification and communication method; its fault category labels contain 7 categories, namely: appearance fault, power supply unit fault, software fault, clock unit fault, communication unit fault, metering unit fault and storage unit fault; traverse each category of samples in the data set, take all samples under this category as minority class sample set, and take the rest of the fault category samples as majority class sample set, and convert the original data set into 7 two-category data sets; for each of the two-category data sets, the data set can be described as:
[0086] X i =[X min ,X maj ]
[0087] Among them, X i is any one of the seven transformed two-class data sets, i∈[1,7]; Xmin For the second-class dataset X i The minority class sample set in X, where each sample class label is set to 1; maj For the second-class dataset X i The majority class sample set in X, where each sample class label is set to 0; i The size is G i =len(X i ), len(X i ) represents the second-class dataset X i The number of samples in .
[0088] For the seven divided data sets, one of them is regarded as the minority class and the remaining six classes are regarded as the majority class, and the original multi-classification problem is converted into multiple binary classification problems for processing.
[0089] Because a total of 7 binary fault data sets were transformed, a total of 7 models were trained, and each model outputs a fault type. During the test, the sample to be tested will pass through 7 models respectively, and each model will output the probability of the sample to be tested being predicted as the current fault category. After all 7 models have output results, the fault category with the highest probability is selected as the final prediction result.
[0090] Aiming at the problem of highly unbalanced number of samples in each category and serious overlap of data between categories in smart meter fault data, a method for electric energy meter fault classification based on nearest neighbor relationship analysis is proposed. Combined with the idea of contrastive learning, the k-nearest neighbor learning method is used to construct the target-nearest neighbor sample combination, and the number of samples is doubled without introducing noise. Subsequently, in the training stage, a neural network is built to extract high-dimensional features from the constructed sample combination and learn the reconstructed contrast labels of the neighbor samples; in the testing stage, the label of the sample can be directly matched by comparing the similarities and differences between the test sample to be classified and its neighbors through predicting the contrast labels. In addition, a neural network classifier is used to classify the data set balanced by GAN, and the sample labels predicted by the two methods are integrated to obtain the final classification result, which improves the robustness of the overall model and can better cope with the smart meter fault classification task.
[0091] The proposed energy meter fault classification method based on nearest neighbor relationship analysis was compared with 6 algorithm-level methods and 9 data-level methods. The support vector machine (SVM) was used as a classifier to verify the sample balance effect of the data-level comparison method. The effectiveness and advancement of the proposed energy meter fault classification method based on transfer learning were confirmed.
[0092] The meter data set collected a total of 7 types of smart meter data from 25 provinces. Due to various factors such as manual labeling errors, the fault type labels were mislabeled or missed, and the meter fault data had problems such as outliers and missing values. After various technical processing such as missing value completion, feature selection, outlier detection, and data standardization, a total of 1,500 smart meter fault data were obtained. Among them, the number of samples of each fault type was highly unbalanced, with the maximum imbalance rate reaching 9.94. After the above data preprocessing, the obtained smart meter fault data set contains 9 characteristic attributes such as working time, arrival batch number, power supply unit number, electric energy meter category, fault identification month, installation month, province, equipment specifications, and communication method. In order to reduce the randomness of the results, the data set is randomly divided into training set and test set with a fixed random number seed in a ratio of 8:2.
[0093] As shown in Table 1, to verify the effectiveness of the proposed algorithm, 6 algorithm-level methods and 9 data-level methods were used for comparison in the embodiment of the present invention. All models were fully retrained and tested in the same experimental environment using official codes.
[0094] Table 1 Comparison methods and detailed information
[0095]
[0096]
[0097] The embodiment of the present invention uses macro-F1 and G-mean indicators to evaluate the classification effect of the algorithm. The macro-F1 indicator is the arithmetic mean of the F1-measure of each fault category, which is used to comprehensively evaluate the accuracy and recall of the model in each category. The G-mean indicator is the geometric mean of the recall rate in each category, which is used to evaluate the recall of the model in each category. Both Macro-F1 and G-mean have values from 0 to 1. The larger the value, the better the classification performance of the model.
[0098] Table 2 Label prediction network structure
[0099]
[0100] Table 3 Generative adversarial network structure
[0101]
[0102]
[0103] Table 4 Classifier network structure
[0104]
[0105] Refer to Table 2, Table 3 and Table 4. In the above tables, "*" indicates the number of features of a sample, and K is the number of selected neighbor samples. In the training process of the label prediction network, the number of training rounds of the model is fixed to 40 times, the optimizer is Adam, and the learning rate is set to 0.0001. In the training process of the generative adversarial network, the number of training rounds of the model is fixed to 100 times, the optimizer is Adam, and the learning rates of the generator G and the discriminator D are both set to 0.0001. In the training process of the neural network classifier, the number of training rounds of the model is fixed to 10 times, the optimizer is Adam, and the learning rate is set to 0.0001. In addition, in order to reduce the randomness of the results during the experiment, a 5-fold cross validation was performed for each type of experiment.
[0106] The experimental results of the comparison of the F1-measure and macro-F1 indicators of the embodiment of the present invention and the comparison methods at the algorithm level under each fault category of the smart meter are shown in Table 5, and the experimental results of the recall rate and G-mean indicators of each category are shown in Table 6; the experimental results of the comparison of the F1-measure and macro-F1 indicators of the embodiment of the present invention and the comparison methods at the data level under each fault category of the smart meter are shown in Table 7, and the experimental results of the recall rate and G-mean indicators of each category are shown in Table 8. It can be seen that the electric energy meter fault classification method based on neighbor relationship analysis proposed in the present invention has obtained F1-measure and recall rates that exceed other methods in most categories, and has obtained the highest macro-F1 and G-mean, and has obvious advantages in the G-mean indicator. The results in Tables 5 to 8 show that the fault sample balancing effect of the method of the embodiment of the present invention is better than that of the comparison methods, and can obtain higher classification accuracy and recall rate.
[0107] Table 5 Experimental results of the F1-measure and macro-F1 indicators of the embodiment of the present invention and the comparison methods at various algorithm levels under various fault categories of smart meters
[0108]
[0109] Table 6 Experimental results of the recall rate and G-mean index of the embodiment of the present invention and the comparison method of each algorithm level under various fault categories of smart meters
[0110]
[0111] Table 7 Experimental results of the embodiments of the present invention and the comparison methods at various data levels on the F1-measure and macro-F1 indicators under various fault categories of smart meters
[0112]
[0113]
[0114] Table 8 Experimental results of the recall rate and G-mean index of the embodiment of the present invention and the comparison method at each data level under various fault categories of smart meters
[0115]
[0116] Through experimental comparative analysis with a total of 15 mainstream data-level methods and algorithm-level methods on the actual fault data set of smart meters, it is shown that the proposed method can effectively mine the relationship information of samples of each category, generate real and diverse samples to expand the data without introducing noise, thereby improving the accuracy and robustness of smart meter fault classification, thereby effectively reducing the operation and maintenance cost of smart grids and improving their overall stability.
[0117] Optionally, a weight calculation strategy describing the degree of proximity of a sample to a data overlap region is determined, and the number of constructed target-nearest neighbor sample combinations is adjusted according to the weight calculation strategy to obtain a target-nearest neighbor sample combination set, including:
[0118] Randomly sample N times in the neighbor pool M of the target sample, sampling K (K≤M) samples each time, to obtain N target-neighbor sample combinations;
[0119] If the dimension of the original sample is d, then the data dimension of each target-neighbor combination is determined to be ((1+K), d), and the dimension of its label is (1+K), where the first dimension is the true label label of the target sample target The remaining K dimensions are the reconstructed comparison labels of the sampled neighbors and whether they are of the same type. compare ;
[0120] Assume that there are a samples in the minority class sample set X and b samples in the majority class sample set Y. Calculate the inverse of the average Euclidean distance between each minority class sample and all majority class samples as its weight. The calculation process is as follows:
[0121]
[0122] Among them, x i and i Represent the minority class samples and the majority class samples respectively, D i Represents x i The average Euclidean distance to all majority class samples, D i The reciprocal of f i That is the weight of each minority sample.
[0123] Optionally, a neural network is constructed to extract features from the constructed target-neighbor sample combination, including:
[0124] Build a neural network to reconstruct and compare the labels of the K nearest neighbors of the target sample compare To make a prediction, the loss function of the neural network is defined as follows:
[0125]
[0126] Where m represents the batch size, pred represents the predicted label of the network output, label compare Represents the reconstruction comparison label. By optimizing the loss function, the neural network has the ability to predict the similarities and differences between the neighboring samples and the target samples.
[0127] Optionally, the target sample and the neighbor sample in the target-neighbor sample combination are compared to determine the degree of category matching, and the label prediction probability of the target sample is obtained for the first time, including:
[0128] The target sample to be tested is compared with K neighboring samples respectively, and the matching degree between the target sample to be tested and each neighboring sample is predicted. The n groups of matching degrees are integrated and divided according to the threshold to obtain the predicted category label of the target sample. Taking the test sample x as an example, its M neighboring samples are found in the original training set as its neighboring sample pool, and random sampling is performed n times in the neighboring sample pool to obtain n target-neighboring sample groups, which are input into the trained label prediction network. The label of the target sample is predicted by the obtained reconstructed comparison label. The prediction value calculation process is as follows:
[0129]
[0130] Among them, prob cl Represents the label prediction probability of the target sample, label represents the true category of the control neighbor sample, pred represents the category matching degree predicted by the model, the closer pred is to 0, the greater the difference between the test sample and the control neighbor sample, that is, the more likely they belong to different categories; similarly, the closer pred is to 1, the more likely the test sample and the control neighbor sample are to belong to the same category. At this time, the predicted category matching degree of the minority class sample with the true label of 1 in the control neighbor sample is close to 1, and the predicted category matching degree of the majority class sample with the true label of 0 is close to 0, indicating that the test sample is a minority class; conversely, the predicted category matching degree of the minority class sample with the true label of 1 in the control neighbor sample is close to 0, and the predicted category matching degree of the majority class sample with the true label of 0 is close to 1, indicating that the test sample is a majority class. Based on this, the above formula is used to compare the true label and predicted matching degree of the neighbor sample to obtain the label probability prediction prob of the target sample cl , and then according to the set threshold θ cl =0.45 to classify the target samples, prob cl When the value is close to 1, it is a minority class, probcl Values close to 0 represent the majority class.
[0131] Optionally, balancing the number of minority class samples and majority class samples based on a generative adversarial network, determining a balanced data set, training a neural network binary classifier based on the balanced data set, performing label prediction on the test set data, and obtaining the label prediction probability of the target sample for the second time through the neural network binary classifier, including:
[0132] Based on the generative adversarial network, the number of minority class samples and majority class samples is balanced to determine the balanced data set;
[0133] Based on the balanced data set, a neural network binary classifier is trained to predict the labels of the test set data to obtain the label prediction probability prob of the test sample. clf ;
[0134]
[0135] Get Prob clf Then according to the above formula, the threshold value θ is set clf Classify the target sample, prob clf When the value is close to 1, it is a minority class, prob clf When the value is close to 0, it is the majority class.
[0136] Optionally, the label prediction probabilities of the target samples obtained twice are integrated proportionally to obtain the label prediction result of the sample to be tested, including:
[0137] The label prediction probability prob of the target sample obtained for the first time cl And the label prediction probability prob of the test sample clf The weighted sum is used to obtain the label prediction result prob of the sample to be tested. The calculation formula is as follows:
[0138] prob=λ×prob cl +(1-λ)×prob clf
[0139]
[0140] Among them, λ is the value of prob cl The weight assigned is prob cl Then, the target samples are classified according to the set threshold θ according to the above formula.
[0141] Optionally, classifying the smart meter fault samples based on the label prediction results of the samples to be tested includes:
[0142] The smart meter fault data set is processed. The samples in the data set contain a variety of characteristic variables, namely: working hours, arrival batch number, power supply unit number, electric energy meter category, fault identification month, installation month, province, equipment specifications and communication method; its fault category labels include multiple categories, namely: appearance fault, power supply unit fault, software fault, clock unit fault, communication unit fault, metering unit fault, storage unit fault;
[0143] Traverse each category of samples in the fault data set, take all samples under this category as the minority class sample set, and take the remaining fault category samples as the majority class sample set, and transform the original data set into multiple second-category data sets. For each of the second-category data sets, the data set is described as:
[0144] X i =[X min ,X maj ]
[0145] Among them, X i is any one of the transformed two-category datasets, i∈[1,7]; X min For the second-class dataset X i The minority class sample set in X, where each sample class label is set to 1; maj For the second-class dataset X i The majority class sample set in X, where each sample class label is set to 0; i The size is G i =len(X i ), len(X i ) represents the second-class dataset X i The number of samples in ;
[0146] For the multiple data sets divided, one of them is taken as the minority class and the rest as the majority class, multiple binary classification fault data sets are determined, multiple models are trained, and the fault category with the highest probability is selected as the final prediction result.
[0147] Thus, a target-neighbor sample combination is constructed, and the sampling times are adjusted by calculating the weight according to the inverse of the average Euclidean distance between each minority class sample and all majority class samples, so as to increase the attention paid to minority class samples in the data overlap area. The constructed sample combination is feature extracted using a neural network, and the relationship information between the neighbor samples and the target sample is learned. Then, in the test phase, the true label of the sample can be analyzed by comparing the similarities and differences between the sample to be classified and its neighbors. This part fully explores the relationship information between sample neighborhoods, focusing on difficult-to-classify samples in the data overlap area, and improving the accuracy of the classification task.
[0148] After generating a balanced data set through a generative adversarial network, a neural network classifier was designed to assist in distinguishing the results. The sample labels predicted by the two methods were integrated to obtain the final classification result, further enhancing the overall accuracy and robustness of the classification task.
[0149] According to another aspect of the present invention, there is also provided an electric energy meter fault classification system 400 based on confrontation comparison, referring to Figure 4 As shown, the system 400 includes:
[0150] The sample combination construction module 410 is used to determine a weight calculation strategy that describes the degree of proximity of the sample to the data overlap region, adjust the number of target-nearest neighbor sample combinations according to the weight calculation strategy, and construct a target-nearest neighbor sample combination set;
[0151] The first label prediction probability module 420 is used to build a neural network, extract features from the constructed target-neighbor sample combination, compare the target sample with the neighbor sample in the target-neighbor sample combination, determine the category matching degree, and obtain the label prediction probability of the target sample for the first time;
[0152] The second label prediction probability obtaining module 430 is used to determine a balanced data set based on the number of minority class samples and majority class samples of the target-nearest neighbor sample combination set generated by the adversarial network, train a neural network binary classifier based on the balanced data set, perform label prediction on the test set data, and obtain the label prediction probability of the target sample for the second time by obtaining the neural network binary classifier;
[0153] The module 440 for calculating the label prediction result of the sample to be tested is used to integrate the label prediction probability of the target sample and the label prediction probability of the test sample obtained twice in proportion to obtain the label prediction result of the sample to be tested;
[0154] The meter fault sample module 450 is used to classify the smart meter fault samples based on the label prediction results of the samples to be tested.
[0155] An electric energy meter fault classification system 400 based on confrontation comparison in an embodiment of the present invention corresponds to an electric energy meter fault classification method 100 based on confrontation comparison in another embodiment of the present invention, and will not be described in detail herein.
[0156] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of complete hardware embodiments, complete software embodiments, or embodiments in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code. The scheme in the embodiments of the present application can be implemented in various computer languages, for example, object-oriented programming language Java and literal scripting language JavaScript, etc.
[0157] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0158] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0159] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0160] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0161] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for classifying electric energy meter faults based on confrontation comparison, characterized in that: include: Determine a weight calculation strategy that describes the degree to which a sample is close to a data overlap region, adjust the number of target-nearest neighbor sample combinations according to the weight calculation strategy, and construct a target-nearest neighbor sample combination set; Build a neural network, extract features from the constructed target-neighbor sample combination, compare the target sample with the neighbor sample in the target-neighbor sample combination, determine the degree of category matching, and obtain the label prediction probability of the target sample for the first time; Based on the generation of an adversarial network to balance the number of minority class samples and majority class samples of the target-neighbor sample combination set, a balanced data set is determined, a neural network binary classifier is trained based on the balanced data set, label prediction is performed on the test set data, and the label prediction probability of the target sample is obtained for the second time through the neural network binary classifier; The label prediction probabilities of the target samples obtained twice are integrated proportionally to obtain the label prediction results of the sample to be tested; Based on the label prediction results of the samples to be tested, the smart meter fault samples are classified.
2. The method according to claim 1, characterized in that Determine a weight calculation strategy that describes the degree of proximity of the sample to the data overlap region, adjust the number of target-nearest neighbor sample combinations according to the weight calculation strategy, and construct a target-nearest neighbor sample combination set, including: Randomly sample N times in the neighbor pool M of the target sample, sampling K (K≤M) samples each time, to obtain N target-neighbor sample combinations; If the dimension of the original sample is d, then the data dimension of each target-neighbor combination is determined to be ((1+K), d), and the dimension of its label is (1+K), where the first dimension is the true label label of the target sample target The remaining K dimensions are the reconstructed comparison labels of the sampled neighbors and whether they are of the same type. compare ; Assume that there are a samples in the minority class sample set X and b samples in the majority class sample set Y. Calculate the inverse of the average Euclidean distance between each minority class sample and all majority class samples as its weight. The calculation process is as follows: Among them, x i and i Represent the minority class samples and the majority class samples respectively, D i Represents x i The average Euclidean distance to all majority class samples, D i The reciprocal of f i That is the weight of each minority sample.
3. The method according to claim 1, characterized in that Build a neural network to extract features from the constructed target-neighbor sample combination, including: Build a neural network to reconstruct and compare the labels of the K nearest neighbors of the target sample compare To make a prediction, the loss function of the neural network is defined as follows: Where m represents the batch size, pred represents the predicted label of the network output, label compare Represents the reconstruction comparison label. By optimizing the loss function, the neural network has the ability to predict the similarities and differences between the neighboring samples and the target samples.
4. The method according to claim 1, characterized in that: Compare the target sample and the neighbor sample in the target-neighbor sample combination to determine the degree of category matching and obtain the label prediction probability of the target sample for the first time, including: The target sample to be tested is compared with K neighboring samples respectively, and the matching degree between the target sample to be tested and each neighboring sample is predicted. The n groups of matching degrees are integrated and divided according to the threshold to obtain the predicted category label of the target sample. Taking the test sample x as an example, its M neighboring samples are found in the original training set as its neighboring sample pool, and random sampling is performed n times in the neighboring sample pool to obtain n target-neighboring sample groups, which are input into the trained label prediction network. The label of the target sample is predicted by the obtained reconstructed comparison label. The prediction value calculation process is as follows: Among them, prob cl Represents the label prediction probability of the target sample, label represents the true category of the control neighbor sample, pred represents the category matching degree predicted by the model, the closer pred is to 0, the greater the difference between the test sample and the control neighbor sample, that is, the more likely they belong to different categories; similarly, the closer pred is to 1, the more likely the test sample and the control neighbor sample are to belong to the same category. At this time, the predicted category matching degree of the minority class sample with the true label of 1 in the control neighbor sample is close to 1, and the predicted category matching degree of the majority class sample with the true label of 0 is close to 0, indicating that the test sample is a minority class; conversely, the predicted category matching degree of the minority class sample with the true label of 1 in the control neighbor sample is close to 0, and the predicted category matching degree of the majority class sample with the true label of 0 is close to 1, indicating that the test sample is a majority class. Based on this, the above formula is used to compare the true label and predicted matching degree of the neighbor sample to obtain the label probability prediction prob of the target sample cl , and then according to the set threshold θ cl =0.45 to classify the target samples, prob cl When the value is close to 1, it is a minority class, prob cl Values close to 0 represent the majority class.
5. The method according to claim 1, characterized in that: Based on the generative adversarial network, the number of minority class samples and majority class samples is balanced, a balanced data set is determined, a neural network binary classifier is trained based on the balanced data set, label prediction is performed on the test set data, and the label prediction probability of the target sample is obtained for the second time through the neural network binary classifier, including: Based on the generative adversarial network, the number of minority class samples and majority class samples is balanced to determine the balanced data set; Based on the balanced data set, a neural network binary classifier is trained to predict the labels of the test set data to obtain the label prediction probability prob of the test sample. clf ; Get Prob clf Then according to the above formula, the threshold value θ is set clf Classify the target sample, prob clf When the value is close to 1, it is a minority class, prob clf When the value is close to 0, it is the majority class.
6. The method according to claim 1, characterized in that The label prediction probabilities of the target samples obtained twice are integrated proportionally to obtain the label prediction results of the sample to be tested, including: The label prediction probability prob of the target sample obtained for the first time cl And the label prediction probability prob of the target sample obtained for the second time clf The weighted sum is used to obtain the label prediction result prob of the sample to be tested. The calculation formula is as follows: prob=λ×prob cl +(1-λ)×prob clf Among them, λ is the value of prob cl The weight assigned is prob cl Then, the target samples are classified according to the set threshold θ according to the above formula.
7. The method according to claim 1, characterized in that Based on the label prediction result of the sample to be tested, the smart meter fault sample is classified, including: The smart meter fault data set is processed. The samples in the data set contain a variety of characteristic variables, namely: working hours, arrival batch number, power supply unit number, electric energy meter category, fault identification month, installation month, province, equipment specifications and communication method; its fault category labels include multiple categories, namely: appearance fault, power supply unit fault, software fault, clock unit fault, communication unit fault, metering unit fault, storage unit fault; Traverse each category of samples in the fault data set, take all samples under this category as the minority class sample set, and take the remaining fault category samples as the majority class sample set, and transform the original data set into multiple second-category data sets. For each of the second-category data sets, the data set is described as: X i =[X min ,X maj ] Among them, X i is any one of the transformed two-category datasets, i∈[1,7]; X min For the second-class dataset X i The minority class sample set in X, where each sample class label is set to 1; maj For the second-class dataset X i The majority class sample set in X, where each sample class label is set to 0; i The size is G i =len(X i ), len(X i ) represents the second-class dataset X i The number of samples in ; For the multiple data sets divided, one of them is taken as the minority class and the rest as the majority class, multiple binary classification fault data sets are determined, multiple models are trained, and the fault category with the highest probability is selected as the final prediction result.
8. An electric energy meter fault classification system based on confrontation comparison, characterized in that: include: Constructing a sample combination module, used to determine a weight calculation strategy that describes the degree of proximity of a sample to a data overlap region, adjusting the number of target-nearest neighbor sample combinations according to the weight calculation strategy, and constructing a target-nearest neighbor sample combination set; The label prediction probability module is obtained for the first time, which is used to build a neural network, extract features from the constructed target-neighbor sample combination, compare the target sample with the neighbor sample in the target-neighbor sample combination, determine the degree of category matching, and obtain the label prediction probability of the target sample for the first time; A label prediction probability module is obtained for the second time, which is used to balance the number of minority class samples and majority class samples of the target-nearest neighbor sample combination set based on the generative adversarial network, determine a balanced data set, train a neural network binary classifier based on the balanced data set, perform label prediction on the test set data, and obtain the label prediction probability of the target sample for the second time by obtaining the neural network binary classifier; The module for calculating the label prediction result of the sample to be tested is used to integrate the label prediction probability of the target sample and the label prediction probability of the test sample obtained twice in proportion to obtain the label prediction result of the sample to be tested; The meter fault sample module is used to classify the smart meter fault samples based on the label prediction results of the samples to be tested.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
10. An electronic device, characterized in that: include: The computer readable storage medium as claimed in claim 9; as well as One or more processors are used to execute the program in the computer-readable storage medium.
Citation Information
Cited By
Hydrological data automatic classification and dynamic label generation method and system
CN122286454A
Hydrological data automatic classification and dynamic label generation method and system
CN122286454B