Power grid anomaly detection method and device, electric energy meter and storage medium
By preprocessing and dynamically weighting the multi-source detection data of the power grid, the problems of low accuracy and poor adaptability of power grid anomaly detection are solved, and efficient identification and accurate response to power grid anomaly types are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHIJIAZHUANG KE ELECTRIC
- Filing Date
- 2026-04-21
- Publication Date
- 2026-07-14
Smart Images

Figure CN122385992A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of power grid anomaly detection technology, and more specifically, relates to a power grid anomaly detection method and device, an electricity meter, and a storage medium. Background Technology
[0002] In traditional power grid anomaly detection methods, electricity meters typically rely on logical rules based on single electrical parameters or fixed thresholds to determine abnormal states such as electricity theft and leakage. However, actual power grid operating conditions are complex and variable, with significant differences in electrical characteristics across different distribution areas and load types. Fixed models struggle to track these dynamic changes in real time, resulting in low detection accuracy and a tendency to generate false alarms or missed alarms under atypical conditions. Furthermore, existing methods lack the ability to adaptively fuse different types of anomaly features, failing to flexibly adjust detection strategies based on real-time power grid conditions. This severely restricts the robustness and scenario adaptability of anomaly identification. Therefore, improving the accuracy and scenario adaptability of anomaly detection has become a core issue that urgently needs to be addressed in the field of smart grid monitoring. Summary of the Invention
[0003] This application provides a power grid anomaly detection method and device, an energy meter, and a storage medium to solve the problems of low accuracy and poor adaptability of existing power grid anomaly detection methods, thereby achieving the goal of improving anomaly detection accuracy and adaptability.
[0004] To achieve the above objectives, the technical solutions provided in this application are as follows: Firstly, a method for detecting power grid anomalies is provided, executed by an electricity meter, including: Acquire the first multi-source detection data of the power grid within the current detection time window, and preprocess the first multi-source detection data to obtain a time-series dataset; the first multi-source detection data includes the voltage data, current data, active power, power factor and harmonic content of the power grid; Local feature extraction is performed on the time-series dataset to obtain local feature vectors; time-series feature extraction is performed on the time-series dataset to obtain time-series feature vectors. Acquire the second multi-source detection data of the power grid within the current detection time window. The second multi-source detection data includes the three-phase imbalance of the power grid, power mutation rate, residual current ratio, and harmonic distortion rate. The initial weights corresponding to the local feature vector and the temporal feature vector are obtained respectively, and the initial weights corresponding to the local feature vector and the temporal feature vector are corrected based on the second multi-source detection data to obtain their respective target weights; A fused feature vector is obtained by fusing local feature vectors and temporal feature vectors with their respective target weights. Based on the fused feature vector, the current power grid is identified as having anomaly types, thus obtaining the anomaly type corresponding to the current power grid.
[0005] Secondly, a power grid anomaly detection device is provided, installed in an electricity meter, comprising: The first data acquisition module is used to acquire the first multi-source detection data of the power grid within the current detection time window, and to preprocess the first multi-source detection data to obtain a time-series dataset; the first multi-source detection data includes the voltage data, current data, active power, power factor and harmonic content of the power grid; The feature extraction module is used to extract local features from the time-series dataset to obtain local feature vectors; and to extract time-series features from the time-series dataset to obtain time-series feature vectors. The second data acquisition module is used to acquire the second multi-source detection data of the power grid within the current detection time window. The second multi-source detection data includes the three-phase imbalance of the power grid, the power mutation rate, the residual current ratio, and the harmonic distortion rate. The weight calculation module is used to obtain the initial weights corresponding to the local feature vector and the temporal feature vector respectively, and to correct the initial weights corresponding to the local feature vector and the temporal feature vector respectively based on the second multi-source detection data to obtain their respective target weights; The feature fusion module is used to fuse local feature vectors and temporal feature vectors with their respective target weights to obtain a fused feature vector. The anomaly detection module is used to identify the anomaly type of the current power grid based on the fused feature vector, and obtain the anomaly type corresponding to the current power grid.
[0006] Thirdly, embodiments of this application also provide an electricity meter, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the power grid anomaly detection method provided in any possible implementation of the first aspect.
[0007] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the power grid anomaly detection method provided by any possible implementation of the first aspect.
[0008] The beneficial effects of the technical solution provided in this application are as follows: Compared with related technologies, the power grid anomaly detection method, device, electricity meter, and storage medium provided in this application embodiment obtain a time-series dataset by preprocessing the first multi-source detection data, eliminating missing data, anomalies, and dimensional differences in the original data, thus providing high-quality input for subsequent feature extraction. Secondly, local feature vectors and time-series feature vectors are extracted separately, and the initial weights of the local and time-series feature vectors are dynamically corrected based on the real-time acquired second multi-source detection data. This correction mechanism can calculate appropriate weight correction values in real time according to changes in the current power grid operating conditions, preventing feature weights from becoming fixed. This effectively overcomes the defect of fixed weights failing under different distribution areas and load types, significantly improving the adaptability and robustness of the detection model.
[0009] Furthermore, in this embodiment, the modified target weights are used to perform weighted fusion of local feature vectors and temporal feature vectors. Compared to simple concatenation or single feature determination, this dynamic weighted fusion method can more scientifically balance the contributions of the two types of features to the recognition result, generating a more comprehensive fused feature vector.
[0010] Therefore, the embodiments of this application fundamentally solve the problems of low accuracy and poor adaptability to working conditions in the prior art through the synergistic effect of dynamic weight correction and weighted fusion, relying on local execution of the electricity meter to balance real-time performance and detection accuracy. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.
[0012] Figure 1 A schematic flowchart illustrating the power grid anomaly detection method provided in this application embodiment; Figure 2 This is a structural block diagram of the power grid anomaly detection device provided in the embodiments of this application; Figure 3 A schematic block diagram of an electricity meter provided in an embodiment of this application. Detailed Implementation
[0013] The embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions of the embodiments of this application.
[0014] Those skilled in the art will understand that, unless otherwise stated, the singular forms “a,” “an,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this application mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term; for example, “A and / or B” can be implemented as “A,” or as “B,” or as “A and B.” When describing multiple (two or more) items, if the relationship between the multiple items is not explicitly defined, the multiple items can refer to one, several or all of the multiple items. For example, the description of "parameter A includes A1, A2, A3" can be implemented as parameter A includes A1 or A2 or A3, or it can be implemented as parameter A includes at least two of the three items A1, A2 and A3.
[0015] This application provides a method for detecting power grid anomalies, which can be executed by an electricity meter, such as... Figure 1 As shown, the method may include: S101: Obtain the first multi-source detection data of the power grid within the current detection time window, and preprocess the first multi-source detection data to obtain a time series dataset; the first multi-source detection data includes the voltage data, current data, active power, power factor and harmonic content of the power grid.
[0016] In this embodiment, the electricity meter is a device that performs the power grid anomaly detection method. It can adopt a dual-core isolation architecture of metering core and management core. The metering core is responsible for collecting power grid detection data, while the management core is used to perform algorithms such as data preprocessing, feature extraction, weight correction, feature fusion, and anomaly identification.
[0017] The current detection time window is used to divide the time interval for power grid data acquisition and analysis. Specifically, it is set to 10 minutes / window, and a single window contains 120 data points (adapted to an acquisition frequency of 1 time / 5 seconds).
[0018] The first multi-source detection data is the basic monitoring data of the power grid operation status. Specifically, it includes the voltage data (three-phase voltage), current data (three-phase current), active power (total active power), power factor, and harmonic content (5th harmonic content and 7th harmonic content). The data is transmitted after 16-bit AD conversion and CRC-16 verification to ensure data integrity. It is the data source for subsequent preprocessing and feature extraction.
[0019] Preprocessing is a step of standardizing the first multi-source detection data. Its purpose is to eliminate data noise, unify data units, and fill in missing information to ensure the data meets the model input requirements. Specifically, this includes linear interpolation imputation of missing values. The process involves four steps: outlier removal, min-max data standardization, and time-series data windowing reconstruction.
[0020] For missing values, linear interpolation is used, and the formula is as follows: ; in The missing data values obtained through interpolation. For the time points corresponding to the missing data, , These are the time points corresponding to the valid data adjacent to the missing time point, with an interval of ≤30 minutes. , Each is a time node , The corresponding valid data values; Outlier removal uses The criteria and formula are as follows: ; in It refers to the raw data value of a certain type of electrical parameter (such as single-phase voltage value, single-phase current value, or active power value) collected by the electricity meter at a single sampling time point. This is the average of historical data for this type of parameter over the past 24 hours. This represents the standard deviation of similar data over the past 24 hours. Data standardization uses min-max standardization, with the following formula: ; in To standardize the data and normalize it to the [0,1] interval, This is the minimum value of similar data over the past 30 days. This represents the maximum value of similar data over the past 30 days. The formula for reconstructing time-series data is: ; in For the i-th time series dataset, N=120 is the number of data points within a single detection time window (corresponding to a 10-minute window and a 5-second sampling rate). This represents the standardized data value at the i-th time point.
[0021] In this embodiment, the metering core of the electricity meter collects the first multi-source detection data within the current detection time window at a frequency of 1 time / 5 seconds. After 16-bit AD conversion and CRC-16 verification, the data is transmitted to the management core. The management core performs preprocessing on the first multi-source detection data (missing value interpolation, outlier removal, standardization, and time series reconstruction) to eliminate data noise and dimensional differences, and generate a standardized time series dataset to provide high-quality input for subsequent feature extraction.
[0022] S102: Perform local feature extraction on the time series dataset to obtain local feature vectors; perform time series feature extraction on the time series dataset to obtain time series feature vectors.
[0023] In this embodiment, local feature extraction is implemented using a convolutional neural network (CNN) to capture local abrupt changes in time series data (such as voltage / current abrupt changes, harmonic anomalies, etc.); time series feature extraction can be implemented using a long short-term memory (LSTM) network to capture long-term dependencies in time series data (such as the time series variation patterns of continuous electricity theft and gradual leakage).
[0024] Before detection, a fusion deep learning model needs to be pre-built and trained. The model consists of a CNN feature extraction layer (3 convolutional layers, 3×3 kernels, stride 1, number of units 32→64→128; 2 max pooling layers, 2×2 pooling kernels, stride 2), an LSTM temporal feature extraction layer (2 LSTM layers, 128 hidden units per layer), an adaptive dynamic weighted fusion layer, and a classification output layer (128 fully connected neurons + Softmax).
[0025] In this embodiment, the management chip calls a CNN network to extract local features from the time-series dataset, capturing local short-term features such as voltage / current surges and harmonic anomalies, and outputting local feature vectors; at the same time, it calls an LSTM network to extract time-series features from the same time-series dataset, capturing the long-term dependencies of the power grid's operating state (such as the time-series changes of continuous electricity theft), and outputting time-series feature vectors; the two types of features focus on short-term bursts and long-term persistence, respectively, to achieve comprehensive coverage of power grid features.
[0026] S103: Obtain the second multi-source detection data of the power grid within the current detection time window. The second multi-source detection data includes the three-phase imbalance of the power grid, power mutation rate, residual current ratio, and harmonic distortion rate.
[0027] In this embodiment, the second multi-source detection data is auxiliary monitoring data used to correct the feature weights, specifically including the three-phase imbalance of the power grid ( ), power mutation rate ( ), residual current ratio ( Harmonic distortion rate ( The data is collected synchronously with the first multi-source detection data. Its function is to reflect the abnormal scene characteristics of the current power grid and provide a basis for dynamic weight correction.
[0028] In this embodiment, the metering core synchronously collects the second multi-source detection data (three-phase imbalance, power mutation rate, etc.) within the current detection time window, and transmits it to the management core synchronously with the first multi-source detection data. This type of data directly reflects the abnormal scenarios of the current power grid (such as three-phase imbalance related to electricity theft, and residual current ratio related to leakage), and is the core basis for subsequent weight correction.
[0029] S104: Obtain the initial weights corresponding to the local feature vector and the temporal feature vector respectively, and correct the initial weights corresponding to the local feature vector and the temporal feature vector respectively based on the second multi-source detection data to obtain their respective target weights.
[0030] In this embodiment, the initial weights are the initial weights assigned to the local feature vector and the temporal feature vector. These weights can be determined offline through optimization using residential, industrial, commercial, and mixed multi-scenario electricity consumption samples. For example, the initial weight of the local feature vector is 0.55, and the initial weight of the temporal feature vector is 0.45, satisfying the normalization condition (the sum of the two is 1), which forms the basis for weight correction. The target weights are the final weights obtained after correcting the initial weights based on the second multi-source detection data. These include the target weights of the local feature vector and the target weights of the temporal feature vector, which can be adapted to the current abnormal power grid scenarios to ensure the rationality of feature fusion.
[0031] In one embodiment of this application, the initial weights corresponding to the local feature vector and the temporal feature vector are corrected based on the second multi-source detection data to obtain their respective target weights, including: Based on the second multi-source detection data, the weight correction values corresponding to the local feature vectors are obtained; The initial weights of the local feature vectors are corrected based on the weight correction values to obtain the target weights corresponding to the local feature vectors; Based on the target weights corresponding to the local feature vectors, the target weights corresponding to the time-series feature vectors are obtained.
[0032] In this embodiment, the weight correction value is a numerical value that represents the amount by which the initial weight of the local feature vector should be increased or decreased due to changes in the power grid state within the t-th detection time window.
[0033] In one embodiment of this application, obtaining the weight correction value corresponding to the local feature vector based on the second multi-source detection data includes: Based on the second multi-source detection data, and using the first formula, the weight correction value corresponding to the local feature vector is obtained; The first formula is: ; in, Let represent the weight correction value corresponding to the local feature vector within the t-th detection time window. This indicates the three-phase imbalance of the power grid. Indicates the power fluctuation rate of the power grid. This indicates the ratio of residual current in the power grid. Indicates the harmonic distortion rate of the power grid. , , and All of these represent correction factors.
[0034] In this embodiment, Three-phase unbalance is usually expressed as a percentage, and the calculation formula is (maximum phase current - minimum phase current) / maximum phase current × 100%; The power mutation rate, expressed as a percentage, is calculated as (current power - previous power) / previous power × 100%. The residual current ratio is expressed in milliamperes (mA) or as a ratio to the rated current. The harmonic distortion rate is expressed as a percentage and is calculated using the following formula: ,in The effective value of the nth harmonic; The correction coefficient is dimensionless and can be determined through experimental optimization, for example, by taking... These coefficients reflect the contribution of each electrical quantity to the weight adjustment.
[0035] In this embodiment, four key electrical quantities are used as independent variables, and a weighted sum is obtained through linear weighting. When a certain electrical quantity increases abnormally, the contribution of the corresponding term increases, causing the correction value to change in a positive or negative direction, thereby adjusting the weight of the local feature.
[0036] In one embodiment of this application, the initial weights of the local feature vectors are corrected based on the weight correction value to obtain the target weights corresponding to the local feature vectors; including: Based on the weight correction value, and by correcting the initial weights of the local feature vectors using the second formula, the target weights corresponding to the local feature vectors are obtained. The second formula is: ; in, This represents the target weight corresponding to the local feature vector within the t-th detection time window. Represents the initial weights of the local eigenvectors. This represents the weight correction value corresponding to the local feature vector within the t-th detection time window.
[0037] In this embodiment, the function Let be the amplitude limiting function, defined as: if Then return ;like Then return Otherwise, return X itself. In this formula, =0.3, =0.8.
[0038] In this embodiment, a limiting function is used to ensure that the target weight of local features is not lower than 0.3 (therefore the weight of temporal features is not higher than 0.7) and not higher than 0.8 (therefore the weight of temporal features is not lower than 0.2). This prevents a certain feature from being completely ignored or over-amplified under extreme data conditions, ensuring the balance of the fused features.
[0039] The target weights corresponding to the local feature vectors are obtained by subtracting them from the target weights corresponding to the time-series feature vectors, based on the constraint that the sum of the weights of the two types of features is 1. , is the target weight corresponding to the temporal feature vector within the t-th detection time window.
[0040] In this embodiment, by utilizing the mathematical normalization constraint (summing to 1), one weight can be directly derived after determining another weight, thus avoiding the non-normalization problem that may result from individually modifying the two weights.
[0041] In this embodiment, the initial weights of the local feature vector and the time-series feature vector obtained through offline optimization of residential, industrial and commercial, and mixed multi-scenario applications are first adopted, and the two satisfy the normalization condition that the sum is 1. Then, based on four key electrical quantities—three-phase imbalance, power mutation rate, residual current ratio, and harmonic distortion rate—the weight correction value of the local feature vector is calculated by linear weighted summation. After superimposing the initial weights and correction values, the target weight of the local feature vector is obtained by applying a limiting function constraint in the range of 0.3-0.8. Finally, based on the normalization constraint that the weight sum is 1, the target weight of the time-series feature vector is directly calculated by subtraction, which dynamically adapts to abnormal power grid conditions throughout the process, ensuring balanced feature fusion and efficient computation.
[0042] As can be seen from the above, this embodiment calculates the weight correction value by linearly weighting four key electrical quantities, which can accurately match the characteristics of the current abnormal power grid operating conditions, allowing the adjustment of local feature weights to conform to the actual operating state, significantly improving the pertinence and adaptability of weight correction; and using a limiting function to constrain the target weight of local features to 0.3. The 0.8 range effectively avoids the over-amplification or complete neglect of a single feature, ensuring the balance and stability of the fusion of local and temporal features. Relying on the normalization constraint that the sum of the weights of the two types of features is 1, the target weight of the temporal feature is directly derived by subtraction, avoiding the non-normalization problem caused by individually correcting the dual weights, simplifying the calculation logic and improving the computational efficiency. The overall dynamic weight correction mechanism is adapted to the embedded deployment environment of the energy meter, ensuring the accuracy of feature fusion while taking into account the real-time performance of the algorithm, further improving the generalization ability and recognition accuracy of the anomaly detection model.
[0043] S105: Based on the fusion of local feature vectors and temporal feature vectors and their corresponding target weights, a fused feature vector is obtained.
[0044] In this embodiment, the fused feature vector is a comprehensive feature vector obtained by dynamically weighting and fusing local feature vectors, time-series feature vectors and their corresponding target weights. It is denoted as Ffusion and integrates the local mutation features and long-term time-series features of the power grid. It can comprehensively and accurately characterize the operating status of the power grid and provide core feature support for subsequent anomaly identification.
[0045] In this embodiment, the management chip performs weighted fusion of the local feature vector and the temporal feature vector according to the target weight to calculate the fused feature vector. , in To fuse feature vectors, The target weights are the corresponding local feature vectors. For local feature vectors, The target weights correspond to the time-series feature vectors. This is a time-series feature vector; it simultaneously contains both local abrupt changes and long-term time-series features of the power grid. Compared to a single feature, it can more comprehensively and accurately characterize the power grid's operating status and improve the accuracy of anomaly identification.
[0046] S106: Based on the fused feature vector, identify the anomaly type of the current power grid to obtain the anomaly type corresponding to the current power grid.
[0047] In one embodiment of this application, based on a fused feature vector, anomaly type identification is performed on the current power grid to obtain the anomaly type corresponding to the current power grid, including: The fused feature vector and the constructed weight matrix are linearly transformed, and the ReLU activation function is used to obtain the original scores of the current power grid's operating state belonging to each anomaly type; the weight matrix represents the mapping relationship parameters between each dimension of the fused feature vector and each anomaly type. Based on the original scores, and after normalization using the Softmax activation function, the probability values of the current power grid's operating state belonging to each anomaly type are obtained. The maximum value among the probability values of each anomaly type is obtained, and the maximum value is compared with the preset target anomaly threshold to obtain the comparison result. Based on the comparison result, the anomaly type of the current power grid is determined.
[0048] In this embodiment, the weight matrix is a 5-row × 128-column matrix, denoted as... Each row corresponds to an anomaly category (in the order: normal, electricity theft, leakage, overload, harmonics), and each column corresponds to one dimension of the fused feature vector. This matrix is automatically learned during model training using the Adam optimizer and cross-entropy loss, requiring no manual setting. Linear transformation refers to matrix multiplication. We obtain a 5-dimensional vector. The ReLU activation function is defined as follows: This is used to introduce nonlinearity. The original score refers to the 5-dimensional vector Z obtained after linear transformation and ReLU, where each component... This represents the original score by which the model determines that the current state belongs to the i-th class. The Softmax activation function converts the original score into a probability distribution, as shown in the formula. This makes all The probability value is between 0 and 1 and sums to 1. This indicates the probability that the current power grid belongs to the i-th type of anomaly (i=1 normal, 2 electricity theft, 3 leakage, 4 overload, 5 harmonics). The preset target anomaly threshold is a pre-set value (e.g., 0.95) used to determine whether the anomaly is valid. The comparison result refers to the logical conclusion obtained by comparing the maximum probability value with the threshold (e.g., greater than or equal to the threshold or less than the threshold).
[0049] In this embodiment, feature vectors are fused. (128-dimensional) input is fed into the fully connected layer for computation. ,in It is a 5-dimensional bias vector. Then, the Softmax is calculated to obtain... to .Pick .like The corresponding category is exception class (2-5) and Define the exception type; if (Normal) or If it is normal, then it is considered normal. The target anomaly threshold.
[0050] As can be seen from the above, the 5×128 weight matrix automatically learned by the model in this embodiment can accurately realize the feature mapping between fused features and five types of electricity consumption states. The introduction of nonlinear transformation by the ReLU activation function effectively improves the feature discrimination power and model expressive power. The original score is normalized to a standard probability distribution by the Softmax function, making the probability of each category quantified intuitively and the judgment basis clear. By selecting the maximum probability value and comparing it with the dynamic threshold, it can accurately distinguish between normal, electricity theft, leakage, overload, and harmonic anomaly types. Combined with the hierarchical judgment logic, it greatly reduces the risk of false alarms and missed alarms. The overall identification process is computationally efficient and the judgment is rigorous, which significantly improves the accuracy, robustness, and real-time performance of power grid anomaly identification and better adapts to the refined monitoring needs of smart grids in multiple scenarios.
[0051] In one embodiment of this application, the preset target anomaly threshold includes: a first anomaly threshold and a second anomaly threshold, wherein the first anomaly threshold is greater than the second anomaly threshold; The comparison results include suspected abnormalities and potential abnormalities; The maximum value is compared with a preset target anomaly threshold to obtain the comparison results, including: If the maximum value is greater than or equal to the first abnormal threshold, the current power grid is determined to be a suspected abnormality; If the maximum value is greater than or equal to the second abnormal threshold and less than the first abnormal threshold, the current power grid is determined to be a potential abnormality. The type of anomaly in the current power grid is determined based on the comparison results, including: In response to the comparison result being a suspected anomaly, the anomaly type corresponding to the maximum value is determined as the target anomaly type; The first multi-source detection data and the second multi-source detection data are filtered to obtain the target data that currently causes the target anomaly type; the target data contains at least one data from the first multi-source detection data and / or at least one data from the second multi-source detection data. The target data is compared with the corresponding preset reference value to determine the current anomaly type of the power grid; In response to a comparison result indicating a potential anomaly, retrieve the corresponding historical comparison results within multiple historical detection time windows that are consecutive to the current detection time window; If, up to the current detection time window, all historical comparison results are of the same anomaly type as the comparison results, and the number of consecutive counts of that anomaly type is greater than or equal to the preset number, then the target data will be compared with the corresponding preset reference value, and the anomaly type of the current power grid will be determined.
[0052] In this embodiment, the first anomaly threshold is a relatively high threshold (e.g., 0.95) used to determine high-confidence anomalies, and the second anomaly threshold is a relatively low threshold (e.g., 0.8) used to delineate suspicious areas. Suspected anomalies indicate that the model considers an anomaly to exist in the current window with a high degree of confidence and requires immediate handling. Potential anomalies indicate that there are signs of anomalies but the confidence level is not high enough and continuous observation is required. Target data refers to the electrical parameters most relevant to the determined anomaly type selected from the first and second multi-source detection data (e.g., focusing on three-phase current and imbalance when stealing electricity). Preset reference values are the empirical thresholds corresponding to various anomalies (e.g., electricity theft: three-phase imbalance ≥ 10%, power mutation rate ≥ 20%; leakage current: residual current ratio ≥ 30mA / rated current, etc.). Historical comparison results refer to the anomaly determination results of several consecutive time windows in the past. Preset number of times refers to the number of windows that need to be continuously monitored, which is 3 times in this embodiment.
[0053] In this embodiment, in specific implementation, if If the value is ≥0.95 (first threshold), it is judged as a suspected anomaly. The anomaly type corresponding to the suspected anomaly is taken as the target anomaly type, and the corresponding target data (such as data extracted during electricity theft) is extracted from the first multi-source detection data and the second multi-source detection data based on the target anomaly type. and The anomaly type is determined by comparing it with a preset reference value, and a detailed report is generated and uploaded to the terminal. If 0.8 ≤ If the value is less than 0.95, it is considered a potential anomaly. Instead of an immediate alarm, the anomaly type for that window is recorded. Monitoring of subsequent windows continues. If three consecutive windows are identified as the same type of potential anomaly, it is escalated to a valid anomaly. The combined target data from these three windows is extracted and compared with a preset reference value. An alarm is triggered after confirming the anomaly type. If any window is identified as a different anomaly or normal during this period, the counter is reset.
[0054] For example, the first abnormal threshold is a dynamically adjusted threshold. Its typical value range is 0.808-0.95; the second anomaly threshold is a fixed threshold of 0.8. The maximum probability value output by Softmax is... (in For the probability of electricity theft, This represents the probability of leakage current. For overload probability, The specific rule for comparing the harmonic probability with the two thresholds mentioned above is as follows: If ≥ If 0.8 ≤ < If so, the current power grid is determined to be a potential anomaly.
[0055] When a suspected anomaly is identified, the electricity meter directly determines the anomaly type corresponding to the maximum value as the target anomaly type. For example, if = and ≥ If so, the target anomaly type is electricity theft anomaly.
[0056] Subsequently, the electricity meter filters the first and second multi-source detection data to obtain the target data that currently causes the target anomaly type. The target data contains at least one piece of data from the first multi-source detection data and / or at least one piece of data from the second multi-source detection data. Specifically, the target data filtered according to different target anomaly types is as follows: If the target anomaly type is electricity theft, the target data includes: three-phase current value, three-phase unbalance U(t), total active power mutation rate M(t) and harmonic distortion rate THD(t) (used to eliminate harmonic interference).
[0057] If the target anomaly type is leakage current anomaly, the target data includes: residual current ratio. Three-phase voltage values and the rate of change of total active power.
[0058] If the target anomaly type is overload anomaly, the target data includes: three-phase current value, total active power and power factor.
[0059] If the target anomaly type is harmonic anomaly, the target data includes: 5th harmonic content, 7th harmonic content, and harmonic distortion rate (THD(t)). 、 Three-phase voltage and current values.
[0060] Then, the target data is compared with the corresponding preset reference values to ultimately determine the current power grid anomaly type. The preset reference values for each type of anomaly are as follows: Abnormal electricity theft: Three-phase current imbalance U(t) ≥ 10% U ( tThe total active power fluctuation rate (Tt) is ≥10%, and the total active power fluctuation rate (Tt) is ≥20%, accompanied by a sudden drop in the current of a certain phase (e.g., the current of phase A drops from the normal value of 5A to below 0.5A), while the harmonic distortion rate (THD(t)) shows no obvious abnormality (e.g., THD(t) <5%). The time segment characteristics are: 1 to 3 consecutive time windows (each window is 10 minutes, for a total of 10 to 30 minutes), and some sudden electricity theft scenarios may show a single window anomaly.
[0061] Leakage abnormality: residual current ratio ≥30mA / rated current (e.g., when the rated current is 100A, the residual current is ≥30mA), the three-phase voltage fluctuation does not exceed 5%, the total active power decreases slightly by 5%-10%, and there is no obvious current change. The time segment characteristics are: continuous for 2 or more time windows (≥20 minutes), showing a stable abnormality, without sudden fluctuations.
[0062] Overload anomaly: All three-phase currents rise simultaneously, exceeding 1.2 times or more of the rated current of the electricity meter, and the total active power rises synchronously and exceeds the rated power. Power factor is differentiated according to load type: power factor ≥ 0.95 for purely resistive loads under overload, and power factor ≤ 0.8 for inductive loads under overload. Timing segment characteristics: single or multiple consecutive time windows, possibly involving sudden starts (such as industrial equipment startup) or sustained overload.
[0063] Harmonic anomalies: 5th harmonic content ≥10% or 7th harmonic content ≥7% (exceeding national standard limits), harmonic distortion rate (THD(t)) ≥15%, no significant abrupt changes in three-phase voltage and current, and total active power basically stable (fluctuation ≤5%). Timing segment characteristics: lasting for one or more time windows, with stable anomaly characteristics and no significant timing fluctuations.
[0064] If the current target data meets all the preset reference values for the corresponding anomaly type, the anomaly type is finally confirmed; otherwise, it is determined to be a false alarm, and only the data is recorded without triggering an alarm.
[0065] Upon confirmation of an anomaly, the electricity meter immediately triggers a local audible and visual alarm at a frequency of once per second for 5 seconds. Simultaneously, the anomaly information is recorded in an encrypted EEPROM, including: anomaly type, occurrence time (accurate to the second), the corresponding time segment (e.g., "2026-03-17 14:30-14:40 window"), and the specific values of key characteristic indicators (e.g., "Phase A current drops sharply from 4.8A to 0.3A, three-phase imbalance 12.5%"). Subsequently, this information is uploaded to the power grid monitoring platform via an NB-IoT module (operating frequency 800MHz), with an upload cycle of no more than one minute. The communication module employs dual links of NB-IoT and RS-485, supporting not only alarm uploads but also remote model updates and the upload of anomaly time-series characteristics and segment data.
[0066] When a potential anomaly is detected, the electricity meter does not immediately trigger an alarm, but instead enters a continuous monitoring mode. Specifically, it acquires historical comparison results corresponding to multiple historical detection time windows consecutive to the current detection time window. In this embodiment, each time window is 10 minutes long, and the preset number of times is 3.
[0067] The electricity meter records the types of potential anomalies in the current window (e.g., potential electricity theft). It then continues monitoring subsequent windows: for each subsequent window, the same calculation is performed. And determine whether it falls on Within the interval, check whether the corresponding anomaly type is the same as the anomaly type recorded for the first time. If, up to the current detection time window, the historical comparison results for three consecutive time windows (a total of 30 minutes) are all the same as the anomaly type corresponding to the current comparison result, and the cumulative number of times this anomaly type occurs reaches three, then the potential anomaly is upgraded to a valid anomaly.
[0068] After the upgrade, the electricity meter extracts comprehensive target data from these three consecutive windows (such as the average three-phase imbalance, maximum power fluctuation rate, or median residual current ratio of the three windows), and compares the comprehensive target data with the preset reference values corresponding to the above-mentioned anomalies. If the preset reference values are met, the anomaly type is finally confirmed. At the same time, the time-series characteristics of the three windows are summarized, the anomaly change trend is marked (e.g., "three-phase imbalance gradually increases from 8% to 15%)", and a detailed report is generated. Subsequently, a local audible and visual alarm is triggered, recorded to an encrypted EEPROM, and uploaded via NB-IoT, the process being the same as for suspected anomalies.
[0069] If during continuous monitoring, any window If the value drops below 0.8 (i.e. below the second anomaly threshold), or if the anomaly type in any window is different from the type recorded initially, the counter is reset, the monitoring of this potential anomaly ends, only the monitoring process data is recorded, and no alarm is triggered.
[0070] When the probability of normal electricity consumption When the value is ≥0.9, it is considered to be in a normal state. The electricity meter only records the electricity consumption data, does not trigger any alarms, and does not perform any abnormality judgment process.
[0071] As can be seen from the above, this embodiment employs a dual-threshold hierarchical judgment mechanism consisting of a first anomaly threshold and a second anomaly threshold. This mechanism can clearly distinguish between high-confidence suspected anomalies and low-confidence potential anomalies, avoiding false alarms and missed alarms caused by a single threshold. Suspected anomalies are quickly confirmed by directly combining target data with preset reference values, ensuring timely and efficient anomaly response. Potential anomalies undergo continuous multi-window verification and cumulative counting, effectively filtering temporary fluctuations and interference data, and improving the reliability of anomaly judgment. By filtering target data and comparing it with preset reference values, the cause of anomalies can be accurately located. Overall, while ensuring detection sensitivity, this mechanism significantly improves the accuracy and reliability of anomaly identification, reduces the rate of operational errors, and meets the rigorous requirements of actual power grid operation and maintenance.
[0072] In one embodiment of this application, the method for determining the first abnormal threshold includes: The Youden index is determined based on the constructed ROC curve, and the maximum value of the Youden index is used as the first basic anomaly threshold. The ROC curve represents the mapping relationship between the true positive rate and the false positive rate of the current anomaly identification model when traversing different classification thresholds. Based on the preset weight coefficient mapping table, the first weight coefficient corresponding to the application area type of the electricity meter is obtained, and the second weight coefficient corresponding to the historical false alarm rate of the area type within the preset statistical period is obtained. Based on the first and second weighting coefficients, the comprehensive weighting coefficient is obtained; Based on the first basic anomaly threshold and the comprehensive weight coefficient, and through the fourth calculation formula, the first anomaly threshold is obtained; The fourth calculation formula is: ; in, Indicates the first abnormal threshold. This represents the first basic anomaly threshold. This represents the overall weighting coefficient. This represents the adjustment factor.
[0073] In this embodiment, the ROC curve is the receiver operating characteristic curve, and the horizontal axis represents the false positive rate (ROC). The vertical axis represents the true positive rate ( ), The steps for establishing a ROC curve are as follows: First, the trained fusion model is run on a validation set (containing normal and anomalous samples with known labels) to obtain the probability value of each sample belonging to the anomalous class. Then, iterate through all possible decision thresholds (e.g., from 0 to 1, with a step size of 0.01), and for each threshold, [the following is done:] Samples ≥ the threshold are considered abnormal; otherwise, they are considered normal. Calculate the true positive rate (the proportion of actual abnormalities correctly identified) and the false positive rate (the proportion of actual normal samples misidentified as abnormal) at that threshold. Plot the FPR (Functional Positive Rate) on the horizontal axis and the TPR (Total Positive Rate) on the vertical axis, and connect the points corresponding to each threshold to form the ROC curve.
[0074] Yoden Index The threshold corresponding to its maximum value gives the model the strongest ability to distinguish between positive and negative examples; the first basic outlier threshold. This is the optimal threshold; the weighting coefficient mapping table is a pre-defined table, for example, transformer substation type: residential substations correspond to a first weighting coefficient of 0.1, industrial and commercial substations 0.6, and mixed substations 0.35; historical false alarm rate: <1% corresponds to a second weighting coefficient of 0.1, 1%-3% corresponds to 0.3, and >3% corresponds to 0.6; comprehensive weighting coefficient. That is, after summing the two weighting coefficients, the amplitude is limited to the [0,1] interval; adjustment coefficient The value was determined to be 0.15 after experimental optimization.
[0075] In this embodiment, during the model validation phase, the ROC curve and Youden index are used to determine... =0.95. When deploying the electricity meter, maintenance personnel configure the transformer substation type (residential / commercial / mixed), and the meter automatically records the historical false alarm rate. The meter periodically (e.g., daily) reads the value corresponding to the current transformer substation type. Corresponding to the false alarm rate of the most recent week ,calculate (If the sum exceeds 1, then take 1), then calculate. .
[0076] For example: old residential areas ( =0.1, false alarm rate <1% =0.1, =0.2, =0.92); New industrial parks ( =0.6, =0.1, =0.7, =0.845); Frequent false alarms in mixed distribution areas ( =0.35, =0.6, =0.95, =0.8075). The calculated value is... Used for subsequent anomaly detection.
[0077] As can be seen from the above, this embodiment determines the optimal first basic anomaly threshold by combining the ROC curve with the Youden index, which can maximize the model's anomaly identification and differentiation capabilities, and fundamentally ensure the scientific nature and accuracy of the threshold setting. Based on the transformer area type and historical false alarm rate, the comprehensive weight coefficient is dynamically calculated, and after amplitude limiting constraints, the first anomaly threshold is adaptively generated through a formula, which completely solves the defect that static thresholds cannot adapt to different transformer areas and different false alarm rate scenarios. The optimal threshold can be automatically matched for various transformer areas such as residential, industrial and commercial, and mixed, effectively reducing the probability of false alarms and missed alarms, significantly improving the generalization ability and scenario adaptability of the anomaly detection model, making the anomaly judgment more in line with the actual operating conditions of the power grid, and ensuring stable and reliable detection accuracy across all scenarios.
[0078] In one embodiment of this application, to ensure that the above detection method can achieve the expected accuracy and generalization ability, this embodiment further includes: a training and optimization process for a fused deep learning model. This process is completed offline before the electricity meter is deployed, and the trained model parameters (weight matrix) are then used to optimize the model. Bias vector Initial weights =0.55, =0.45, correction factor =0.25, =0.30, =0.20, =0.25 etc.) is solidified into the energy meter management chip.
[0079] The specific implementation method is as follows: First, construct a deep learning model that integrates LSTM and CNN. After the model is constructed, prepare the training dataset. The dataset should contain no fewer than 100,000 records, covering time-series electricity consumption data for five scenarios: normal electricity consumption, electricity theft, leakage, overload anomaly, and harmonic anomaly, across different transformer substations (residential, industrial / commercial, and mixed) and different user types. Each data category includes first-source multi-source detection data (voltage, current, active power, power factor, and harmonic content) and second-source multi-source detection data (three-phase imbalance, power mutation rate, residual current ratio, and harmonic distortion rate). All data are linearly interpolated for missing values. The input samples are processed by outlier removal, min-max standardization, and 10-minute window reconstruction.
[0080] The dataset was divided into training, validation, and test sets in a 7:2:1 ratio. Mini-batch gradient descent was used during training, with a batch size of 32. The cross-entropy loss function was employed. ,in The number of training samples is ≥100,000, and C=5 represents the number of anomaly categories. Let i be the true label of the j-th class of the i-th sample. To predict probabilities for the model, an L2 regularization term is added to prevent overfitting. The regularization coefficient is... =0.001, the total loss function is Where K is the total number of parameters in the fully connected layer. There are k parameters. The optimizer uses the Adam optimizer, with a learning rate of... =0.001, iterate 100 times.
[0081] The update formula for the Adam optimizer is: First-order moment estimation ; in, The first moment estimate of the t-th iteration is the exponential moving average of the gradient, which is used to reflect the overall trend of the gradient. The first moment estimate is the value of the (t-1)th iteration, which is the gradient moving average result of the previous iteration. The first-order moment decay coefficient is fixed at 0.9 in this embodiment to control the weight of the influence of historical gradients on the current value; In the t-th iteration, the current gradient value corresponding to the model parameters is obtained by taking the derivative of the loss function with respect to the parameters; t is the current iteration number (which step the training has reached).
[0082] Second moment estimation ; in, This is the second moment estimate for the t-th iteration, which is the exponential moving average of the squared gradient and is used to measure the fluctuation of the gradient. The second moment estimate for the (t-1)th iteration is the moving average of the squared gradient from the previous iteration. The second-order moment decay coefficient is fixed at 0.999 in this embodiment to control the weight of the influence of the historical gradient square on the current value; deviation correction. , ; in, This is the first-order moment estimate after bias correction in the t-th iteration (the final effective value used for parameter updates).
[0083] Parameter update .
[0084] in, is the second-order moment estimate after bias correction in the t-th iteration, which is the effective value actually used by the Adam optimizer for parameter updates.
[0085] During training, the accuracy is calculated on the validation set after each iteration, employing an early stopping strategy: if the validation set accuracy does not improve for five consecutive iterations, training is stopped, and the model parameters with the highest validation set accuracy are saved. After training is complete, the model performance is evaluated on the test set, requiring an overall accuracy of at least 98%.
[0086] Based on the same principle as the power grid anomaly detection method provided in the embodiments of this application, the embodiments of this application also provide a power grid anomaly detection device, such as... Figure 2 As shown, the power grid anomaly detection device 20 is installed in the electricity meter and may specifically include: a first data acquisition module 21, a feature extraction module 22, a second data acquisition module 23, a weight calculation module 24, a feature fusion module 25, and an anomaly judgment module 26. The first data acquisition module 21 is used to acquire the first multi-source detection data of the power grid within the current detection time window, and to preprocess the first multi-source detection data to obtain a time-series dataset; the first multi-source detection data includes the voltage data, current data, active power, power factor and harmonic content of the power grid; The feature extraction module 22 is used to perform local feature extraction on the time series dataset to obtain local feature vectors; and to perform time series feature extraction on the time series dataset to obtain time series feature vectors. The second data acquisition module 23 is used to acquire the second multi-source detection data of the power grid within the current detection time window. The second multi-source detection data includes the three-phase imbalance of the power grid, the power mutation rate, the residual current ratio, and the harmonic distortion rate. The weight calculation module 24 is used to obtain the initial weights corresponding to the local feature vector and the temporal feature vector respectively, and to correct the initial weights corresponding to the local feature vector and the temporal feature vector respectively based on the second multi-source detection data to obtain their respective target weights; The feature fusion module 25 is used to fuse local feature vectors and temporal feature vectors and their respective target weights to obtain a fused feature vector. The anomaly detection module 26 is used to identify the anomaly type of the current power grid based on the fused feature vector, and obtain the anomaly type corresponding to the current power grid.
[0087] In one embodiment of this application, the weight calculation module 24 is specifically used for: Based on the second multi-source detection data, the weight correction values corresponding to the local feature vectors are obtained; The initial weights of the local feature vectors are corrected based on the weight correction values to obtain the target weights corresponding to the local feature vectors; Based on the target weights corresponding to the local feature vectors, the target weights corresponding to the time-series feature vectors are obtained.
[0088] In one embodiment of this application, the weight calculation module 24 is further configured to: Based on the second multi-source detection data, and using the first formula, the weight correction value corresponding to the local feature vector is obtained; The first formula is: ; in, This represents the weight correction value corresponding to the local feature vector. This indicates the three-phase imbalance of the power grid. Indicates the power fluctuation rate of the power grid. This indicates the ratio of residual current in the power grid. Indicates the harmonic distortion rate of the power grid. , , and All of these represent correction factors.
[0089] In one embodiment of this application, the weight calculation module 24 is further configured to: Based on the weight correction value, and by correcting the initial weights of the local feature vectors using the second formula, the target weights corresponding to the local feature vectors are obtained. The second formula is: ; in, This represents the target weight corresponding to the local feature vector. Represents the initial weights of the local eigenvectors. This represents the weight correction value corresponding to the local feature vector.
[0090] In one embodiment of this application, the anomaly detection module 26 is specifically used for: The fused feature vector and the constructed weight matrix are linearly transformed, and the ReLU activation function is used to obtain the original scores of the current power grid's operating state belonging to each anomaly type; the weight matrix represents the mapping relationship parameters between each dimension of the fused feature vector and each anomaly type. Based on the original scores, and after normalization using the Softmax activation function, the probability values of the current power grid's operating state belonging to each anomaly type are obtained. The maximum value among the probability values of each anomaly type is obtained, and the maximum value is compared with the preset target anomaly threshold to obtain the comparison result. Based on the comparison result, the anomaly type of the current power grid is determined.
[0091] In one embodiment of this application, the preset target anomaly threshold includes: a first anomaly threshold and a second anomaly threshold, wherein the first anomaly threshold is greater than the second anomaly threshold; The comparison results include suspected abnormalities and potential abnormalities; The maximum value is compared with a preset target anomaly threshold to obtain the comparison results, including: If the maximum value is greater than or equal to the first abnormal threshold, the current power grid is determined to be a suspected abnormality; If the maximum value is greater than or equal to the second abnormal threshold and less than the first abnormal threshold, the current power grid is determined to be a potential abnormality. The weight calculation module 24 is also specifically used for: In response to the comparison result being a suspected anomaly, the anomaly type corresponding to the maximum value is determined as the target anomaly type; The first multi-source detection data and the second multi-source detection data are filtered to obtain the target data that currently causes the target anomaly type; the target data contains at least one data from the first multi-source detection data and / or at least one data from the second multi-source detection data. The target data is compared with the corresponding preset reference value to determine the current anomaly type of the power grid; In response to a comparison result indicating a potential anomaly, retrieve the corresponding historical comparison results within multiple historical detection time windows that are consecutive to the current detection time window; If, up to the current detection time window, all historical comparison results are of the same anomaly type as the comparison results, and the number of consecutive counts of that anomaly type is greater than or equal to the preset number, then the target data will be compared with the corresponding preset reference value, and the anomaly type of the current power grid will be determined.
[0092] In one embodiment of this application, The methods for determining the first abnormal threshold include: The Youden index is determined based on the constructed ROC curve, and the maximum value of the Youden index is used as the first basic anomaly threshold. The ROC curve represents the mapping relationship between the true positive rate and the false positive rate of the current anomaly identification model when traversing different classification thresholds. Based on the preset weight coefficient mapping table, the first weight coefficient corresponding to the application area type of the electricity meter is obtained, and the second weight coefficient corresponding to the historical false alarm rate of the area type within the preset statistical period is obtained. Based on the first and second weighting coefficients, the comprehensive weighting coefficient is obtained; Based on the first basic anomaly threshold and the comprehensive weight coefficient, and through the fourth calculation formula, the first anomaly threshold is obtained; The fourth calculation formula is: ; in, Indicates the first abnormal threshold. This represents the first basic anomaly threshold. This represents the overall weighting coefficient. This represents the adjustment factor.
[0093] The apparatus in this application embodiment can execute the method provided in this application embodiment, and the implementation principle is similar. The actions performed by each module in the apparatus of each embodiment of this application correspond to the steps in the method of each embodiment of this application. For detailed functional descriptions of each module of the apparatus, please refer to the descriptions in the corresponding methods shown above, which will not be repeated here.
[0094] Figure 3 A schematic diagram of the structure of an electricity meter applicable to an embodiment of this application is shown, as follows: Figure 3 As shown, the electricity meter can be used to implement the methods provided in any embodiment of this application.
[0095] like Figure 3 As shown, the electricity meter 300 may primarily include at least one processor 301. Figure 3 The diagram shows components such as a memory 302, a communication module 303, and an input / output interface 304. Optionally, these components can be connected and communicate with each other via a bus 305. It should be noted that... Figure 3 The structure of the electricity meter 300 shown is merely illustrative and does not constitute a limitation on the electricity meter to which the method provided in the embodiments of this application applies.
[0096] The memory 302 can be used to store operating systems and applications, etc. The applications can include computer programs that implement the methods shown in the embodiments of this application when invoked by the processor 301, and can also include programs for implementing other functions or services. The memory 302 can be ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices that can store information and computer programs, or it can be EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.
[0097] Processor 301 is connected to memory 302 via bus 305 and implements corresponding functions by calling the application programs stored in memory 302. Processor 301 can be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 301 can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0098] The electricity meter 300 can be connected to a network via a communication module 303 (which may include, but is not limited to, components such as a network interface) to communicate with other devices (such as user terminals or servers) through the network and achieve data interaction, such as sending data to or receiving data from other devices. The communication module 303 may include a wired network interface and / or a wireless network interface, meaning the communication module may include at least one of a wired communication module or a wireless communication module.
[0099] The electricity meter 300 can connect to necessary input / output devices, such as a keyboard or display device, via the input / output interface 304. The electricity meter 300 itself can have a display device, and other external display devices can also be connected via the input / output interface 304. Optionally, a storage device, such as a hard drive, can also be connected via the input / output interface 304 to store data from the electricity meter 300, retrieve data from the storage device, or store data from the storage device in the memory 302. It is understood that the input / output interface 304 can be a wired interface or a wireless interface. Depending on the actual application scenario, the device connected to the input / output interface 304 can be an integral part of the electricity meter 300 or an external device connected to the electricity meter 300 when needed.
[0100] The bus 305 used to connect the components may include a path for transmitting information between the components. The bus 305 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Depending on its function, the bus 305 may be divided into an address bus, a data bus, a control bus, etc.
[0101] Optionally, for the solution provided in the embodiments of this application, the memory 302 can be used to store a computer program that executes the solution of this application, and the processor 301 runs the computer program. When the processor 301 runs the computer program, it implements the operation of the method or apparatus provided in the embodiments of this application.
[0102] Based on the same principle as the method provided in the embodiments of this application, the embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the corresponding content of the aforementioned method embodiments.
[0103] This application also provides a computer program product, which includes a computer program that, when executed by a processor, can implement the corresponding content of the aforementioned method embodiments.
[0104] It should be noted that the terms "first," "second," "third," "fourth," "1," "2," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in a sequence other than that shown in the figures or text.
[0105] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0106] It should be understood that although arrows indicate various operation steps in the flowcharts of this application's embodiments, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of this application's embodiments, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all steps in each flowchart, based on the actual implementation scenario, may include multiple sub-steps or multiple stages. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and this application's embodiments do not limit this.
[0107] The above description is only an optional implementation method for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application without departing from the technical concept of this application also fall within the protection scope of the embodiments of this application.
Claims
1. A method for detecting power grid anomalies, characterized in that, Performed by the electricity meter, including: The first multi-source detection data of the power grid within the current detection time window is obtained, and the first multi-source detection data is preprocessed to obtain a time-series dataset; the first multi-source detection data includes the voltage data, current data, active power, power factor and harmonic content of the power grid; Local feature extraction is performed on the time-series dataset to obtain local feature vectors; time-series feature extraction is performed on the time-series dataset to obtain time-series feature vectors. Acquire the second multi-source detection data of the power grid within the current detection time window. The second multi-source detection data includes the three-phase imbalance of the power grid, power mutation rate, residual current ratio, and harmonic distortion rate. The initial weights corresponding to the local feature vector and the temporal feature vector are obtained respectively, and the initial weights corresponding to the local feature vector and the temporal feature vector are corrected based on the second multi-source detection data to obtain their respective target weights; The local feature vector and the temporal feature vector, along with their respective target weights, are fused to obtain a fused feature vector. Based on the fused feature vector, the current power grid is identified as having anomaly type, and the anomaly type corresponding to the current power grid is obtained.
2. The power grid anomaly detection method as described in claim 1, characterized in that, The step of correcting the initial weights corresponding to the local feature vector and the temporal feature vector based on the second multi-source detection data to obtain their respective target weights includes: Based on the second multi-source detection data, the weight correction value corresponding to the local feature vector is obtained; The initial weights of the local feature vectors are corrected based on the weight correction value to obtain the target weights corresponding to the local feature vectors; Based on the target weights corresponding to the local feature vectors, the target weights corresponding to the time-series feature vectors are obtained.
3. The power grid anomaly detection method as described in claim 2, characterized in that, The step of obtaining the weight correction value corresponding to the local feature vector based on the second multi-source detection data includes: Based on the second multi-source detection data, and using the first formula, the weight correction value corresponding to the local feature vector is obtained; The first formula is: ; in, This represents the weight correction value corresponding to the local feature vector. This indicates the three-phase imbalance of the power grid. Indicates the power fluctuation rate of the power grid. This indicates the ratio of residual current in the power grid. Indicates the harmonic distortion rate of the power grid. , , and All of these represent correction factors.
4. The power grid anomaly detection method as described in claim 2, characterized in that, The step of correcting the initial weights of the local feature vector based on the weight correction value to obtain the target weights corresponding to the local feature vector includes: Based on the weight correction value, and by correcting the initial weight of the local feature vector using the second formula, the target weight corresponding to the local feature vector is obtained; The second formula is: ; in, This represents the target weight corresponding to the local feature vector. This represents the initial weights of the local feature vectors. This represents the weight correction value corresponding to the local feature vector.
5. The power grid anomaly detection method as described in claim 1, characterized in that, The step of identifying the anomaly type of the current power grid based on the fused feature vector to obtain the anomaly type corresponding to the current power grid includes: The fused feature vector and the constructed weight matrix are linearly transformed, and the ReLU activation function is used to obtain the original scores of the current power grid's operating state belonging to each anomaly type; the weight matrix represents the mapping relationship parameters between each dimension of the fused feature vector and each anomaly type. Based on the original scores, and after normalization using the Softmax activation function, the probability values of the current power grid's operating state belonging to each anomaly type are obtained. The maximum value among the probability values of each anomaly type is obtained, and the maximum value is compared with a preset target anomaly threshold to obtain a comparison result. Based on the comparison result, the anomaly type of the current power grid is determined.
6. The power grid anomaly detection method as described in claim 5, characterized in that, The preset target anomaly threshold includes: a first anomaly threshold and a second anomaly threshold, wherein the first anomaly threshold is greater than the second anomaly threshold; the comparison result includes suspected anomalies and potential anomalies. The step of comparing the maximum value with a preset target anomaly threshold to obtain a comparison result includes: If the maximum value is greater than or equal to the first abnormal threshold, the current power grid is determined to be a suspected abnormality; If the maximum value is greater than or equal to the second abnormal threshold and less than the first abnormal threshold, then the current power grid is determined to be a potential abnormality. The step of determining the anomaly type of the current power grid based on the comparison result includes: In response to the comparison result being a suspected anomaly, the anomaly type corresponding to the maximum value is determined to be the target anomaly type; The first multi-source detection data and the second multi-source detection data are filtered to obtain the target data that currently causes the target anomaly type; the target data contains at least one data from the first multi-source detection data and / or at least one data from the second multi-source detection data; The target data is compared with the corresponding preset reference value to determine the current power grid anomaly type; In response to the comparison result being a potential anomaly, the corresponding historical comparison results within multiple historical detection time windows consecutive to the current detection time window are obtained; If, up to the current detection time window, all historical comparison results are of the same anomaly type as the comparison results, and the number of consecutive counts of the anomaly type is greater than or equal to a preset number, then the target data is compared with the corresponding preset reference value, and the anomaly type of the current power grid is determined.
7. The power grid anomaly detection method as described in claim 6, characterized in that, The method for determining the first abnormal threshold includes: The Youden index is determined based on the constructed ROC curve, and the maximum value of the Youden index is used as the first basic anomaly threshold. The ROC curve represents the mapping relationship between the true positive rate and the false positive rate when traversing different classification thresholds. Based on a preset weight coefficient mapping table, the first weight coefficient corresponding to the application area type of the electricity meter is obtained, and the second weight coefficient corresponding to the historical false alarm rate of the area type within a preset statistical period is obtained. Based on the first weighting coefficient and the second weighting coefficient, a comprehensive weighting coefficient is obtained; Based on the first basic anomaly threshold and the comprehensive weight coefficient, and through the fourth calculation formula, the first anomaly threshold is obtained; The fourth calculation formula is as follows: ; in, Indicates the first abnormal threshold. This represents the first basic anomaly threshold. This represents the overall weighting coefficient. This represents the adjustment factor.
8. A power grid anomaly detection device, characterized in that, The following are installed in the electricity meter: The first data acquisition module is used to acquire the first multi-source detection data of the power grid within the current detection time window, and to preprocess the first multi-source detection data to obtain a time-series dataset; the first multi-source detection data includes the voltage data, current data, active power, power factor and harmonic content of the power grid; The feature extraction module is used to perform local feature extraction on the time series dataset to obtain local feature vectors; and to perform time series feature extraction on the time series dataset to obtain time series feature vectors. The second data acquisition module is used to acquire the second multi-source detection data of the power grid within the current detection time window. The second multi-source detection data includes the three-phase imbalance of the power grid, the power mutation rate, the residual current ratio, and the harmonic distortion rate. The weight calculation module is used to obtain the initial weights corresponding to the local feature vector and the temporal feature vector respectively, and to correct the initial weights corresponding to the local feature vector and the temporal feature vector respectively based on the second multi-source detection data to obtain their respective target weights; The feature fusion module is used to fuse the local feature vector and the temporal feature vector and their respective target weights to obtain a fused feature vector. The anomaly detection module is used to identify the anomaly type of the current power grid based on the fused feature vector, and obtain the anomaly type corresponding to the current power grid.
9. An electricity meter, characterized in that, The electricity meter includes a memory and a processor. The memory stores a computer program, and the processor executes the power grid anomaly detection method according to any one of claims 1 to 7 when running the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the power grid anomaly detection method according to any one of claims 1 to 7.