An intelligent electric meter abnormal power utilization detection method based on random matrix theory and double-path Transformer representation fusion

CN123012944APending Publication Date: 2026-10-30NANJING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610880008.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-17
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0010]本发明目的在于针对现有智能电表异常用电检测技术中存在的人工特征表达不充分、缺失值和零值异常利用不足、用户群体结构偏离刻画不足、局部异常与长期依赖难以兼顾、单一模型泛化稳定性不足以及类别不平衡场景下异常用户识别能力受限等问题,提出一种基于随机矩阵理论与双路径Transformer表征融合的智能电表异常用电检测方法

Benefits of technology

1、本发明同时刻画个体行为与群体偏离,提高隐蔽异常识别能力,引入随机矩阵理论,增强群体异常信号提取能力。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123012944A_ABST
    Figure CN123012944A_ABST
Patent Text Reader

Abstract

The application discloses an intelligent electric meter abnormal power utilization detection method based on random matrix theory and double-path Transformer representation fusion, which comprises the following steps: (1) multi-source power utilization feature construction; (2) random matrix theory feature enhancement; (3) double-path Transformer representation fusion and integrated discrimination: inputting monthly multi-channel power utilization sequences into a double-path Transformer network, capturing short-term continuous abnormal changes through local window attention, and modeling cross-month long-term dependence through a global Transformer branch; then, dimensionally reducing deep time sequence representation, fusing with artificial features and random matrix theory features, constructing an integrated classifier by using CatBoost, XGBoost and LightGBM, and obtaining a final abnormal power utilization detection result. The application has the characteristics of multi-source feature fusion, individual abnormality and group deviation joint modeling, local and global time sequence information collaborative extraction, sensitivity to missing values and zero value abnormalities, and can be applied to electricity stealing identification, abnormal power utilization screening and user power utilization behavior analysis in a smart grid.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method for detecting abnormal electricity consumption in smart meters based on the fusion of random matrix theory and dual-path Transformer representation, belonging to the fields of smart grid, abnormal electricity consumption detection, smart meter data analysis and machine learning. Background Technology

[0002] With the large-scale deployment of advanced metering systems and smart meters, power companies can continuously collect daily, hourly, and higher-frequency electricity consumption data from users. Smart meter data reflects users' long-term electricity consumption habits, short-term load fluctuations, seasonal changes, holiday differences in electricity consumption, and abnormal load changes, serving as a crucial data foundation for electricity theft identification, metering anomaly investigation, equipment fault detection, and abnormal load connection monitoring. Abnormal electricity consumption not only causes economic losses for power companies but also affects the accuracy of distribution line loss analysis, increases marketing audit and maintenance costs, and in severe cases, may impact the operational safety of the distribution network. Therefore, accurately identifying abnormal users from large-scale, high-noise, long-cycle smart meter time series is a critical technical challenge in smart grid data analysis, power marketing audit, and refined distribution network management.

[0003] Existing abnormal power consumption detection technologies mainly include machine learning methods driven by artificial features, unsupervised anomaly detection methods, deep learning time series modeling methods, and multi-model fusion methods.

[0004] Manually-driven machine learning methods typically construct features such as mean, variance, peak-to-valley difference, load factor, proportion of zero values, proportion of missing values, differences between previous and subsequent cycles, trend decline magnitude, seasonal statistics, and cross-user ranking based on historical user electricity consumption data. These features are then used to identify anomalous users through classifiers such as Logistic Regression, Support Vector Machine, Random Forest, XGBoost, LightGBM, or CatBoost. These methods are simple to implement, have high training efficiency, and are well-suited to tabular electricity consumption behavior features; some features also offer strong business interpretability. However, the detection effectiveness of these methods is highly dependent on manually designed features and struggles to automatically learn deep temporal representations from long-term electricity consumption sequences. For progressive anomalies, intermittent anomalies, slow declines in later stages, anomalies masked by seasonal fluctuations, and significant differences in electricity consumption scale among different users, statistical features alone are often insufficient to fully express anomalous behavior. Furthermore, these methods typically treat each user as an independent sample, focusing primarily on individual electricity consumption behavior changes, and failing to adequately utilize the structural deviations implicit in the user group's electricity consumption matrix.

[0005] In scenarios where anomaly labels are scarce or manual labeling is costly, unsupervised anomaly detection methods are also used for screening abnormal electricity consumption. These methods typically determine whether a user is abnormal based on isolation level, local density, distance deviation, clustering results, or reconstruction error. For example, some methods weight electricity consumption behavior indicators and introduce an Isolation Forest model to identify abnormal users based on the isolation level of samples in the feature space; other methods utilize robust clustering to classify user electricity consumption curves or electricity consumption behavior characteristics based on similarity and determine anomalies based on the degree to which a user deviates from their group. These methods can complete preliminary screening even in the absence of anomaly labels and have certain engineering application value. However, unsupervised methods usually rely on pre-constructed statistical indicators, distance metrics, density estimates, isolation assumptions, or clustering structures, and the detection results are easily affected by feature scale, differences in user electricity consumption scale, anomaly ratio, and threshold settings. For concealed electricity theft, gradual anomalies, slow declines in the later stages, and abnormal electricity consumption patterns similar to normal user behavior, relying solely on isolation level or cluster deviation is insufficient to reliably distinguish between normal behavior differences and genuine abnormal behavior, easily leading to false positives or false negatives.

[0006] With the development of deep learning technology, existing methods have attempted to use deep neural networks to identify abnormal electricity consumption behaviors in high-dimensional energy consumption data or big data on electricity. These methods typically take user electricity consumption sequences, electricity consumption statistics, or multi-dimensional energy consumption features as input, and learn the nonlinear mapping relationship between electricity consumption data and abnormal states through neural networks, thereby improving the model's ability to express complex electricity consumption patterns. Compared with traditional machine learning methods, deep learning methods can reduce the reliance on manual feature combinations to a certain extent and can extract higher-level electricity consumption behavior representations from raw or aggregated sequences. For example, convolutional neural networks can extract local electricity consumption fluctuation features, recurrent neural networks, long short-term memory networks, and gated recurrent units can model time dependencies, and Transformer-type models can characterize global correlations in long-period sequences through self-attention mechanisms.

[0007] However, existing deep learning-based methods for detecting abnormal electricity consumption still have shortcomings. On the one hand, some methods mainly model based on single-user electricity consumption sequences or fixed-dimensional feature vectors, focusing on changes in the user's own electricity consumption curve, and failing to adequately utilize cross-user relative rankings, group behavior differences, and structural deviations in the overall user electricity consumption matrix. On the other hand, different depth time series models have their own limitations: convolutional models emphasize local pattern extraction and are insufficient in characterizing long-term dependencies across cycles; recurrent models have low training efficiency in long-cycle sequences and are easily limited by their ability to model long-term dependencies; while single-path Transformers have global modeling capabilities, they lack explicit constraints on local abnormal patterns such as continuous declines, short-term abrupt changes, and intermittent zeroing within adjacent cycles. In addition, smart meter data commonly suffers from missing values, zero values, seasonal fluctuations, differences in user electricity consumption scales, and a low proportion of abnormal samples. If only a single deep model is relied upon, it is easily affected by data noise, changes in sample distribution, and class imbalance, resulting in insufficient stability of the detection results.

[0008] Multi-model fusion methods improve the performance of abnormal electricity consumption detection by combining multiple classifiers or feature sources. Existing fusion methods typically use weighted averaging, voting fusion, ranking fusion, or stacking fusion of the outputs of traditional machine learning models, deep learning models, or unsupervised detectors to reduce the sensitivity of a single model to sample partitioning, feature perturbation, and parameter selection. While these methods can improve detection stability to some extent, if the input feature sources used by each model are similar, or if fusion is only performed at the classification result level, it is difficult to fully leverage the complementary effects between different feature perspectives. Especially for complex abnormal electricity consumption scenarios that simultaneously include individual electricity consumption changes, group structure deviations, local continuous anomalies, and long-term trend changes, simple result fusion still falls short of comprehensively characterizing abnormal behavior.

[0009] In summary, while existing abnormal electricity consumption detection technologies can screen for abnormal users to a certain extent, they still have the following technical shortcomings: First, traditional machine learning methods rely on manual feature engineering, making it difficult to automatically learn deep temporal representations in long-term electricity consumption sequences; Second, unsupervised detection and clustering methods mainly rely on distance metrics, isolation assumptions, cluster structures, or anomaly thresholds, making them sensitive to differences in user electricity consumption patterns and hidden abnormal behaviors; Third, existing deep learning methods mostly model from a single-user perspective, lacking effective utilization of information on deviations in user group structures; Fourth, existing single-path temporal models struggle to simultaneously capture local continuous anomalies within adjacent cycles and long-term dependencies across cycles; Fifth, existing fusion methods mostly remain at the model result level, insufficiently utilizing the complementary relationships between manual features, group spectral structure features, and deep temporal representations; Sixth, real smart meter data exhibits prominent issues such as missing values, zero values, seasonal fluctuations, and class imbalances, making it difficult for a single model to maintain stable detection performance in complex real-world scenarios. Summary of the Invention

[0010] This invention aims to address the shortcomings of existing smart meter anomaly detection technologies, such as insufficient representation of manual features, inadequate utilization of missing and zero-value anomalies, insufficient characterization of user group structure deviations, difficulty in simultaneously addressing local anomalies and long-term dependencies, insufficient generalization stability of single models, and limited ability to identify abnormal users in class imbalance scenarios. To address these issues, this invention proposes a smart meter anomaly detection method based on the fusion of stochastic matrix theory and dual-path Transformer representation. This method constructs multi-source electricity consumption behavior features to characterize individual user statistical features, missing zero-value patterns, trend deviations, cross-user rankings, seasonal variations, and multi-scale change points. It then uses stochastic matrix theory to perform spectral decomposition on the monthly electricity consumption matrix of the user group, extracting group structure deviation features. A dual-path Transformer, composed of local window attention branches and global self-attention branches, simultaneously captures continuous anomaly fluctuations within adjacent periods and long-term dependencies across periods. Finally, it fuses manual features, stochastic matrix theory-enhanced features, and deep temporal representations, and uses a weighted ensemble of CatBoost, XGBoost, and LightGBM to complete anomaly discrimination. This improves the model's ability to identify hidden anomalies, progressive anomalies, missing zero-value anomalies, and population structure deviation anomalies.

[0011] The technical solution adopted by this invention to solve its technical problem is: a method for detecting abnormal electricity consumption in smart meters based on the fusion of random matrix theory and dual-path Transformer representation, the method comprising the following steps: Step 1: Data Acquisition and Preprocessing; The system acquires the electricity consumption sequences of multiple electricity users' smart meters and their abnormal electricity consumption tags within a continuous time period, and constructs a user-time two-dimensional electricity consumption matrix. The system then identifies, marks, counts, and fills in the missing values, zero values, and abnormal sampling positions in the user-time two-dimensional electricity consumption matrix to obtain a standardized user electricity consumption time series. Step 2: Extraction of multi-source power consumption behavior features; Using the standardized user electricity consumption time series as the processing object, user statistical features, missing pattern features, zero value behavior features, monthly aggregation features, trend deviation features, cross-user relative ranking features, calendar features, seasonality features, and multi-scale change point features are extracted to form a basic electricity consumption behavior feature matrix. Step 3: Signal enhancement using random matrix theory; Using the user's monthly electricity consumption sequence corresponding to the monthly aggregated features as the processing object, a random matrix is ​​constructed; the random matrix is ​​robustly normalized, covariance matrix is ​​constructed and eigenvalue decomposition is performed, the signal subspace and noise subspace are divided according to the Marchenko-Pastur spectral boundary, and the theoretical enhancement features of the random matrix are extracted based on the subspace projection results; Step 4: Dual-path Transformer deep representation extraction; Using monthly multi-channel electricity consumption sequences as input, a dual-path Transformer model including a local window attention branch and a global self-attention branch is constructed. The local window attention branch extracts short-term abnormal fluctuation features within adjacent periods, and the global self-attention branch extracts long-term dependency features across periods. The outputs of the two branches are then fused to obtain a deep time series representation of the user. Step 5: Deep representation compression and fusion; The user deep time series representation is reduced in dimension and compressed to obtain a low-dimensional deep time series representation; the low-dimensional deep time series representation, the basic electricity consumption behavior feature matrix and the random matrix theory enhanced features are concatenated to obtain the final fused feature matrix. Step 6: Integrating classification and anomaly detection: Train multiple gradient boosting classifiers using the final fused feature matrix as input; determine the fusion weights based on the validation performance of each classifier, and perform weighted fusion of the anomaly probabilities or anomaly ranking results output by multiple classifiers to obtain the user's abnormal power consumption detection results.

[0012] Furthermore, the data acquisition and preprocessing steps of the present invention specifically include: constructing a missing mask and a zero-value mask for the user's daily electricity consumption sequence; statistically analyzing the missing and zero-value distribution of users in the entire cycle, the first half of the cycle, and the second half of the cycle based on the missing mask and the zero-value mask; filling the interpolable missing points using interpolation along the time direction, and completing the remaining missing points using group statistical values ​​within the same time period to obtain a complete user electricity consumption sequence.

[0013] Furthermore, the missing pattern features described in this invention are obtained by statistical analysis of the missing mask and the zero-value mask, and include at least the user's full-cycle missing ratio, the longest consecutive missing ratio, the first half-cycle missing ratio, the second half-cycle missing ratio, the difference between the missing and non-missing periods, the number of missing segments, the zero-value ratio, the longest consecutive zero-value ratio, and the no-signal ratio.

[0014] Furthermore, the monthly aggregation features of the present invention are obtained in the following manner: using a preset number of days as the aggregation window, the standardized user electricity consumption time series is converted into a monthly electricity consumption series; within each aggregation window, at least one monthly fluctuation statistic is extracted, including monthly mean, monthly standard deviation, monthly maximum value, monthly zero value ratio, monthly missing value ratio, and monthly range, coefficient of variation, rolling mean or rolling standard deviation.

[0015] Furthermore, the trend deviation feature of the present invention includes a relative benchmark deviation feature and a cumulative deviation feature; wherein, the relative benchmark deviation feature is obtained by using the electricity consumption statistics of the user in the previous several periods as an individual benchmark and calculating the degree of deviation of the electricity consumption in the current period relative to the individual benchmark; the cumulative deviation feature is obtained by accumulating the relative benchmark deviation of multiple periods, and is used to characterize the continuous decline or continuous deviation trend of the user's electricity consumption behavior.

[0016] Furthermore, the cross-user relative ranking feature of the present invention includes a cross-user ranking feature, a ranking deviation feature, and a ranking decline feature; wherein, the cross-user ranking feature is obtained by sorting the electricity consumption of all users within the same time period; the ranking deviation feature is obtained by calculating the difference between a user's current ranking and its historical average ranking; and the ranking decline feature is obtained by comparing a user's ranking in the previous period and its ranking in the subsequent period.

[0017] Furthermore, the random matrix theory signal enhancement steps of this invention specifically include: robustly standardizing and centering the user's monthly electricity consumption matrix to construct a group covariance matrix; performing eigenvalue decomposition on the group covariance matrix to obtain eigenvalues ​​and their corresponding eigenvectors; dividing the eigenvectors into a salient signal subspace and a noise subspace based on the Marchenko-Pastur spectral boundary; projecting the user's monthly electricity consumption sequence onto the salient signal subspace and the noise subspace respectively, and extracting signal energy, noise energy, and global signal-to-noise ratio features based on the projection results.

[0018] Furthermore, the random matrix theory enhancement feature of the present invention also includes the late signal energy ratio feature; the late signal energy ratio feature is obtained by: stratifying users according to the average electricity consumption level or historical electricity consumption scale, constructing a significant signal subspace in each stratum; projecting the user's late monthly electricity consumption sequence to the significant signal subspace of the corresponding stratum, and calculating the ratio of the late projected energy to the full-cycle projected energy.

[0019] Furthermore, the dual-path Transformer model of this invention includes an input projection layer, a position encoding layer, a local window attention module, a global Transformer encoding module, a class label vector, and a classification output layer. The input projection layer maps the monthly multi-channel sequence to a unified hidden dimension. The position encoding layer injects monthly order information into the mapped sequence. The local window attention module extracts neighboring month dependency features based on a local attention mask. The global Transformer encoding module aggregates full-cycle electricity consumption behavior information through the class label vector and a multi-head self-attention mechanism, ensuring that the i-th month only performs attention calculations with months within a preset window range, thus obtaining local window attention features. This enhances the model's ability to perceive continuous short-term abnormal fluctuations. The global Transformer encoding module adds a learnable class label vector before the monthly electricity consumption behavior sequence, encodes the full-cycle monthly electricity consumption behavior sequence after adding the class label through a multi-head self-attention mechanism, and uses the output corresponding to the class label vector as a global temporal representation.

[0020] Further, the dual-path Transformer deep representation described in this invention is obtained through the following methods: pooling the sequence features output by the local window attention branch to obtain a local temporal representation; obtaining the output features corresponding to the category label vector in the global self-attention branch to obtain a global temporal representation; concatenating the local and global temporal representations to obtain the user deep temporal representation; the training of the dual-path Transformer employs adaptive Focal Loss; wherein, the category weights are determined based on the number of normal and abnormal electricity consumption samples, and the category weights are introduced into the cross-entropy term of the Focal Loss to obtain the loss function used to train the dual-path Transformer model; principal component analysis is performed on the high-dimensional deep temporal representation output by the dual-path Transformer to reduce its dimensionality, resulting in a low-dimensional deep temporal representation; the low-dimensional deep temporal representation, the basic electricity consumption behavior feature matrix, and the random matrix theory-enhanced features are concatenated along the feature dimension to form a final fused feature matrix; the integrated classification and anomaly detection steps specifically include: training CatBoost, XGBoost, and LightGBM using hierarchical cross-validation. The classifiers are used to obtain the out-of-bounds prediction results and out-of-bounds AUC index of each classifier; the fusion weights are determined based on the squared normalized result of the out-of-bounds AUC of each classifier; the anomaly probability ranking values ​​output by each classifier are weighted and summed using the fusion weights to obtain the final user anomaly risk score.

[0021] Beneficial effects 1. This invention simultaneously characterizes individual behavior and group deviations, improving the ability to identify hidden anomalies, and introduces random matrix theory to enhance the ability to extract abnormal group signals.

[0022] 2. This invention uses a dual-path Transformer to address both local anomalies and long-term dependencies, integrating Transformer characterization with GBDT to improve overall detection performance.

[0023] 3. This invention is adapted to class imbalance scenarios and improves the ability to identify a small number of abnormal users. It shows good effectiveness and robustness on both the SGCC main dataset and the London comparison dataset. Attached Figure Description

[0024] Figure 1 This is a flowchart of the method of the present invention.

[0025] Figure 2 This is a flowchart of the data preprocessing and multi-source feature engineering process of the present invention.

[0026] Figure 3 This is a structural diagram of the random matrix theory signal enhancement module of the present invention.

[0027] Figure 4 This is a structural diagram of the random matrix theory signal enhancement module of the present invention.

[0028] Figure 5 This is a diagram of the Transformer representation and GBDT integration module of the present invention.

[0029] Figure 6 The figure shows the ablation experiment results of the SGCC main dataset of this invention.

[0030] Figure 7 This is a comparison experiment diagram of the SGCC main dataset model of this invention.

[0031] Figure 8 This is a heatmap comparing the detection performance of the GBDT ensemble model and the base classifier on the SGCC dataset of this invention.

[0032] Figure 9 This is a comparison chart of AUC for abnormal power consumption scenarios synthesized using the London dataset, based on the difficulty of data distribution in this invention.

[0033] Figure 10 This is a comparison chart of F1 scores for abnormal power consumption scenarios synthesized using the London dataset from this invention.

[0034] Figure 11 This is a bar chart showing the performance degradation of the London dataset model in this invention. Detailed Implementation

[0035] like Figure 1 As shown, this invention provides a method for detecting abnormal electricity consumption in smart meters based on the fusion of random matrix theory and dual-path Transformer representation. The method includes the following steps: Step 1: Data Acquisition and Preprocessing. Obtain long-term electricity consumption sequences for smart meter users and construct a user-time two-dimensional matrix. For the SGCC dataset, user electricity consumption sequences are arranged in daily units and include user identifiers and anomaly labels. First, identify missing values ​​and zero values ​​in the original matrix and construct missing value masks and zero value masks respectively. Then, calculate the missing value ratio, longest consecutive missing value length, difference in missing values ​​between different periods, zero value ratio, longest consecutive zero value length, and no-signal ratio for each user. Subsequently, use linear interpolation along the user's time direction to fill missing values, and use the mean of the same time column to fill positions where interpolation is not possible.

[0036] In one specific embodiment, the electricity consumption sequence of the i-th user over T consecutive sampling periods is represented as follows:

[0037] in, This represents the complete electricity consumption sequence of the i-th user. Let represent the electricity consumption of the i-th user in the t-th sampling period, and T represent the total number of sampling periods. Construct a missing indicator variable for the missing sampling points:

[0038] in, This represents the missing status of the i-th user in the t-th sampling period. It is set to 1 when the sampling point is missing, and 0 otherwise. The user's total missing rate across all periods can be expressed as:

[0039] in, This represents the percentage of missing sampling points for the i-th user throughout the entire period. The percentage of zero values ​​can be expressed as:

[0040] in, This represents the percentage of sampling points where the i-th user has zero electricity consumption throughout the entire cycle. This is an indicator function; it takes the value 1 when the condition within the parentheses is true, and 0 otherwise. To reduce the impact of extreme electricity consumption values ​​on subsequent modeling, a robust normalization method can be used:

[0041] in, This represents the normalized electricity consumption. This represents the median of the electricity consumption sequence for user i. This represents the interquartile range of user i's electricity consumption sequence. It is a very small constant used to avoid the denominator being zero.

[0042] Step 2: Multi-source electricity consumption behavior feature extraction. The complete electricity consumption sequence is aggregated monthly by fixed window to obtain the user's monthly electricity consumption matrix. The following parameters are extracted: monthly mean, monthly standard deviation, monthly maximum value, monthly zero-value ratio, monthly missing value ratio, deviation from the baseline mean of the previous few months, cumulative deviation, cross-user monthly ranking, deviation of user monthly ranking from the average ranking, user ranking changes between different periods, self-ratio, logarithmic deviation, rolling mean, rolling standard deviation, local Z-score, global deviation, first-order difference, second-order difference, and coefficient of variation. Further extraction is performed for weekday vs. weekend electricity consumption differences, summer / winter electricity consumption ratio, seasonality intensity, global statistical features, and multi-scale change point features.

[0043] In one specific embodiment, using D days as the aggregation window, the daily electricity consumption sequence is divided into M aggregation periods. The window for the i-th user in the j-th aggregation period is represented as follows:

[0044] Where D represents the number of sampling days contained in each aggregation window, and j represents the aggregation period number. This represents the subsequence of daily electricity consumption within this window. The monthly average can be expressed as:

[0045] in, This represents the average electricity consumption of the i-th user during the j-th aggregation period. The monthly standard deviation can be expressed as:

[0046] in, This represents the fluctuation in electricity consumption of the i-th user during the j-th aggregation period. The monthly zero-value ratio can be expressed as:

[0047] The monthly missing percentage can be expressed as:

[0048] in, This represents the proportion of sampling points where the electricity consumption of the i-th user is zero during the j-th aggregation period. This represents the proportion of missing sampling points for the i-th user during the j-th aggregation period.

[0049] Step 3: Random Matrix Theory Signal Enhancement. The monthly electricity consumption matrix is ​​standardized by user using the median and interquartile range, and a covariance matrix is ​​constructed and eigenvalue decomposition is performed. Significant signal directions are selected based on the Marchenko-Pastur spectral boundary. The monthly user sequences are projected onto both the significant signal subspace and the noise subspace, and the ratio of signal subspace energy to noise subspace energy is calculated to obtain the global signal-to-noise ratio (SNR) characteristics. Simultaneously, users are stratified according to their average electricity consumption level. Within each stratum, a local covariance matrix and signal subspace are constructed, and the proportion of a user's later monthly electricity consumption signal energy to the total signal energy over the entire cycle is calculated to obtain the later signal energy proportion characteristics.

[0050] In one specific embodiment, the standardized electricity consumption sequences of N users over T periods are constructed into a random matrix:

[0051] Where N represents the number of users, T represents the number of time periods, and each row of X corresponds to a user's standardized electricity consumption sequence. X is centered and standardized to obtain matrix Z, and a covariance matrix is ​​constructed:

[0052] in, The covariance matrix representing the electricity consumption behavior of a user group. Representation matrix The transpose of. For Perform eigenvalue decomposition:

[0053] in, The eigenvector matrix, The eigenvalue diagonal matrix can be represented as:

[0054] in, Let represent the k-th eigenvalue. Let the dimensionality ratio be:

[0055] The Marchenko-Pastur spectral boundary can then be represented as:

[0056]

[0057] in, and These represent the lower and upper boundaries of the random noise spectrum, respectively. This represents the noise variance estimate. Eigenvalues ​​greater than... The direction is divided into a signal subspace, and the location is... and The direction between them is divided into a noise subspace. The signal energy can be expressed as:

[0058] Noise energy can be expressed as:

[0059] The global signal-to-noise ratio can be expressed as:

[0060] in, Represents the energy of the significant signal subspace. Representing the noise subspace energy, SNR is used to measure the strength of structurally abnormal signals relative to random noise in the electricity consumption matrix of a user group.

[0061] Step 4: Construct a dual-path Transformer input sequence. A monthly multi-channel sequence is constructed as the Transformer input. Each user is represented as a two-dimensional sequence multiplied by the number of months and channels. Input channels include average monthly spending, monthly fluctuation, monthly peak, zero-value ratio, cross-user ranking, ranking deviation, ranking decline, baseline deviation, cumulative decline, logarithmic deviation, first-order difference, second-order difference, self-ratio, local Z-score, global deviation, monthly trajectory, and stratified deviation trajectory. The channel mean is further copied as a global scalar feature to each month and concatenated with the original monthly channels, thereby enhancing the global user behavior information in the sequence input.

[0062] Step 5: Dual-Path Transformer Deep Representation Extraction. The dual-path Transformer includes a local window attention branch and a global self-attention branch. The local window attention branch uses a striped attention mask to focus only on months within its neighboring window for each month, capturing short-term anomalous fluctuations over several consecutive months. The global self-attention branch appends a learnable class label vector to the sequence and models full-cycle dependencies through a multi-layer Transformer Encoder. The average pooled features from the local branch are concatenated with the class label vector output features from the global branch to obtain the user's deep temporal representation.

[0063] In one specific embodiment, for a monthly electricity consumption sequence:

[0064] in, This represents the monthly multi-channel electricity consumption behavior sequence of the i-th user. Indicates the month number. This represents the number of feature channels corresponding to each month. After inputting the projection and position encoding, we obtain:

[0065] in, This represents the initial hidden representation of the Transformer. For the input projection matrix, For bias terms, Position encoding. Local attention mask. The elements can be represented as: Local window attention can be represented as:

[0066] Where Q, K, and V represent the query matrix, key matrix, and value matrix, respectively. This represents the dimension of the key vector. The global branch employs multi-head self-attention:

[0067] The r-th attention head can be represented as:

[0068] Where h represents the number of attention heads, Indicates the output projection matrix. , , These are the query, key, and value projection matrices for the r-th attention head, respectively. Local branch pooling features. Global category label features Formed by splicing:

[0069] in, This represents the user's deep temporal representation.

[0070] Step 6: Transformer Training and Representation Dimensionality Reduction. Due to the low proportion of anomalous users, adaptive Focal Loss is used when training the dual-path Transformer. After model training, high-dimensional features are extracted by concatenating local and global representations, and then PCA is used for dimensionality reduction. These features are then input as deep temporal representations into the subsequent GBDT ensemble model.

[0071] In one specific embodiment, for the i-th user, their real tag is:

[0072] in, =1 indicates a user with abnormal electricity consumption. =0 indicates a normal electricity user. The model predicts an anomaly probability of... ,definition for:

[0073] That is, p_t represents the model's predicted probability of the true class. Adaptive Focal Loss can be expressed as:

[0074] in, Indicates training loss, This represents the total number of training samples. This represents the adaptive weight corresponding to the category to which the sample belongs. This is a focusing factor used to reduce the impact of easily classified samples on the loss. This is a very small constant used to avoid logarithmic errors. Class weights can be determined based on the number of samples from each class in the training set, for example:

[0075] in, This represents the weight of category c. Let be the number of samples in class c. The depth representation output by the Transformer can be denoted as: PCA projection matrix is ​​used get:

[0076] in, This represents the depth time series representation after dimensionality reduction.

[0077] Step 7: Feature Fusion Construction. The basic feature matrix, the random matrix theory-enhanced features, and the TransformerPCA representation are concatenated to obtain the final fused feature matrix. In a specific embodiment, the final fused feature matrix can be represented as:

[0078] Where F represents the fusion feature matrix that is finally input into the ensemble classifier. This represents a basic electricity consumption behavior feature matrix composed of statistical features, missing zero-value features, trend deviation features, ranking features, seasonality features, and change point features. This represents the enhanced feature matrix obtained from random matrix theory. This represents the depth time series representation after PCA compression.

[0079] Step 8: GBDT Ensemble Classification and Ranking Fusion. Based on the final fused feature matrix, three gradient boosting tree classifiers (CatBoost, XGBoost, and LightGBM) are trained respectively. Hierarchical five-fold cross-validation is used to obtain the out-of-fold prediction probability of each model. The square of the out-of-fold AUC of each model is used as the fusion weight to perform weighted fusion of the ranking values ​​of the prediction probabilities of each model, resulting in the final user anomaly risk score.

[0080] In one specific embodiment, let the out-of-bounds AUC of the m-th classifier be... Then the fusion weight can be expressed as:

[0081] in, This represents the fusion weight of the m-th classifier. Let represent the out-of-bounds AUC of the m-th classifier in cross-validation, and the denominator represent the sum of the squares of the out-of-bounds AUCs of all classifiers participating in the fusion. The final anomaly probability or risk score of the i-th user can be expressed as:

[0082] in, This represents the probability of an anomaly or the ranking score of the m-th classifier for the i-th user. This represents the final anomaly risk score after weighted fusion. The rules for determining anomalies can be expressed as:

[0083] in, This represents the risk threshold used for anomaly detection. When... Greater than or equal to the preset threshold If the user is identified as having abnormal electricity usage, the user will be classified as having normal electricity usage; otherwise, the user will be classified as having normal electricity usage.

[0084] It should be noted that in some metrics of the London comparison dataset, the method of this invention did not achieve optimal results compared to XGBoost or Random Forest in all AUC, F1, and degradation magnitude metrics. The main reason is that the abnormal electricity consumption labels in the London dataset experiment are not original, real abnormal labels, but rather constructed based on normal user electricity consumption sequences according to preset rules. These synthetic abnormal electricity consumption scenarios mainly exhibit regularized changes such as reduced electricity consumption in the latter half of the cycle, increased proportion of zero values, downward shift in the mean, or gradual decay. These changes can be directly reflected in manually statistical features such as monthly average, proportion of zero values, differences between preceding and following cycles, and ranking changes. Therefore, tree models such as XGBoost and Random Forest can more easily utilize explicit statistical features to form effective splitting rules, achieving better single-item results in some synthetic scenarios.

[0085] In contrast, the method of this invention integrates random matrix theory population spectral features, dual-path Transformer deep temporal representation, and GBDT ensemble discrimination. Its design goal is not only to target regularized synthetic anomalies, but also to address more complex, concealed, and diverse abnormal electricity consumption behaviors in real-world smart meter scenarios. On the London dataset, although the method of this invention did not achieve optimal results on all degradation metrics, it still maintained high AUC and F1 scores, indicating good generalization ability across external datasets and different levels of anomaly concealment. Furthermore, on the SGCC dataset with real anomaly labels, the method of this invention achieved optimal detection results, demonstrating its suitability for real-world abnormal electricity consumption detection scenarios with many missing zero values, significant differences in user behavior, and complex and irregular anomaly patterns.

[0086] To verify the effectiveness of the method of this invention, ablation experiments on the SGCC main dataset, model comparison experiments on the SGCC main dataset, and experiments on synthesizing abnormal power consumption scenarios with varying difficulty on the London comparison dataset were conducted. The evaluation metrics included AUC and F1, where AUC measures the model's overall ability to rank abnormal users, and F1 measures the comprehensive accuracy of anomaly identification in class-imbalanced scenarios. The experimental results in the following two tables were obtained from tests on the SGCC dataset.

[0087] Table 1

[0088] As shown in Table 1, after adding the enhanced features of random matrix theory and the deep representation of Transformer PCA to the basic feature matrix, the OOF AUC of the model is improved to 0.8760 and the OOF F1 is improved to 0.5170, indicating that the features of random matrix theory and the deep time series representation can provide complementary information for abnormal power consumption detection.

[0089] Table 2

[0090] Table 2 shows that Logistic Regression and MLP have low detection performance, indicating that simple linear boundary and shallow nonlinear models are insufficient to fully characterize abnormal electricity consumption behavior. Random Forest shows some improvement, but is still weaker than gradient boosting tree models. Single Transformer performs limitedly when lacking artificial features, random matrix theory enhancement, and ensemble discrimination. Unsupervised methods such as Isolation Forest and LOF are difficult to reliably identify hidden anomalies. The method of this invention achieves the highest AUC and F1 by fusing random matrix theory-enhanced features, dual-path Transformer deep representation, and GBDT ensemble discrimination.

[0091] To verify the detection capability of the method of this invention under abnormal electricity consumption behaviors with different levels of concealment, this invention constructed three types of synthetic abnormal electricity consumption scenarios based on the London smart meter dataset, denoted as simple, medium, and difficult. In each scenario, 10% of normal users were randomly selected as abnormal users, and abnormal electricity consumption changes were injected starting from the latter half of the electricity consumption sequence. The abnormal forms included randomly reduced electricity consumption, fixed low-value electricity consumption, periodic zero values, mean shift, random date zeroing, and gradual electricity consumption decay. The difficulty level was divided into three categories based on the magnitude of abnormal changes, the frequency of zero values, the intensity of electricity consumption decline, and the concealment of abnormal behavior. In the simple scenario, the magnitude of electricity consumption changes was large, the proportion of zero values ​​was high, and the downward trend was obvious, with significant differences between abnormal and normal users, thus the detection difficulty was low. In the medium scenario, the magnitude of abnormal changes was moderate, and some abnormal behaviors were masked by normal electricity consumption fluctuations, resulting in a moderate detection difficulty. In the difficult scenario, the magnitude of abnormal changes was small, the proportion of zero values ​​was low, and the gradual decay was closer to the natural fluctuations of normal users, resulting in the strongest concealment of abnormal behavior, thus the detection difficulty was the highest.

[0092] Specifically, simple scenarios correspond to clearly abnormal electricity consumption behavior: in the random reduction scenario, the electricity consumption in the second half of the cycle is scaled down to 10%-50% of the original value; in the fixed low value scenario, the lower quantile of the user's second half of the cycle is used as the replacement value; the periodic zero value occurs once every 2-4 days; the number of days with random zero values ​​accounts for 30%-50% of the second half of the cycle; and the gradual decay eventually drops to 10%-30% of the original level. These scenarios have large abnormal amplitudes and long durations, making them easy to distinguish from normal electricity consumption behavior.

[0093] Medium-level scenarios correspond to moderately hidden abnormal electricity consumption behavior: after random reduction, 50%-80% of the original value is retained; fixed low values ​​are replaced with higher quantiles; the periodic zero-value interval is extended to 5-10 days; the number of days with random zeroing accounts for 15%-25%; and the gradual attenuation ultimately retains 40%-60% of the original level. These scenarios still exhibit obvious abnormal characteristics, but some changes may be mixed with normal user load fluctuations, seasonal changes, or short-term electricity consumption declines.

[0094] Difficult scenarios correspond to highly concealed abnormal electricity consumption behaviors: after random reduction, 80%-95% of the original value is retained, the mean shift is small, the periodic zero value interval extends to 10-20 days, the number of days with random zero values ​​accounts for only 5%-12%, and the gradual decay ultimately retains 70%-90% of the original level. In these scenarios, abnormal changes are weak, the continuous decline is slow, and the overall pattern is close to the natural fluctuations of normal users, thus better testing the model's ability to identify subtle anomalies, gradual anomalies, and concealed anomalies.

[0095] Table 3

[0096] As shown in Table 3, the proposed method maintains high detection performance across the three difficulty levels (easy, medium, and hard) of synthesizing anomalous power consumption on the London comparison dataset. While the AUC and F1 score decrease as the concealment of anomalous power consumption behavior increases, the method still achieves an AUC of 0.9139 and an F1 score of 0.7473 on the Hard difficulty, indicating good generalization ability and robustness across datasets.

[0097] This invention proposes a method for detecting abnormal electricity consumption in smart meters based on the fusion of stochastic matrix theory and dual-path Transformer representation. The SGCC dataset is used as the primary validation dataset, while the London dataset is used for comparison and generalization validation. This method characterizes individual user behavior through multi-source feature engineering, extracts group spectral structure anomalies through stochastic matrix theory, learns local-global temporal representations through dual-path Transformer, and achieves final anomaly discrimination through GBDT weighted ranking ensemble. Experimental results show that this method can effectively improve the performance of abnormal electricity consumption detection in smart meters, and is particularly suitable for real-world power scenarios with class imbalance, concealed electricity theft, numerous missing zero values ​​in electricity consumption data, and significant differences in user behavior.

[0098] The above embodiments are merely preferred embodiments of the present invention and are not intended to limit the present invention. Any equivalent substitutions, simple modifications, or combinations made based on the technical essence of the present invention should fall within the protection scope of the present invention.

Claims

1. A method for detecting abnormal electricity consumption in smart meters based on the fusion of random matrix theory and dual-path Transformer representation, characterized in that, Includes the following steps: Step 1: Data Acquisition and Preprocessing; The system acquires the electricity consumption sequences of multiple electricity users' smart meters and their abnormal electricity consumption tags within a continuous time period, and constructs a user-time two-dimensional electricity consumption matrix. The system then identifies, marks, counts, and fills in the missing values, zero values, and abnormal sampling positions in the user-time two-dimensional electricity consumption matrix to obtain a standardized user electricity consumption time series. Step 2: Extraction of multi-source power consumption behavior features; Using the standardized user electricity consumption time series as the processing object, user statistical features, missing pattern features, zero value behavior features, monthly aggregation features, trend deviation features, cross-user relative ranking features, calendar features, seasonality features, and multi-scale change point features are extracted to form a basic electricity consumption behavior feature matrix. Step 3: Signal enhancement using random matrix theory; Using the user's monthly electricity consumption sequence corresponding to the monthly aggregated features as the processing object, a random matrix is ​​constructed; the random matrix is ​​robustly normalized, covariance matrix is ​​constructed and eigenvalue decomposition is performed, the signal subspace and noise subspace are divided according to the Marchenko-Pastur spectral boundary, and the theoretical enhancement features of the random matrix are extracted based on the subspace projection results; Step 4: Dual-path Transformer deep representation extraction; Using monthly multi-channel electricity consumption sequences as input, a dual-path Transformer model including a local window attention branch and a global self-attention branch is constructed. The local window attention branch extracts short-term abnormal fluctuation features within adjacent periods, and the global self-attention branch extracts long-term dependency features across periods. The outputs of the two branches are then fused to obtain a deep time series representation of the user. Step 5: Deep representation compression and fusion; The user deep temporal representation is dimensionality-reduced and compressed to obtain a low-dimensional deep temporal representation. The low-dimensional deep time series representation, the basic electricity consumption behavior feature matrix, and the random matrix theory enhanced features are concatenated to obtain the final fused feature matrix. Step 6: Integrating classification and anomaly detection: Train multiple gradient boosting classifiers using the final fused feature matrix as input; determine the fusion weights based on the validation performance of each classifier, and perform weighted fusion of the anomaly probabilities or anomaly ranking results output by multiple classifiers to obtain the user's abnormal power consumption detection results.

2. The method for detecting abnormal electricity consumption in smart meters based on the fusion of random matrix theory and dual-path Transformer representation as described in claim 1, characterized in that, The data acquisition and preprocessing steps specifically include: constructing a missing mask and a zero-value mask for the user's daily electricity consumption sequence; statistically analyzing the missing and zero-value distribution of users in the entire cycle, the first half of the cycle, and the second half of the cycle based on the missing mask and the zero-value mask; filling the interpolable missing points using interpolation along the time direction, and completing the remaining missing points using group statistical values ​​within the same time period to obtain a complete user electricity consumption sequence.

3. The method for detecting abnormal electricity consumption in smart meters based on the fusion of random matrix theory and dual-path Transformer representation as described in claim 2, characterized in that, The missing pattern features are obtained by statistical analysis of the missing mask and the zero-value mask, and include at least the user's full-cycle missing ratio, the longest consecutive missing ratio, the first half-cycle missing ratio, the second half-cycle missing ratio, the difference between missing and missing segments, the number of missing segments, the zero-value ratio, the longest consecutive zero-value ratio, and the no-signal ratio.

4. The method for detecting abnormal electricity consumption in smart meters based on the fusion of random matrix theory and dual-path Transformer representation as described in claim 1, characterized in that, The monthly aggregated features are obtained by using a preset number of days as the aggregation window to convert the standardized user electricity consumption time series into a monthly electricity consumption series; and extracting at least one monthly fluctuation statistic from the following within each aggregation window: monthly mean, monthly standard deviation, monthly maximum value, monthly zero value ratio, monthly missing value ratio, monthly range, coefficient of variation, rolling mean, or rolling standard deviation.

5. The method for detecting abnormal electricity consumption in smart meters based on the fusion of random matrix theory and dual-path Transformer representation as described in claim 1, characterized in that, The trend deviation features include relative benchmark deviation features and cumulative deviation features; wherein, the relative benchmark deviation features are obtained by using the electricity consumption statistics of the user in the previous several periods as an individual benchmark and calculating the degree of deviation of the current period's electricity consumption relative to the individual benchmark; the cumulative deviation features are obtained by accumulating the relative benchmark deviations of multiple periods, and are used to characterize the continuous decline or continuous deviation trend of the user's electricity consumption behavior.

6. The method for detecting abnormal electricity consumption in smart meters based on the fusion of random matrix theory and dual-path Transformer representation as described in claim 1, characterized in that, The cross-user relative ranking features include cross-user ranking features, ranking deviation features, and ranking decline features; wherein, the cross-user ranking features are obtained by sorting the electricity consumption of all users within the same time period; the ranking deviation features are obtained by calculating the difference between a user's current ranking and its historical average ranking; and the ranking decline features are obtained by comparing a user's ranking in the previous period and its ranking in the subsequent period.

7. The method for detecting abnormal electricity consumption in smart meters based on the fusion of random matrix theory and dual-path Transformer representation as described in claim 1, characterized in that, The specific steps of the random matrix theory signal enhancement include: robustly standardizing and centering the user's monthly electricity consumption matrix to construct a group covariance matrix; performing eigenvalue decomposition on the group covariance matrix to obtain eigenvalues ​​and their corresponding eigenvectors; dividing the eigenvectors into a salient signal subspace and a noise subspace based on the Marchenko-Pastur spectral boundary; projecting the user's monthly electricity consumption sequence onto the salient signal subspace and the noise subspace respectively, and extracting signal energy, noise energy, and global signal-to-noise ratio features based on the projection results.

8. The method for detecting abnormal electricity consumption in smart meters based on the fusion of random matrix theory and dual-path Transformer representation as described in claim 7, characterized in that, The enhanced features of the random matrix theory also include the feature of the proportion of energy in the later stage of the signal; the feature of the proportion of energy in the later stage of the signal is obtained by: stratifying users according to the average electricity consumption level or historical electricity consumption scale, constructing a significant signal subspace in each stratum; projecting the user's later monthly electricity consumption sequence to the significant signal subspace of the corresponding stratum, and calculating the proportion of the later projected energy to the total projected energy.

9. The method for detecting abnormal electricity consumption in smart meters based on the fusion of random matrix theory and dual-path Transformer representation as described in claim 1, characterized in that, The dual-path Transformer model includes an input projection layer, a position encoding layer, a local window attention module, a global Transformer encoding module, a class label vector, and a classification output layer. The input projection layer maps the monthly multi-channel sequence to a unified hidden dimension. The position encoding layer injects monthly order information into the mapped sequence. The local window attention module extracts neighboring month dependency features based on a local attention mask. The global Transformer encoding module aggregates full-cycle electricity consumption behavior information through class label vectors and a multi-head self-attention mechanism, ensuring that the i-th month only performs attention calculations with months within a preset window range, thus obtaining local window attention features and enhancing the model's ability to perceive continuous short-term abnormal fluctuations. The global Transformer encoding module adds a learnable class label vector before the monthly electricity consumption behavior sequence, encodes the full-cycle monthly electricity consumption behavior sequence after adding class labels through a multi-head self-attention mechanism, and uses the output corresponding to the class label vector as a global temporal representation.

10. The method for detecting abnormal electricity consumption in smart meters based on the fusion of random matrix theory and dual-path Transformer representation as described in claim 1, characterized in that, The dual-path Transformer deep representation is obtained as follows: pooling the sequence features output by the local window attention branch to obtain a local temporal representation; obtaining the output features corresponding to the category label vector in the global self-attention branch to obtain a global temporal representation; concatenating the local and global temporal representations to obtain the user deep temporal representation. The dual-path Transformer is trained using adaptive Focal Loss. Specifically, the category weights are determined based on the number of normal and abnormal electricity consumption samples, and these weights are incorporated into the cross-entropy term of the Focal Loss to obtain the loss function used to train the dual-path Transformer model. Principal component analysis is performed to reduce the dimensionality of the high-dimensional deep temporal representation output by the dual-path Transformer to obtain a low-dimensional deep temporal representation. The low-dimensional deep temporal representation, the basic electricity consumption behavior feature matrix, and the random matrix theory-enhanced features are concatenated along the feature dimension to form the final fused feature matrix. The integrated classification and anomaly detection steps specifically include: training CatBoost, XGBoost, and LightGBM using hierarchical cross-validation. The classifiers are used to obtain the out-of-bounds prediction results and out-of-bounds AUC index of each classifier; the fusion weights are determined based on the squared normalized result of the out-of-bounds AUC of each classifier; the anomaly probability ranking values ​​output by each classifier are weighted and summed using the fusion weights to obtain the final user anomaly risk score.