Meter fault classification method and device, electronic equipment and computer storage medium
By training a target classifier on historical data of smart meter faults using a category difference constrained flow model, the problem of difficulty in judging the fault type of smart meters is solved, and more efficient fault handling is achieved.
Patent Information
- Application Number
- CN202211530445.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-01
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2042-12-01
AI Technical Summary
In existing technologies, it is difficult to determine the fault type of smart meters, resulting in untimely and inefficient fault handling.
A category difference constrained flow model is used to train historical data of electricity meter faults, and a target category difference constrained flow model and a target classifier are established. By mapping the data to the latent space, the distribution of data of the same type is reduced and the distribution of data of different types is increased. The trained classifier is used to determine the fault type.
This improved the accuracy of meter fault classification and increased the efficiency of fault handling.
Smart Images

Figure CN116010875B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of electric energy metering, and more particularly to a meter fault classification method and device, an electronic device, and a computer storage medium. BACKGROUND
[0002] As an important terminal of the smart grid, the smart meter not only has basic functions such as data acquisition and metering of the traditional meter, but also meets the requirements of remote communication, information processing, automatic control, and various expansion functions, plays an important supporting role in the stable operation of the power grid, and realizes the rapid and accurate judgment of the fault type of the smart meter, which is of great significance to improving the operation quality of the smart grid and ensuring the stability of power consumption.
[0003] The design scheme, component selection, and process flow of each smart meter manufacturer are different, and are affected by complex external operating environments, so the fault types of the smart meter are diverse and complex. At present, the handling of the smart meter fault mainly depends on the operation and maintenance personnel, who mainly rely on experience to judge the fault type of the meter. For the meter faults that have not been handled, it is often difficult to judge the fault type of the meter, resulting in untimely handling of the meter fault and low fault handling efficiency. SUMMARY
[0004] Therefore, the application provides a meter fault classification method and device, an electronic device, and a computer storage medium, which mainly aims to solve the problem that it is difficult to judge the fault type of the meter, resulting in untimely handling of the meter fault and low fault handling efficiency.
[0005] According to a first aspect of the application, a meter fault classification method is provided, which includes:
[0006] Obtaining fault history data of a plurality of meters under a plurality of fault types as an input data set, and dividing the input data set into a two-class sample set, wherein the two-class sample set includes a two-class sample subset corresponding to each fault type in the plurality of fault types;
[0007] Establishing a category difference constraint flow model, and training the category difference constraint flow model using the two-class sample subset corresponding to each fault type to update the parameters, to obtain a target category difference constraint flow model corresponding to each fault type;
[0008] Inputting the two-class sample subset corresponding to each fault type into the corresponding target category difference constraint flow model to obtain a two-class mapping sample set;
[0009] Determining an initial classifier, and training the initial classifier based on the mapping sample subset corresponding to each fault type in the two-class mapping sample set to obtain a target classifier corresponding to each fault type;
[0010] obtaining a test sample, and determining a fault type corresponding to the test sample in the plurality of fault types based on the target class difference constraint flow model corresponding to each fault type and the target classifier.
[0011] Optionally, the dividing the input data set into a two-class sample set comprises:
[0012] traversing each fault history data in the input data set to determine a minority class data subset and a majority class data subset corresponding to each fault type in the plurality of fault types, wherein the minority class data subset is a data set corresponding to one fault type in the plurality of fault types, and the majority class data subset is a data set corresponding to other fault types except the one fault type in the plurality of fault types;
[0013] obtaining the two-class sample set based on the minority class data subset and the majority class data subset corresponding to each fault type in the plurality of fault types, wherein each two-class sample subset in the two-class sample set corresponds to one fault type.
[0014] Optionally, the establishing the class difference constraint flow model comprises:
[0015] establishing a class difference constraint flow model comprising a sample standardization layer, a reversible transformation layer and an affine coupling layer; wherein,
[0016] the sample standardization layer is configured to perform transformation on each dimension by using a learnable scale transformation s1 and an offset transformation b1, and a transformation formula of each dimension is represented as:
[0017] Formula 1: v1 = s1 ⊙ u1 + b1,
[0018] wherein u1 is an input sample of the sample standardization layer, v1 is output data of the sample standardization layer, and ⊙ represents multiplication of corresponding positions of vectors;
[0019] the reversible transformation layer is configured to transform the sample after the sample standardization layer, and the sample after the reversible transformation is represented as:
[0020] Formula 2: v2 = Wu2,
[0021] wherein W represents an initialized n × n-dimensional random matrix, u2 is an input sample of the reversible transformation layer, and v2 is output data of the reversible transformation layer;
[0022] the affine coupling layer is configured to divide attributes of the sample after the reversible transformation layer into two parts, and use a nonlinear transformation NN to transform one part of the attributes u 1:da scale transformation s2 and an offset transformation b2 are performed, and another part of the divided sample attribute u is transformed using the scale transformation s2 and the offset transformation b2 d+1:n an affine transformation is performed on the scale transformation s2 and the offset transformation b2, and the feature u after the affine transformation d+1:n respectively, as shown in the following formulas 1 and 2:
[0023] Formula 3: s2, b2 = NN(u 1:d ),
[0024] Formula 4: v d+1:n = s2⊙u d+1:n + b2,
[0025] wherein 1:d represents the first to d-dimensional features of the sample, d+1:n represents the d+1 to n-dimensional features of the sample, and v d+1:n is output data of the affine coupling layer.
[0026] Optionally, the training of the class difference constraint flow model using the two-class sample subset corresponding to each fault type, the updating of the parameters, and the obtaining of the target class difference constraint flow model corresponding to each fault type include:
[0027] each sample in the two-class sample subset corresponding to each fault type is input into the formula 1, and a sample standardization layer loss corresponding to each sample is determined, and the sample standardization layer loss is represented as:
[0028]
[0029] wherein s i represents an i-th element of a vector;
[0030] the output data of the sample standardization layer is input into the formula 2 as input sample of the reversible transformation layer, a reversible transformation layer loss corresponding to each sample is determined, and the reversible transformation layer loss is represented as:
[0031] Formula 6: L Permutation = -log|det(W)|,
[0032] wherein det() represents a calculation of a matrix determinant;
[0033] the output data of the reversible transformation layer is input into the formula 3 and the formula 4 as input sample of the affine coupling layer, an affine coupling layer loss corresponding to each sample is determined, and the affine coupling layer loss is represented as:
[0034] a global constraint loss L globalLocal constraint loss L local And based on the sample normalization layer loss L corresponding to each sample Actnorm Reversible transformation layer loss L Permutation Affine coupling layer loss L Affine Global constraint loss L global and local constraint loss L local Determine the model loss function L of the category difference constrained flow model. model And by minimizing the model loss function L model The parameters of the class difference constrained flow model are updated using gradient descent to obtain the target class difference constrained flow model corresponding to each binary sample subset. The model loss function for each binary sample subset is expressed as:
[0035] Formula 8: L model =L Actnorm +L Permutation +L Affine +L global +α*L local ,
[0036] in, x i Let f be the i-th sample in the binary sample subset, M be the number of samples in the binary sample subset, and f θ For the category difference constrained flow model, p z () Latent space data distribution, N(u) y ,Σ y ) indicates that the mean value corresponding to category y is u. y The covariance matrix is Σ y The normal distribution ω and b1 are the weights and offsets used to construct the linear classifier with local constraints, β is the regularization hyperparameter, and α is the hyperparameter that controls the weights of the local constraint loss.
[0037] Optionally, training the initial classifier based on a subset of mapping samples corresponding to each fault type in the binary mapping sample set to obtain the target classifier corresponding to each fault type includes:
[0038] Calculate the noise probability of each mapped sample in the binary mapping sample set, and denoise the binary sample set based on the noise probability of each mapped sample to obtain a denoised binary sample set;
[0039] The corresponding target class difference constraint flow model is trained and updated using the denoised sample subset corresponding to each fault type in the denoised binary sample set. The denoised sample subset is then input into the corresponding trained target class difference constraint flow model to obtain the denoised mapping dataset of the denoised binary sample set in the latent space. Each denoised mapping sample subset in the denoised mapping dataset includes a denoised minority class mapping dataset and a denoised majority class mapping dataset corresponding to the denoised minority class mapping dataset.
[0040] For each subset of denoised minority class mapping data, perform the following operations: determine the neighboring data of each denoised minority class mapping data in the subset, obtain new minority class mapping data based on each denoised minority class mapping data and its corresponding neighboring data, and obtain a new subset of denoised minority class mapping data based on each denoised minority class mapping data and its corresponding new minority class mapping data. new Represented as:
[0041] Formula 10: z new =z i +a*(z i,j -z i ),
[0042] Among them, z i For the i-th denoised minority class mapping data in the subset of denoised minority class mapping data, z i,j For z i The corresponding neighboring data, where 'a' is a random number between 0 and 1;
[0043] The initial classifier is trained using each subset of new denoised mapping samples in the two-class new denoised mapping sample set to obtain the target classifier corresponding to each subset of new denoised mapping samples. Each subset of new denoised mapping samples corresponds to a fault type, and each subset of new denoised mapping samples includes a subset of new denoised minority class mapping data and a subset of denoised majority class mapping data corresponding to the subset of new denoised minority class mapping data.
[0044] Optionally, the step of calculating the noise probability of each mapped sample in the binary mapped sample set, and denoising the binary sample set based on the noise probability of each mapped sample to obtain a denoised binary sample set, includes:
[0045] Calculate the probability that each mapped sample in each subset of the binary mapped sample set follows a latent space distribution, and the probability prod corresponding to the i-th mapped sample. i for:
[0046] Formula 11: prodi =log(p z (f θ (x i )|y=y i ))=log(N(f θ (x i )|u y ,Σ y ));
[0047] The probability of each mapped sample being noise is obtained by taking the inverse of the probability corresponding to each mapped sample;
[0048] Calculate the first quartile and the third quartile of the noise probability corresponding to each subset of mapped samples;
[0049] Based on the first quartile and the third quartile of the noise probability corresponding to each mapped sample subset, the noise data in the two-class sample set is determined;
[0050] The noisy data in the two-class sample set is removed from the two-class sample set to obtain the denoised two-class sample set.
[0051] Optionally, the step of determining the fault type corresponding to the test sample among the multiple fault types based on the target category difference constraint flow model and the target classifier corresponding to each fault type includes:
[0052] The test samples are input into the target category difference constraint flow model corresponding to each fault type to obtain the mapping data of the test samples in the latent space corresponding to each fault type.
[0053] The mapping data corresponding to each fault type is input into the corresponding target classifier to obtain the probability that the test sample has each fault type;
[0054] The fault type corresponding to the maximum probability of each fault type in the test sample is determined as the target fault type.
[0055] According to a second aspect of this application, a classification device for electricity meter faults is provided, comprising:
[0056] The first acquisition module is used to acquire historical fault data of multiple meters under multiple fault types as input dataset, and divide the input dataset into two sample sets, wherein the two sample sets include a subset of two samples corresponding to each fault type among the multiple fault types.
[0057] The first training module is used to establish a category difference constrained flow model, and to train the category difference constrained flow model using a subset of two types of samples corresponding to each fault type, update the parameters, and obtain the target category difference constrained flow model corresponding to each fault type.
[0058] The second acquisition module is used to input the binary sample subset corresponding to each fault type into the corresponding target category difference constraint flow model to obtain a binary mapping sample set;
[0059] The second training module is used to determine an initial classifier and train the initial classifier based on a subset of mapping samples corresponding to each fault type in the binary mapping sample set to obtain a target classifier corresponding to each fault type.
[0060] The classification module is used to acquire test samples and, based on the target category difference constraint flow model and target classifier corresponding to each fault type, determine the fault type corresponding to the test sample among the multiple fault types.
[0061] Optionally, the first acquisition module is further configured to: traverse each historical fault data in the input dataset, determine the minority class data subset and the majority class data subset corresponding to each fault type among the plurality of fault types, wherein the minority class data subset is the dataset corresponding to one fault type among the plurality of fault types, and the majority class data subset is the dataset corresponding to other fault types among the plurality of fault types besides the one fault type; obtain the binary sample set based on the minority class data subset and the majority class data subset corresponding to each fault type among the plurality of fault types, wherein each binary sample subset in the binary sample set corresponds to one fault type.
[0062] Optionally, the first training module is further configured to:
[0063] Establish a class difference constrained flow model comprising a sample normalization layer, a reversible transformation layer, and an affine coupling layer; wherein,
[0064] The sample normalization layer is used to transform each dimension using a learnable scaling transformation s1 and an offset transformation b1. The transformation formula for each dimension is expressed as follows:
[0065] Formula 1: v1=s1⊙u1+b1,
[0066] Where u1 is the input sample of the sample standardization layer, v1 is the output data of the sample standardization layer, and ⊙ represents the multiplication of corresponding positions of vectors;
[0067] The reversible transformation layer is used to transform the samples that have passed through the sample standardization layer. The samples after the reversible transformation are represented as follows:
[0068] Formula 2: v2=Wu2,
[0069] Where W represents the initialized n×n-dimensional random matrix, u2 is the input sample of the invertible transformation layer, and v2 is the output data of the invertible transformation layer;
[0070] The affine coupling layer is used to divide the attributes of the samples after the reversible transformation layer into two parts, and a nonlinear transformation NN is used to process a portion of the attributes u of the divided samples. 1:d The transformations are performed to obtain scaling transformation s2 and offset transformation b2, and another part of the attribute u of the partitioned sample is applied using scaling transformation s2 and offset transformation b2. d+1:n Perform an affine transformation, including the scaling transformation s2 and the offset transformation b2, and the feature u after the affine transformation. d+1:n They are represented as follows:
[0071] Formula 3: s2,b2=NN(u 1:d ),
[0072] Formula 4: v d+1:n =s2⊙u d+1:n +b2,
[0073] Where 1:d represents the 1st to dth dimensions of the sample, d+1:n represents the (d+1)th to nth dimensions of the sample, and v d+1:n This refers to the output data of the affine coupling layer.
[0074] Optionally, the first training module is further configured to:
[0075] Each sample from the binary sample subset corresponding to each fault type is input into Formula 1 to determine the sample standardization layer loss corresponding to each sample. The sample standardization layer loss is expressed as:
[0076]
[0077] Among them, s i This represents the i-th element of the vector;
[0078] The output data of the sample normalization layer is used as the input sample of the reversible transformation layer and input into Formula 2 to determine the reversible transformation layer loss corresponding to each sample. The reversible transformation layer loss is expressed as:
[0079] Formula 6: L Permutation = -log|det(W)|,
[0080] Where det() calculates the determinant of a matrix;
[0081] The output data of the reversible transformation layer is used as the input sample of the affine coupling layer and input into Equations 3 and 4 to determine the affine coupling layer loss corresponding to each sample. The affine coupling layer loss is expressed as:
[0082]
[0083] Obtain the global constraint loss L corresponding to each sample. global Local constraint loss L local And based on the sample normalization layer loss L corresponding to each sample Actnorm Reversible transformation layer loss L Permutation Affine coupling layer loss L Affine Global constraint loss L global and local constraint loss L local Determine the model loss function L of the category difference constrained flow model. model And by minimizing the model loss function L model The parameters of the class difference constrained flow model are updated using gradient descent to obtain the target class difference constrained flow model corresponding to each binary sample subset. The model loss function for each binary sample subset is expressed as:
[0084] Formula 8: L model =L Actnorm +L Permutation +L Affine +L global +α*L local ,
[0085] in, x i Let f be the i-th sample in the binary sample subset, M be the number of samples in the binary sample subset, and f θ For the category difference constrained flow model, p z () Latent space data distribution, N(u) y ,∑ y ) indicates that the mean value corresponding to category y is u. y The sum and covariance matrix is ∑ y The normal distribution ω and b1 are the weights and offsets used to construct the linear classifier with local constraints, β is the regularization hyperparameter, and α is the hyperparameter that controls the weights of the local constraint loss.
[0086] Optionally, the second training module is further configured to:
[0087] Calculate the noise probability of each mapped sample in the binary mapping sample set, and denoise the binary sample set based on the noise probability of each mapped sample to obtain a denoised binary sample set;
[0088] The corresponding target class difference constraint flow model is trained and updated using the denoised sample subset corresponding to each fault type in the denoised binary sample set. The denoised sample subset is then input into the corresponding trained target class difference constraint flow model to obtain the denoised mapping dataset of the denoised binary sample set in the latent space. Each denoised mapping sample subset in the denoised mapping dataset includes a denoised minority class mapping dataset and a denoised majority class mapping dataset corresponding to the denoised minority class mapping dataset.
[0089] For each subset of denoised minority class mapping data, perform the following operations: determine the neighboring data of each denoised minority class mapping data in the subset, obtain new minority class mapping data based on each denoised minority class mapping data and its corresponding neighboring data, and obtain a new subset of denoised minority class mapping data based on each denoised minority class mapping data and its corresponding new minority class mapping data. new Represented as:
[0090] Formula 10: z new =z i +a*(z i,j -z i ),
[0091] Among them, z i For the i-th denoised minority class mapping data in the subset of denoised minority class mapping data, z i,j For z i The corresponding neighboring data, where 'a' is a random number between 0 and 1;
[0092] The initial classifier is trained using each subset of new denoised mapping samples in the two-class new denoised mapping sample set to obtain the target classifier corresponding to each subset of new denoised mapping samples. Each subset of new denoised mapping samples corresponds to a fault type, and each subset of new denoised mapping samples includes a subset of new denoised minority class mapping data and a subset of denoised majority class mapping data corresponding to that subset.
[0093] Optionally, the second training module is further configured to:
[0094] Calculate the probability that each mapped sample in each subset of the binary mapped sample set follows a latent space distribution, and the probability prod corresponding to the i-th mapped sample. i for:
[0095] Formula 11: prod i =log(p z (fθ (x i )|y=y i ))=log(N(f θ (x i )|u y ,Σ y ));
[0096] The probability of each mapped sample being noise is obtained by taking the inverse of the probability corresponding to each mapped sample;
[0097] Calculate the first quartile and the third quartile of the noise probability corresponding to each subset of mapped samples;
[0098] Based on the first quartile and the third quartile of the noise probability corresponding to each mapped sample subset, the noise data in the two-class sample set is determined;
[0099] The noisy data in the two-class sample set is removed from the two-class sample set to obtain the denoised two-class sample set.
[0100] Optionally, the classification module is further configured to: input the test sample into the target category difference constraint flow model corresponding to each fault type to obtain the mapping data of the test sample in the latent space corresponding to each fault type; input the mapping data corresponding to each fault type into the corresponding target classifier to obtain the probability that the test sample has each fault type; and determine the fault type corresponding to the maximum value among the probabilities that the test sample has each fault type as the target fault type.
[0101] According to a third aspect of this application, an electronic device is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor executes the computer program to implement the steps of the method described in any one of the first aspects above.
[0102] According to a fourth aspect of this application, a computer storage medium is provided, on which a computer program is stored, wherein the computer program, when executed by a processor, implements the steps of the method described in any one of the first aspects above.
[0103] Using the above technical solution, this application provides a method for classifying electricity meter faults. First, historical fault data of multiple electricity meters under multiple fault types are obtained as input datasets, and the input dataset is divided into two sample sets. Then, a class difference constraint flow model is established, and the class difference constraint flow model is trained using the subset of the two samples corresponding to each fault type, updating the parameters to obtain a target class difference constraint flow model for each fault type. Next, the subset of the two samples corresponding to each fault type is input into the corresponding target class difference constraint flow model to obtain a binary mapping sample set. Finally, an initial classifier is determined, and based on each fault in the binary mapping sample set… The initial classifier is trained using a subset of mapped samples corresponding to each fault type to obtain the target classifier for each fault type. Finally, test samples are obtained, and the target classifier determines the fault type corresponding to the test sample among multiple fault types based on the target class difference constraint flow model corresponding to each fault type. By using the trained class difference constraint flow model to map the data to the latent space, the distribution of similar data is reduced and the distribution of different classes of data is increased in the latent space. Then, the trained target classifier is used to classify the data in the latent space where the sample distribution is simpler and the classification difficulty is lower, thereby improving the accuracy of meter fault classification and thus improving fault handling efficiency.
[0104] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0105] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0106] Figure 1 A flowchart illustrating a method for classifying meter faults according to an embodiment of this application is shown;
[0107] Figure 2 This illustration shows a structural diagram of the category difference constraint flow model of a method for classifying meter faults provided in an embodiment of this application;
[0108] Figure 3 This illustration shows a schematic diagram of the nonlinear transformation in the affine coupling layer of a differential constraint flow model for classifying meter faults according to an embodiment of this application.
[0109] Figure 4A flowchart of Algorithm 1 of a method for classifying meter faults according to an embodiment of this application is shown;
[0110] Figure 5 A flowchart of Algorithm 2 of a method for classifying meter faults according to an embodiment of this application is shown;
[0111] Figure 6 A schematic diagram of the structure of a meter fault classification device provided in an embodiment of this application is shown;
[0112] Figure 7 A schematic diagram of the device structure of the electronic device provided in the embodiments of this application is shown. Detailed Implementation
[0113] Various embodiments and features of this application are described herein with reference to the accompanying drawings.
[0114] It should be understood that various modifications can be made to the embodiments described herein. Therefore, the above description should not be considered as limiting, but merely as an example of embodiments. Other modifications within the scope and spirit of this application will be apparent to those skilled in the art.
[0115] The accompanying drawings, which are included in and form part of this specification, illustrate embodiments of the present application and, together with the general description of the present application given above and the detailed description of the embodiments given below, serve to explain the principles of the present application.
[0116] These and other features of this application will become apparent from the following description of preferred forms of embodiments given as non-limiting examples, with reference to the accompanying drawings.
[0117] It should also be understood that although this application has been described with reference to some specific examples, those skilled in the art can certainly implement many other equivalent forms of this application.
[0118] The above and other aspects, features and advantages of this application will become more apparent when taken in conjunction with the accompanying drawings and in view of the following detailed description.
[0119] Specific embodiments of this application are described thereafter with reference to the accompanying drawings; however, it should be understood that the claimed embodiments are merely examples of this application, which can be implemented in various ways. Well-known and / or repeated functions and structures are not described in detail to avoid unnecessary or redundant details that could obscure the application. Therefore, the specific structural and functional details claimed herein are not intended to be limiting, but merely serve as the basis and representative basis for the claims to teach those skilled in the art to use this application in a variety of substantially any suitable detailed structures.
[0120] This specification may use the phrases “in one embodiment,” “in another embodiment,” “in yet another embodiment,” or “in other embodiments,” all of which may refer to one or more of the same or different embodiments according to this application.
[0121] Example 1
[0122] This application provides a method for classifying electricity meter faults, such as... Figure 1 As shown, the method includes:
[0123] 101. Obtain historical fault data of multiple meters under multiple fault types as input dataset, and divide the input dataset into two sample sets.
[0124] In this embodiment of the application, the two-type sample set includes a subset of two types of samples corresponding to each of the multiple fault types.
[0125] 102. Establish a category difference constrained flow model, and train the category difference constrained flow model using a subset of two types of samples corresponding to each fault type, update the parameters, and obtain the target category difference constrained flow model corresponding to each fault type.
[0126] 103. Input the binary sample subset corresponding to each fault type into the corresponding target category difference constraint flow model to obtain the binary mapping sample set.
[0127] 104. Determine the initial classifier, and train the initial classifier based on the subset of mapping samples corresponding to each fault type in the binary mapping sample set to obtain the target classifier corresponding to each fault type.
[0128] 105. Obtain test samples, and determine the fault type corresponding to the test samples from multiple fault types based on the target category difference constraint flow model and target classifier corresponding to each fault type.
[0129] The method provided in this application uses a trained class difference constrained flow model to map data to a latent space, thereby reducing the distribution of similar data and increasing the distribution of different data in the latent space. Then, a trained target classifier is used to classify the data in the latent space where the sample distribution is simpler and the classification difficulty is lower, thereby improving the accuracy of meter fault classification and thus improving fault handling efficiency.
[0130] This application provides a method for classifying electricity meter faults, which specifically includes:
[0131] 201. Obtain historical fault data of multiple meters under multiple fault types as input dataset, and divide the input dataset into two sample sets.
[0132] In this embodiment of the application, after obtaining the historical fault data of multiple meters under multiple fault types as the input dataset, each historical fault data in the input dataset is traversed to determine the minority class dataset and the majority class dataset corresponding to each fault type among the multiple fault types. The minority class dataset is the dataset corresponding to one fault type among the multiple fault types, and the majority class dataset is the dataset corresponding to other fault types among the multiple fault types besides the one fault type.
[0133] It should be noted that the fault history dataset is a dataset of actual meter faults, and this dataset is used as the input dataset. For example, the samples in this dataset contain nine feature variables: working hours, delivery batch number, power supply unit number, meter type, fault identification month, installation month, province, equipment specifications, communication method, and equipment identifier. Furthermore, its fault category labels include eleven categories: appearance fault, metering fault, storage unit fault, processing unit fault, display unit fault, control unit fault, power supply unit fault, communication unit fault, clock unit fault, other faults, and software faults. The fault history dataset is then transformed into eleven binary sample subsets within a binary sample set, which are described as follows:
[0134] Formula 1: X = [X min ,X maj ],
[0135] Where X is a binary sample set, and X = {x} i'}, x i' Let X be a subset of binary samples corresponding to the i'-th fault type in the binary sample set, where i' = 1, 2, ..., 11. min It is a minority class of data set, and X min ={x min,i'}, x min,i' Let X be the i'-th minority class subset in the total minority class dataset. maj For the majority class data set, and X maj ={x maj,i'}, x maj,i ' is the i-th subset of the majority class data in the total majority class data set.
[0136] 202. Establish a category difference constraint flow model.
[0137] In this embodiment of the application, the category difference constraint flow model consists of three modules, such as... Figure 2 As shown, these are the sample normalization layer, the reversible transformation layer, and the affine coupling layer, respectively. The sample normalization layer, the reversible transformation layer, and the affine coupling layer constitute one affine transformation. The flow model is composed of K affine transformations connected in sequence. For example, the sample feature dimension is n, and the fault type corresponding to each sample is y. iThe sample normalization layer, the reversible transformation layer, and the affine coupling layer are represented as follows:
[0138] The sample normalization layer uses a learnable scaling transformation s1 and a bias transformation b1 in each dimension. The transformation formula for each dimension is expressed as:
[0139] Formula 2: v1=s1⊙u1+b1,
[0140] Where u1 is the input sample of the sample standardization layer, v1 is the output data of the sample standardization layer, and ⊙ represents the multiplication of corresponding positions of the vector;
[0141] The reversible transformation layer transforms the samples after the sample standardization layer to improve the model's expressive power. The samples after the reversible transformation are represented as follows:
[0142] Formula 3: v2=Wu2,
[0143] Where W represents the initialized n×n-dimensional random matrix, u2 is the input sample of the invertible transformation layer, and v2 is the output data of the invertible transformation layer;
[0144] The affine coupling layer is used to divide the attributes of samples after the invertible transformation layer into two parts, and then uses a nonlinear transformation NN to modify a portion of the attributes u of the divided samples. 1:d The transformations are performed to obtain scaling transformation s2 and offset transformation b2, and another part of the attribute u of the partitioned sample is applied using scaling transformation s2 and offset transformation b2. d+1:n Perform affine transformation, scaling transformation s2, and offset transformation b2, and then apply the affine transformation to the feature u. d+1:n They are represented as follows:
[0145] Formula 4: s2,b2=NN(u 1:d ),
[0146] Formula 5: v d+1:n =s2⊙u d+1:n +b2,
[0147] Where 1:d represents the 1st to dth dimensions of the sample, d+1:n represents the (d+1)th to nth dimensions of the sample, and v d+1:n For the output data of the affine coupling layer, the Jacobian matrix of the affine transformation can be expressed as:
[0148]
[0149] Among them, I d Let d represent an identity matrix of dimension d×d, and diag(s) be a diagonal matrix with diagonal length s.
[0150] It should be noted that, as Figure 3As shown, in the class difference constrained flow model, ReLU is the neural network activation function, Linear is the fully connected layer construction function, Dropout is the random deactivation function, and the data partitioning layer divides a single sample into two parts based on the feature dimension. K represents the number of serially connected models, which is 4. The latent space distribution of the majority class is set to an n-dimensional normal distribution with a mean vector of 2 and a covariance matrix of the identity matrix; the latent space distribution of the minority class is set to an n-dimensional normal distribution with a mean vector of -2 and a covariance matrix of the identity matrix; the hyperparameter k controlling the noise removal ratio is 10. The structure of the nonlinear transformation in the affine coupling layer is as follows. Figure 4 As shown, d and nd represent that the data is divided into two parts with d and nd features before the affine transformation.
[0151] 203. Train the class difference constrained flow model using a subset of binary samples corresponding to each fault type, update the parameters, and obtain the target class difference constrained flow model for each fault type. The specific steps are as follows:
[0152] 2031. Input each sample from the binary sample subset corresponding to each fault type into Formula 2 to determine the sample standardization layer loss for each sample. The sample standardization layer loss is expressed as:
[0153]
[0154] Among them, s i This represents the i-th element of the vector;
[0155] 2032. Input the output data of the sample standardization layer as the input sample of the reversible transformation layer into Equation 3 to determine the reversible transformation layer loss for each sample. The reversible transformation layer loss is expressed as:
[0156] Formula 8: L Permutation = -log|det(W)|,
[0157] Where det() calculates the determinant of a matrix;
[0158] 2033. The output data of the reversible transformation layer is used as the input sample of the affine coupling layer and input into Equations 4 and 5 to determine the affine coupling layer loss corresponding to each sample. The affine coupling layer loss is expressed as:
[0159]
[0160] Obtain the global constraint loss L for each sample global Local constraint loss L local And based on the sample normalization layer loss L corresponding to each sample Actnorm Reversible transformation layer loss L PermutationAffine coupling layer loss L Affine Global constraint loss L global and local constraint loss L local Determine the model loss function L for the category difference constrained flow model model And by minimizing the model loss function L model The parameters of the class difference constrained flow model are updated using gradient descent to obtain the target class difference constrained flow model for each binary sample subset. The model loss function for each binary sample subset is expressed as:
[0161] Formula 10: L model =L Actnorm +L Permutation +L Affine +L global +α*L local ,
[0162] Specifically, samples are mapped to the latent space through a flow model, and the latent space distribution of data of the same fault type is constrained by adding global constraints from the category difference constraints. Based on the sample fault type y... i Calculate the probability that the sample follows the latent space distribution of this fault type, and the global constraint loss L. global It can be represented as:
[0163]
[0164] Where x i Let f be the i-th sample in the binary sample subset, M be the number of samples in the binary sample subset, and f θ For a class difference constrained flow model, p z () represents the latent space data distribution, N(u) y ,∑ y ) indicates that the mean value corresponding to category y is u. y The sum and covariance matrix is ∑ y It follows a normal distribution.
[0165] Furthermore, by using a single linear layer in a neural network to implement the global constraint in the class difference constraint, we can obtain the local constraint loss, which is expressed as:
[0166]
[0167] Where ω and b1 are the weights and biases of the linear classifier used to construct local constraints, β is the regularization hyperparameter, and α is the hyperparameter controlling the weights of the local constraint loss. The magnitude of the hyperparameter α is determined by the magnitude of each part of the loss, and the calculation formula is expressed as:
[0168]
[0169] in, It indicates the order of magnitude of the calculated data.
[0170] It should be noted that the algorithm 1 of the above-mentioned stream model training pseudocode is as follows: Figure 4 As shown, the input to Algorithm 1 is: training dataset D = (X, Y), where X is the set of data features, Y is the set of data category labels, the number of training iterations is numepoch, the dataset is divided into numbatch training batches, the number of early stopping iterations is t, the batch size is batchsize, and the latent space distribution is p. z (z), flow model, flow model parameters θ, flow model learning rate lr model Locally constrained linear classifier parameters Linear classifier model local Learning rate lr of linear classifier local The algorithm consists of: minimum learning rate (min_lr), local constraint weights (α), and learning rate decay (α_lr) for the streaming model. The output of Algorithm 1 is: latent space data z, (trained) streaming model model, and locally constrained linear classifier model. local .
[0171] 204. Determine the initial classifier and train it based on the subset of mapping samples corresponding to each fault type in the binary mapping sample set to obtain the target classifier for each fault type.
[0172] In this embodiment, the initial classifier is trained based on each subset of mapping samples in the binary mapping sample set to obtain the target classifier corresponding to each fault type. The specific steps are as follows:
[0173] 2041. Calculate the noise probability of each mapped sample in the binary mapping sample set, and denoise the binary sample set based on the noise probability of each mapped sample to obtain the denoised binary sample set. The specific steps are as follows:
[0174] 2041.1 Calculate the probability that each mapped sample in each subset of the binary mapped sample set follows a latent space distribution, and the probability prod corresponding to the i-th mapped sample. i for:
[0175] Formula 14: prod i =log(p z (f θ (x i )|y=y i ))=log(N(f θ (x i )|u y ,Σ y )).
[0176] 2041.2. Take the opposite of the probability corresponding to each mapped sample to obtain the probability that each mapped sample is noise.
[0177] Specifically, the higher the probability of the data, the more the sample follows the sample distribution of the corresponding category, that is, the lower the probability that the sample is noise. i Taking the opposite number gives the probability prod that the sample is noise. i _n i In other words, the larger the probability value, the greater the probability that the sample is noise.
[0178] 2041.3 Calculate the first and third quartiles of the noise probability corresponding to each subset of mapped samples.
[0179] Specifically, the first and third quartiles of the noise probability corresponding to each subset of mapped samples are calculated, denoted as Q. 1,min Q 3,min Q 1,maj Q 3,maj , where Q 1,min and Q 3,min Q represents the first and third quartiles of the noise probability of the minority class data. 1,maj and Q 3,maj These are the first and third quartiles of the noise probability for the majority class data. From this, the noise data for the majority and minority classes can be obtained separately, as follows:
[0180] Formula 15: X noisy,maj ={x i ∈X maj |prod_n i Q 3,maj +k*(Q 3,maj -Q 1,maj )},
[0181] Formula 16: X noisy,min ={x i ∈X min |prod_n i Q 3,min +k*(Q 3,min -Q 1,min )},
[0182] Where k is a hyperparameter that controls the proportion of noise removed.
[0183] 2041.4. Based on the first and third quartiles of the noise probability corresponding to each mapped sample subset, determine the noise data in the second-class sample set.
[0184] Specifically, based on the first quartile and the third quartile of the noise probability corresponding to each mapped sample subset, the noise data in each binary sample subset is determined, and thus the noise data in the binary sample subset is determined.
[0185] 2041.5. Remove the noisy data from the second-class sample set to obtain the denoised second-class sample set.
[0186] 2042. Train the corresponding target class difference constraint flow model using the denoised sample subset corresponding to each fault type in the denoised binary sample set, update the parameters, and input each denoised sample subset in the denoised binary sample set into the corresponding trained target class difference constraint flow model to obtain the denoised mapping dataset of the denoised binary sample set in the latent space. Each denoised mapping sample subset in the denoised mapping dataset includes a denoised minority class mapping data subset and a denoised majority class mapping data subset corresponding to the denoised minority class mapping data subset.
[0187] Specifically, the target class difference constraint flow model is trained using each subset of denoised samples in the denoised binary sample set, and the optimization objective is:
[0188] Formula 17:minL model =min(L Actnorm +L Permutation +L Affine +L global +α*L local ).
[0189] Furthermore, after training, the mapped data obtained using the streaming model can be represented as:
[0190] Formula 18: z i =f θ (x i ).
[0191] Among them, z i For the mapping data of sample data in the latent space, z i ∈Z, where Z is the mapping dataset of the original samples in the latent space.
[0192] 2043. For each subset of denoised minority class mapping data, perform the following operations: determine the neighboring data of each denoised minority class mapping data in the subset, and obtain new minority class mapping data based on each denoised minority class mapping data and its corresponding neighboring data; and obtain a new subset of denoised minority class mapping data based on each denoised minority class mapping data and its corresponding new minority class mapping data. new Represented as:
[0193] Formula 14: znew =z i +a*(z i,j -z i ),
[0194] Among them, z i For the i-th denoised minority class mapping data in the subset of denoised minority class mapping data, z i,j For z i The corresponding neighboring data, where 'a' is a random number between 0 and 1;
[0195] 2044. Train the initial classifier using each subset of new denoised mapping samples in the two-class new denoised mapping sample set to obtain the target classifier corresponding to each subset of new denoised mapping samples. Each subset of new denoised mapping samples corresponds to a fault type, and each subset of new denoised mapping samples includes a subset of new denoised minority class mapping data and a subset of denoised majority class mapping data corresponding to the subset of new denoised minority class mapping data.
[0196] It should be noted that the algorithm 2 of the above-mentioned stream model training pseudocode is as follows: Figure 5 As shown, the input to Algorithm 2 is: training dataset D = (X, Y), where X is the set of data features, Y is the set of data category labels, pre-training times numepoch1, training times numepoch2, the dataset is divided into numbatch training batches, the number of early stopping training times t, the batch size, the latent space distribution pz(z), the streaming model model, the streaming model parameters θ, and the parameters of the locally constrained linear classifier. Local constraint weights α, flow model learning rate lr model Linear classifier model local Learning rate lr of linear classifier local The minimum learning rate is min_lr, the learning rate decay for the streaming model is α_lr, and the weight k controls the proportion of noise removal. The output of Algorithm 2 is: a balanced dataset D. balanced .
[0197] 205. Obtain test samples, and determine the fault type corresponding to the test samples from the multiple fault types based on the target category difference constraint flow model and target classifier corresponding to each fault type. The specific steps are as follows:
[0198] 2051. Input the test samples into the target category difference constraint flow model corresponding to each fault type to obtain the mapping data of the test samples in the latent space corresponding to each fault type.
[0199] Specifically, for test sample x testThe target category difference constraint flow model corresponding to each fault type is used to map the data, and the mapping data z of the test samples in the latent space corresponding to each fault type is obtained. testi .
[0200] 2052. Input the mapping data corresponding to each fault type into the corresponding target classifier to obtain the probability that the test sample has each fault type;
[0201] Specifically, each mapping data z test,i Input into the corresponding target classifier i The probability that the test sample is a type i fault is obtained. Among them, classifier i The subscript indicates that the classifier is trained using the i-th class as the minority class and the remaining classes as the majority class.
[0202] 2053. Determine the fault type corresponding to the maximum probability of each fault type in the test sample as the target fault type.
[0203] Specifically, for test sample x test Predicted labels The calculation is as follows:
[0204]
[0205] When the value is j, it represents the test sample x. test The predicted target fault category is the j-th fault category.
[0206] In this embodiment of the application, after obtaining the test sample, the test sample is input into the target category difference constraint flow model corresponding to each fault type to obtain the mapping data of the test sample in the latent space corresponding to each fault type. Then, the mapping data corresponding to each fault type is input into the corresponding target classifier to obtain the probability that the test sample has each fault type. Then, the fault type corresponding to the maximum value of the probability that the test sample has each fault type is determined as the target fault type.
[0207] The method provided in this application uses a trained class difference constrained flow model to map data to a latent space, thereby reducing the distribution of similar data and increasing the distribution of different data in the latent space. Then, a trained target classifier is used to classify the data in the latent space where the sample distribution is simpler and the classification difficulty is lower, thereby improving the accuracy of meter fault classification.
[0208] Example 2
[0209] This application provides a device for classifying electricity meter faults, such as... Figure 6As shown, it includes: a first acquisition module 501, a first training module 502, a second acquisition module 503, a second training module 504, and a classification module 505.
[0210] The first acquisition module 501 is used to acquire historical fault data of multiple meters under multiple fault types as input dataset, and divide the input dataset into two sample sets, wherein the two sample sets include a subset of two samples corresponding to each fault type among the multiple fault types;
[0211] The first training module 502 is used to establish a category difference constraint flow model, and to train the category difference constraint flow model using a subset of two types of samples corresponding to each fault type, update the parameters, and obtain the target category difference constraint flow model corresponding to each fault type.
[0212] The second acquisition module 503 is used to input the binary sample subset corresponding to each fault type into the corresponding target category difference constraint flow model to obtain the binary mapping sample set;
[0213] The second training module 504 is used to determine the initial classifier and train the initial classifier based on the subset of mapping samples corresponding to each fault type in the binary mapping sample set to obtain the target classifier corresponding to each fault type.
[0214] The classification module 505 is used to acquire test samples and, based on the target category difference constraint flow model and target classifier corresponding to each fault type, determine the fault type corresponding to the test sample among multiple fault types.
[0215] In specific application scenarios, the first acquisition module 501 is further configured to: traverse each historical fault data in the input dataset, determine the minority class data subset and the majority class data subset corresponding to each fault type among multiple fault types, wherein the minority class data subset is the dataset corresponding to one fault type among multiple fault types, and the majority class data subset is the dataset corresponding to other fault types among multiple fault types except for one fault type; and obtain a binary sample set based on the minority class data subset and the majority class data subset corresponding to each fault type among multiple fault types, wherein each binary sample subset in the binary sample set corresponds to one fault type.
[0216] In specific application scenarios, the first training module 502 is also used for:
[0217] Establish a class difference constrained flow model comprising a sample normalization layer, a reversible transformation layer, and an affine coupling layer; wherein,
[0218] The sample normalization layer is used to transform each dimension using a learnable scaling transformation s1 and an offset transformation b1. The transformation formula for each dimension is expressed as follows:
[0219] Formula 1: v1=s1⊙u1+b1,
[0220] Where u1 is the input sample of the sample standardization layer, v1 is the output data of the sample standardization layer, and ⊙ represents the multiplication of corresponding positions of the vector;
[0221] The reversible transformation layer is used to transform the samples after the sample standardization layer. The sample after the reversible transformation is represented as follows:
[0222] Formula 2: v2=Wu2,
[0223] Where W represents the initialized n×n-dimensional random matrix, u2 is the input sample of the invertible transformation layer, and v2 is the output data of the invertible transformation layer;
[0224] The affine coupling layer is used to divide the attributes of samples after the invertible transformation layer into two parts, and then uses a nonlinear transformation NN to modify a portion of the attributes u of the divided samples. 1:d The transformations are performed to obtain scaling transformation s2 and offset transformation b2, and another part of the attribute u of the partitioned sample is applied using scaling transformation s2 and offset transformation b2. d+1:n Perform affine transformation, scaling transformation s2, and offset transformation b2, and then apply the affine transformation to the feature u. d+1:n They are represented as follows:
[0225] Formula 3: s2,b2=NN(u 1:d ),
[0226] Formula 4: v d+1:n =s2⊙u d+1:n +b2,
[0227] Where 1:d represents the 1st to dth dimensions of the sample, d+1:n represents the (d+1)th to nth dimensions of the sample, and v d+1:n This is the output data of the affine coupling layer.
[0228] In specific application scenarios, the first training module 502 is also used for:
[0229] Input each sample from the binary sample subset corresponding to each fault type into Formula 1 to determine the sample standardization layer loss for each sample. The sample standardization layer loss is expressed as:
[0230]
[0231] Among them, s i This represents the i-th element of the vector;
[0232] The output data of the sample standardization layer is used as the input sample of the reversible transformation layer and input into Equation 2 to determine the reversible transformation layer loss for each sample. The reversible transformation layer loss is expressed as:
[0233] Formula 6: L Permutation = -log|det(W)|,
[0234] Where det() calculates the determinant of a matrix;
[0235] The output data of the reversible transformation layer is used as the input sample of the affine coupling layer and fed into Equations 3 and 4 to determine the affine coupling layer loss for each sample. The affine coupling layer loss is expressed as:
[0236]
[0237] Obtain the global constraint loss L for each sample global Local constraint loss L local And based on the sample normalization layer loss L corresponding to each sample Actnorm Reversible transformation layer loss L Permutation Affine coupling layer loss L Affine Global constraint loss L global and local constraint loss L local Determine the model loss function L for the category difference constrained flow model model And by minimizing the model loss function L model The parameters of the class difference constrained flow model are updated using gradient descent to obtain the target class difference constrained flow model for each binary sample subset. The model loss function for each binary sample subset is expressed as:
[0238] Formula 8: L model =L Actnorm +L Permutation +L Affine +L global +α*L local ,
[0239] in, x i Let f be the i-th sample in the binary sample subset, M be the number of samples in the binary sample subset, and f θ For a class difference constrained flow model, p z () Latent space data distribution, N(u) y ,∑ y ) indicates that the mean value corresponding to category y is u. y The sum and covariance matrix is ∑ y The normal distribution ω and b1 are the weights and offsets used to construct the linear classifier with local constraints, β is the regularization hyperparameter, and α is the hyperparameter that controls the weights of the local constraint loss.
[0240] In specific application scenarios, this second training module 504 is also used for:
[0241] Calculate the noise probability of each mapped sample in the binary mapping sample set, and denoise the binary sample set based on the noise probability of each mapped sample to obtain a denoised binary sample set;
[0242] The corresponding target class difference constraint flow model is trained and updated using the denoised sample subset corresponding to each fault type in the denoised binary sample set. The denoised sample subset is then input into the corresponding trained target class difference constraint flow model to obtain the denoised mapping dataset of the denoised binary sample set in the latent space. Each denoised mapping sample subset in the denoised mapping dataset includes a denoised minority class mapping data subset and a denoised majority class mapping data subset corresponding to the denoised minority class mapping data subset.
[0243] For each subset of denoised minority class mapping data, perform the following operations: determine the neighboring data of each denoised minority class mapping data in the subset, obtain new minority class mapping data based on each denoised minority class mapping data and its corresponding neighboring data, and obtain a new subset of denoised minority class mapping data based on each denoised minority class mapping data and its corresponding new minority class mapping data. new Represented as:
[0244] Formula 10: z new =z i +a*(z i,j -z i ),
[0245] Among them, z i For the i-th denoised minority class mapping data in the subset of denoised minority class mapping data, z i,j For z i The corresponding neighboring data, where 'a' is a random number between 0 and 1;
[0246] The initial classifier is trained using each subset of new denoised mapping samples in the two-class new denoised mapping sample set to obtain the target classifier corresponding to each subset of new denoised mapping samples. Each subset of new denoised mapping samples corresponds to a fault type, and each subset of new denoised mapping samples includes a subset of new denoised minority class mapping data and a subset of denoised majority class mapping data corresponding to the subset of new denoised minority class mapping data.
[0247] In specific application scenarios, this second training module 504 is also used for:
[0248] Calculate the probability that each mapped sample in each subset of the binary mapped sample set follows a latent space distribution, and the probability prod corresponding to the i-th mapped sample. i for:
[0249] Formula 11: prod i =log(p z (f θ (x i )|y=y i ))=log(N(f θ (x i )|u y ,∑ y ));
[0250] By taking the inverse of the probability corresponding to each mapped sample, we obtain the probability that each mapped sample is noise;
[0251] Calculate the first and third quartiles of the noise probability for each subset of mapped samples;
[0252] Based on the first and third quartiles of the noise probability corresponding to each subset of mapped samples, the noise data in the two-class sample set is determined.
[0253] The noisy data in the second-class sample set is removed to obtain the denoised second-class sample set;
[0254] In specific application scenarios, the classification module 505 is also used to: input test samples into the target category difference constraint flow model corresponding to each fault type to obtain the mapping data of the test samples in the latent space corresponding to each fault type; input the mapping data corresponding to each fault type into the corresponding target classifier to obtain the probability that the test sample has each fault type; and determine the fault type corresponding to the maximum value of the probability that the test sample has each fault type as the target fault type.
[0255] The apparatus provided in this application uses a trained class difference constrained flow model to map data to a latent space, thereby reducing the distribution of similar data and increasing the distribution of different types of data in the latent space. Then, a trained target classifier is used to classify the data in the latent space where the sample distribution is simpler and the classification difficulty is lower, thereby improving the accuracy of meter fault classification.
[0256] Example 3
[0257] This application also provides an electronic device, such as... Figure 7As shown, the electronic device includes a bus, a processor, a memory, and a communication interface. It may also include input / output interfaces and a display device. The various functional units can communicate with each other via the bus. The memory stores computer programs, and the processor executes the programs stored in the memory, performing the meter fault classification method described in the above embodiment.
[0258] Example 4
[0259] This application embodiment also provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the method for classifying meter faults.
[0260] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented in hardware or by using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) and includes several instructions to cause a computer device (such as a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0261] The above embodiments are merely exemplary embodiments of this application and are not intended to limit this application. The scope of protection of this application is defined by the claims. Those skilled in the art can make various modifications or equivalent substitutions to this application within its substance and scope of protection, and such modifications or equivalent substitutions should also be considered to fall within the scope of protection of this application.
Claims
1. A method for classifying electricity meter faults, characterized in that, include: The historical fault data of multiple meters under multiple fault types are obtained as input datasets, and the input datasets are divided into two sample sets, wherein the two sample sets include the two sample subsets corresponding to each of the multiple fault types; A category difference constrained flow model is established, and the model is trained using a subset of binary samples corresponding to each fault type. The parameters are then updated to obtain the target category difference constrained flow model for each fault type. This process includes: establishing a category difference constrained flow model comprising a sample normalization layer, a reversible transformation layer, and an affine coupling layer; wherein the sample normalization layer is used to apply a learnable scaling transformation in each dimension. s 1 and offset transformation b 1. Perform a transformation, and the transformation formula for each dimension is expressed as: Formula 1: , in, The input samples for the sample normalization layer, The output data of the sample normalization layer, This indicates that corresponding positions of the vectors are multiplied; the reversible transformation layer is used to transform the samples after the sample standardization layer, and the samples after the reversible transformation are represented as follows: Formula 2: , in, Indicates initialization 3D random matrix, The input samples of the reversible transform layer are... The output data of the reversible transformation layer; the affine coupling layer is used to divide the attributes of the sample after the reversible transformation layer into two parts, and to perform a nonlinear transformation. NN A subset of attributes of the split samples The transformations are performed to obtain scaling transformation s2 and offset transformation b2, as well as another part of the attributes of the partitioned samples using scaling transformation s2 and offset transformation b2. Perform an affine transformation, including the scaling transformation s2 and the offset transformation b2, and the features after the affine transformation. They are represented as follows: Formula 3: Formula 4: , in, Indicates the first to last sample d dimensional features, Indicates the sample number d +1 to n dimensional features, The output data of the affine coupling layer; each sample in the binary sample subset corresponding to each fault type is input into Formula 1 to determine the sample standardization layer loss corresponding to each sample, wherein the sample standardization layer loss is expressed as: Formula 5: , in, Represents the vector of the first i Each sample has one element; the output data of the sample standardization layer is used as the input sample of the reversible transformation layer and input into Formula 2 to determine the reversible transformation layer loss corresponding to each sample. The reversible transformation layer loss is expressed as: Formula 6: , in, The matrix determinant is calculated; the output data of the invertible transformation layer is used as the input sample of the affine coupling layer and input into formulas 3 and 4 to determine the affine coupling layer loss corresponding to each sample. The affine coupling layer loss is expressed as: Formula 7: ; Obtain the global constraint loss corresponding to each sample. Local constraint loss And based on the sample normalization layer loss corresponding to each sample. Reversible transformation layer loss Affine coupling layer loss Global constraint loss and local constraint loss Determine the model loss function of the category difference constrained flow model. and by minimizing the model loss function The parameters of the class difference constrained flow model are updated using gradient descent to obtain the target class difference constrained flow model corresponding to each binary sample subset. The model loss function for each binary sample subset is expressed as: Formula 8: , in, , For the second type of sample subset, the first i There are M samples, where M is the number of samples in the subset of the two types of samples. For the category difference constrained flow model, Latent space data distribution This indicates that the mean value corresponding to category y is The sum and covariance matrix are The normal distribution , and These are the weights and biases used to construct a linear classifier with local constraints. For regularization hyperparameters, The hyperparameters are used to control the weights of the local constraint loss, and the hyperparameters are... The magnitude is determined by the magnitude of the loss in each part, and the calculation formula is expressed as: , in, Indicates the order of magnitude of the calculated data; The binary sample subset corresponding to each fault type is input into the corresponding target category difference constraint flow model to obtain the binary mapping sample set; An initial classifier is determined, and the initial classifier is trained based on a subset of mapping samples corresponding to each fault type in the binary mapping sample set to obtain a target classifier for each fault type. Obtain test samples, and determine the fault type corresponding to the test samples among the multiple fault types based on the target category difference constraint flow model and target classifier corresponding to each fault type.
2. The method for classifying meter faults according to claim 1, characterized in that, The step of dividing the input dataset into two sample sets includes: Traverse each historical fault data in the input dataset to determine the minority class data subset and the majority class data subset corresponding to each fault type among the multiple fault types. The minority class data subset is the dataset corresponding to one fault type among the multiple fault types, and the majority class data subset is the dataset corresponding to other fault types among the multiple fault types except for the one fault type. The binary sample set is obtained based on the minority class data subset and the majority class data subset corresponding to each of the multiple fault types, wherein each binary sample subset in the binary sample set corresponds to a fault type.
3. The method for classifying meter faults according to claim 1, characterized in that, The step of training the initial classifier based on a subset of mapping samples corresponding to each fault type in the binary mapping sample set to obtain the target classifier corresponding to each fault type includes: Calculate the noise probability of each mapped sample in the binary mapping sample set, and denoise the binary sample set based on the noise probability of each mapped sample to obtain a denoised binary sample set; The corresponding target class difference constraint flow model is trained and updated using the denoised sample subset corresponding to each fault type in the denoised binary sample set. The denoised sample subset is then input into the corresponding trained target class difference constraint flow model to obtain the denoised mapping dataset of the denoised binary sample set in the latent space. Each denoised mapping sample subset in the denoised mapping dataset includes a denoised minority class mapping data subset and a denoised majority class mapping data subset corresponding to the denoised minority class mapping data subset. For each subset of denoised minority class mapping data, perform the following operations: determine the neighboring data of each denoised minority class mapping data in the subset, obtain new minority class mapping data based on each denoised minority class mapping data and its corresponding neighboring data, and obtain a new subset of denoised minority class mapping data based on each denoised minority class mapping data and its corresponding new minority class mapping data. Represented as: Formula 10: , in, For the denoised minority class mapping data subset, the first i Denoising minority class mapping data for Corresponding neighboring data, A random number between 0 and 1; The initial classifier is trained using each new denoised mapping sample subset to obtain the target classifier corresponding to each new denoised mapping sample subset. Each new denoised mapping sample subset corresponds to a fault type, and each new denoised mapping sample subset includes a new denoised minority class mapping data subset and a denoised majority class mapping data subset corresponding to the new denoised minority class mapping data subset.
4. The method for classifying meter faults according to claim 3, characterized in that, The step of calculating the noise probability of each mapped sample in the binary mapping sample set and denoising the binary sample set based on the noise probability of each mapped sample to obtain a denoised binary sample set includes: Calculate the probability that each mapped sample in each subset of the binary mapped sample set follows a latent space distribution. i The probability corresponding to each mapped sample for: Formula 11: ; The probability of each mapped sample being noise is obtained by taking the inverse of the probability corresponding to each mapped sample; Calculate the first quartile and the third quartile of the noise probability corresponding to each subset of mapped samples; Based on the first quartile and the third quartile of the noise probability corresponding to each mapped sample subset, the noise data in the two-class sample set is determined; The noisy data in the two-class sample set is removed from the two-class sample set to obtain the denoised two-class sample set.
5. The method for classifying meter faults according to claim 1, characterized in that, The step of determining the fault type corresponding to the test sample from among the multiple fault types based on the target category difference constraint flow model and target classifier corresponding to each fault type includes: The test samples are input into the target category difference constraint flow model corresponding to each fault type to obtain the mapping data of the test samples in the latent space corresponding to each fault type. The mapping data corresponding to each fault type is input into the corresponding target classifier to obtain the probability that the test sample has each fault type; The fault type corresponding to the maximum probability of the test sample having each fault type is determined as the target fault type.
6. A device for classifying meter malfunctions, characterized in that, The classification method applicable to claim 1 includes: The first acquisition module is used to acquire historical fault data of multiple meters under multiple fault types as input dataset, and divide the input dataset into two sample sets, wherein the two sample sets include a subset of two samples corresponding to each fault type among the multiple fault types. The first training module is used to establish a category difference constrained flow model, and to train the category difference constrained flow model using a subset of two types of samples corresponding to each fault type, update the parameters, and obtain the target category difference constrained flow model corresponding to each fault type. The second acquisition module is used to input the binary sample subset corresponding to each fault type into the corresponding target category difference constraint flow model to obtain a binary mapping sample set; The second training module is used to determine an initial classifier and train the initial classifier based on a subset of mapping samples corresponding to each fault type in the binary mapping sample set to obtain a target classifier corresponding to each fault type. The classification module is used to acquire test samples and, based on the target category difference constraint flow model and target classifier corresponding to each fault type, determine the fault type corresponding to the test sample among the multiple fault types.
7. An electronic device comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.
8. A computer storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Controllable automobile image synthesis method based on causal flow model
CN112102156A
Intelligent electric meter fault classification method based on neighbor sample pair construction
CN114722940A