Power consumption anomaly detection method based on time-frequency behavior mismatch analysis

By analyzing time-frequency behavior mismatch, a hierarchical graph convolutional variational autoencoder model was constructed, which solved the accuracy problem of electricity consumption sub-sector classification and anomaly detection, and achieved dynamic adaptability and efficient electricity consumption anomaly detection.

CN121456731APending Publication Date: 2026-02-03TAIAN POWER SUPPLY CO OF STATE GRID SHANDONG ELECTRIC POWER CO
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511337329.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-18
Publication Date
2026-02-03

AI Technical Summary

Technical Problem

Existing technologies cannot accurately distinguish between different electricity consumption sub-sectors, static feature modeling leads to high false alarm rates, poor anomaly detection adaptability, and fail to effectively integrate time-series load data with industry-level relationships, making it difficult to cope with complex electricity consumption behavior patterns.

Method used

A time-frequency behavior mismatch analysis-based approach is adopted. Through multimodal feature extraction and dynamic frequency band discovery, a hierarchical graph convolutional variational autoencoder model is constructed. Dynamic hierarchical center constraints and graph guidance are introduced to train a multi-objective model, thereby achieving hierarchical classification and time-frequency consistency anomaly detection.

Benefits of technology

It achieves fine-grained classification, dynamically adapts to changes in industry electricity consumption characteristics, reduces false alarm and false alarm rates, and provides more accurate user behavior analysis support.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121456731A_ABST
    Figure CN121456731A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of power grid dispatching, in particular to a power consumption anomaly detection method based on time-frequency behavior mismatch analysis, which comprises the following steps of: 1, extracting a multi-modal feature and discovering a dynamic frequency band; step 2, constructing a hierarchical graph convolution variation auto-encoder model; 3, introducing dynamic hierarchy center constraint and map guidance; step 4, multi-objective model training and optimization; step 5, performing hierarchical classification and time-frequency consistency anomaly detection; the method aims at solving the technical problem that in the prior art, dynamic evolution of industry electricity utilization characteristics cannot be captured, fine-grained user electricity utilization behavior modes can be deeply mined through linkage analysis of multi-dimensional data, and powerful technical support is provided for more accurate and intelligent user behavior analysis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of power grid dispatching technology, and in particular to a method for detecting abnormal power consumption based on time-frequency behavior mismatch analysis. Background Technology

[0002] With the deepening of smart grid construction and the rapid development of power big data technology, refined management and intelligent analysis of electricity load have become crucial aspects of power system operation. A search reveals that existing Chinese patents, such as "Methods, Devices, Equipment and Storage Media for Fine-Grained Classification of Electricity Users" (publication number CN115809406B), while using a VAE model, do not consider the hierarchical relationships between industries, failing to achieve knowledge transfer between similar industries. This invention addresses this issue through an industry relationship graph. Existing Chinese patents, such as "Electricity Behavior Diagnosis System and Method Based on Anomaly Detection Model" (publication number CN119918005A), may suffer from insufficient granularity in electricity user classification, making it difficult to distinguish differences in electricity consumption across sub-sectors and failing to effectively capture dynamic changes in industry electricity consumption characteristics. Current mainstream electricity consumption analysis technologies suffer from the following problems:

[0003] 1. Coarse classification granularity: Traditional methods can only classify industries into broad categories such as industry and commerce, and cannot distinguish the differences in electricity consumption among sub-sectors under these broad categories (such as retail and catering in commerce), making fine-grained differentiation difficult;

[0004] 2. Static feature modeling: Relies on fixed thresholds or statistical features, which can easily lead to a high false positive rate due to industry differences;

[0005] 3. Poor adaptability of anomaly detection: The detection method based on a global fixed threshold ignores the differences in electricity consumption benchmarks across different industries, resulting in a high false alarm rate (e.g., normal fluctuations of high-energy-consuming industrial users may be misjudged as anomalies).

[0006] 4. Insufficient data utilization: The relationship between time-series load data (such as 24-hour power curves) and industry hierarchy is not effectively integrated, making it difficult to uncover fine-grained behavioral patterns.

[0007] It is difficult to cope with the challenges of increasingly complex electricity consumption patterns and massive data processing. Especially in the context of the construction of new electricity markets, more accurate and intelligent user behavior analysis technologies are needed.

[0008] Currently, accurate classification of electricity users and detection of abnormal electricity consumption have become core requirements for intelligent operation of the power grid. The core shortcomings of existing technologies are: ① poor modeling ability for the dynamic evolution of industry electricity consumption characteristics; ② insufficient hierarchical classification systems to support fine-grained user grouping; and ③ failure to incorporate industry-specific benchmarks in anomaly detection, resulting in insufficient detection accuracy and generalization ability. Therefore, an anomaly detection method is needed that can dynamically learn industry characteristics, support fine-grained classification, and adapt to industry differences. Based on this, this invention proposes an electricity consumption anomaly detection method based on time-frequency behavior mismatch analysis, specifically a fine-grained classification and anomaly detection method and system for electricity users based on the dynamic evolution of industry characteristics. Summary of the Invention

[0009] The purpose of this invention is to address the shortcomings of the prior art by proposing a power consumption anomaly detection method based on time-frequency behavior mismatch analysis.

[0010] To achieve the above objectives, the technical solution adopted by this invention is: a method for detecting abnormal power consumption based on time-frequency behavioral mismatch analysis, comprising the following steps:

[0011] Step 1: Multimodal Feature Extraction and Dynamic Frequency Band Discovery: Define a tree-like hierarchical mapping relationship between major and minor industry categories; clean the user's time-series electricity consumption data, including outlier correction, missing value imputation, and normalization based on industry grouping; perform spectral analysis on the historical load curves of each major industry category to automatically identify the most representative key frequency bands for that industry; extract the time-domain load characteristics and frequency-domain energy characteristics of each user in the key frequency bands of their respective industry, and concatenate them to form a multimodal feature vector;

[0012] Step 2: Construct a hierarchical graph convolutional variational autoencoder model: Concatenate the multimodal feature vectors with the semantic vectors of the major and minor industry categories obtained through the embedding layer to form a fused feature vector; map the fused feature vector to the latent space through the encoder to obtain the mean μ and variance σ² of the latent variables; construct an industry relationship graph based on the industry hierarchy, use a graph convolutional network to enhance the features of the latent variables, and aggregate neighboring industry information; simultaneously reconstruct the time-domain load curve and the frequency-domain feature vector through the multimodal decoder.

[0013] Step 3: Introducing Dynamic Hierarchical Center Constraints and Graph Guidance: During model training, learnable dynamic center parameters are introduced for each industry category and subcategory; the mean μ of each user's latent variable is constrained to converge to the center of its respective industry category and subcategory through a loss function; the industry center parameters are dynamically updated using an exponential moving average algorithm; and the latent representation learning is guided by an industry relationship graph to enhance the similarity of representations within the same industry.

[0014] Step 4, Multi-objective model training and optimization: The model is trained using a comprehensive loss function that integrates temporal reconstruction loss, frequency domain reconstruction loss, KL divergence loss and hierarchical center constraint loss. Semantic information is conveyed through industry relationship graphs to improve the model's generalization ability.

[0015] Step 5: Hierarchical Classification and Time-Frequency Consistency Anomaly Detection: For the user to be tested, the trained model is used to extract their latent features. First, the comprehensive similarity score between the user and the typical feature curves of each industry category is calculated to determine the major category. Then, matching is performed within the set of minor categories corresponding to the predicted major category to determine the final minor category classification result. Based on the classification result, the consistency score between the user's current time-domain and frequency-domain features and their own historical behavior is calculated. Combined with the distance between their latent features and the industry dynamic center, a dual judgment is performed. The dual judgment includes: first, anomaly detection based on time-frequency behavior consistency; second, anomaly detection based on industry benchmark distance. When either detection result is judged as anomaly, the user's behavior is ultimately judged as abnormal.

[0016] Step Six: System Implementation and Multimodal Output: This step involves generating model evaluation reports, visualizing industry relationship graphs, displaying multimodal reconstruction results, and archiving classification and anomaly detection information for retrospective analysis.

[0017] Preferably, the industry classification hierarchy definition and dynamic frequency band discovery in step one includes the following steps:

[0018] Hierarchical structure modeling: Defines the tree-like mapping relationship between major and minor industry categories, including major categories such as agriculture, residential, and retail, and their corresponding subcategories. It also supports the automatic classification of unknown categories into the "other" category, ensuring the integrity and scalability of the classification system.

[0019] Bidirectional mapping construction: Establish a bidirectional index relationship between major and minor classes to facilitate subsequent hierarchical constraint modeling and graph construction;

[0020] Industry spectrum analysis: Perform fast Fourier transform on the historical load curves of each major industry category, calculate the average power spectral density, and identify the characteristic frequency bands that characterize the electricity consumption patterns of the industry.

[0021] Dynamic frequency band extraction: Based on the spectrum peak detection algorithm, it automatically discovers the N most representative key frequency bands of each industry category and dynamically adjusts the frequency band selection as the data distribution changes.

[0022] Preferably, the time-series data cleaning and feature engineering includes:

[0023] Outlier Correction: For hourly data in each industry, outliers are identified based on IQR. Outliers are corrected by threshold truncation; that is, values ​​greater than "upper" are corrected to "upper," and values ​​less than "lower" are corrected to "lower." The formula is as follows:

[0024]

[0025] Where Q1 and Q3 are the 25th and 75th percentiles, respectively, and IQR = Q3 - Q1;

[0026] Missing value imputation: Missing values ​​in time series data are imputed using the industry group median. Specifically, for users within the same industry category, the median of non-missing values ​​for that industry is used for imputation. The formula is:

[0027]

[0028] Fill the remaining missing values ​​with the global median;

[0029] Normalization: Time series data are normalized to the [0,1] interval using MinMaxScaler to eliminate the influence of units and accelerate model convergence. The formula is as follows:

[0030]

[0031] Frequency domain feature extraction: Perform a Fast Fourier Transform on the load curve of each user to calculate its energy intensity in the key frequency band of its industry. The formula is as follows:

[0032]

[0033] Where X(f) is the spectral amplitude at frequency f. This refers to the key frequency bands in the industry.

[0034] Multimodal feature construction: The time-domain load feature vector and the frequency-domain energy feature vector are concatenated to form the final multimodal feature representation, as shown in the formula:

[0035]

[0036] in It is a 24-dimensional time-domain feature. It represents the N-dimensional frequency domain features, where N is the number of key frequency bands.

[0037] Preferably, the industry embedding layer includes:

[0038] Hierarchical semantic encoding: The industry category code and industry sub-category code are mapped to low-dimensional dense vectors through the embedding layer: the major category embedding dimension is major_embed_dim=4 to capture the macro features of the industry, and the minor category embedding dimension is minor_embed_dim=8 to capture the details of the sub-field.

[0039] Multimodal feature fusion: The temporal feature vector, frequency domain feature vector, and industry embedding vector are concatenated and used as encoder input. The input dimension is 24+N+4+8, where N is the number of key frequency bands extracted. The formula is:

[0040]

[0041] in, It is a 24-dimensional time-domain feature vector. It is an N-dimensional frequency domain eigenvector.

[0042] Preferably, the encoder and the potential space include:

[0043] Multimodal feature extraction network: A high-level representation of fused features is extracted through a two-layer fully connected network. The network structure is (input_dim + 12) → 64 → 32, where input_dim = 24 + N. The activation function is LeakyReLU (negative slope 0.1), and Dropout (p=0.2) is introduced to prevent overfitting. The calculation process is as follows:

[0044]

[0045] ;

[0046] Probability distribution modeling: Output the mean μ and logarithm logσ² of the latent space for variational inference, sampling the latent variable z through reparameterization techniques.

[0047] Preferably, the multimodal decoder and dual reconstruction in step two include:

[0048] Multimodal feature decoding network: After concatenating the latent variable z, graph convolutional enhanced features, and industry embedding vectors, the decoding network simultaneously reconstructs the time-domain load curve and frequency-domain feature vector.

[0049]

[0050]

[0051] Dual reconstruction loss function: The time-domain reconstruction loss and frequency-domain reconstruction loss are calculated separately using the mean square error, and the formula is as follows:

[0052] .

[0053] Preferably, the dynamic hierarchical center constraint and graph guidance in step three include:

[0054] Dynamic Industry Centers: Learnable parameters `major_centers` and `minor_centers` are introduced. `major_centers` represents the major category centers, and `minor_centers` represents the minor category centers. The latent variables are constrained to converge towards their respective industry centers using MSE loss.

[0055]

[0056] Where, m i mi i The major and minor class codes for sample i;

[0057] Industry center update mechanism: During training, the industry center is dynamically updated using an exponential moving average. The formula is: New center = 0.9 * Old center + 0.1 * Mean of similar samples in the current batch.

[0058]

[0059] Industry Graph Guidance: Utilizing pre-built industry relationship graphs, latent representation learning is enhanced through graph convolutional networks, aggregating semantically similar neighboring industry information, and strengthening the similarity of representations of similar industries.

[0060] Preferably, the multi-objective model training and optimization in step four includes:

[0061] Multi-objective loss function: fusion of temporal reconstruction loss, frequency reconstruction loss, KL divergence, and hierarchical center constraint loss, the formula is:

[0062]

[0063] Among them, KL divergence measures the difference between the latent distribution and the standard normal distribution, and the hierarchical constraint weights are 0.3 / 0.7;

[0064] The optimization strategy includes:

[0065] The AdamW optimizer is used with a learning rate of lr=1e-4 and weight decay of weight_decay=1e-5 to suppress overfitting. The ReduceLROnPlateau strategy based on validation loss is used. When the validation loss has not decreased for 3 consecutive rounds, the learning rate is decayed to 50% of the current value. The gradient norm is limited to ≤1.0 by clip_grad_norm to prevent gradient explosion.

[0066] The data partitioning and training process includes:

[0067] A two-stage stratification approach is adopted to ensure a balanced industry distribution of the training set, validation set, or test set: First, the training and validation sets are divided into test sets in an 8:2 ratio, based on the major category coding. Then, the training and validation sets are divided into training and validation sets in a 75:25 ratio, also based on the major category coding. The training adopts an early stopping mechanism: when the validation loss has not improved for 5 consecutive rounds, the training is terminated early to save the optimal model parameters.

[0068] Preferably, the hierarchical classification and time-frequency consistency anomaly detection in step five include:

[0069] Hierarchical classification assessment: For each valid industry, latent variable samples are generated through VAE, and the mean curve is calculated after decoding as the typical feature of the industry; when making category prediction, the comprehensive similarity score between the time series curve of the test sample and the typical curve of each category is calculated: When making category prediction, the comprehensive score between the time series curve of the test sample and the typical curve of each category is calculated using the formula: Score=0.4·DTW+0.5·MSE-0.1·Corr, where DTW is the dynamic time warping distance, MSE is the mean squared error, and Corr is the Pearson correlation coefficient. The weights reflect the emphasis on the curve shape DTW and the numerical difference MSE.

[0070] The category with the lowest overall score is selected as the prediction result. Sub-category prediction is then performed, matching only within the set of sub-categories corresponding to the predicted major category to narrow the search space. The method is consistent with the major category prediction. Finally, the sub-category prediction result is output. The anomaly detection mechanism includes:

[0071] Time-frequency behavior consistency detection: Record the time-domain and frequency-domain features of the user in the most recent T periods, and calculate the current time-domain features. With historical time domain characteristics DTW distance and current frequency domain characteristics Historical frequency domain characteristics Cosine distance; Overall score The average of the two distances reflects the difference between the user's electricity consumption behavior and their own historical patterns. If the overall score exceeds the industry average + 3σ, it is marked as a potential anomaly.

[0072] ;

[0073] Industry mean and standard deviation: The DTW distance distribution of all users in each industry is calculated using the training set to obtain the industry-specific normal fluctuation range;

[0074] Time window T: Set according to industry characteristics;

[0075] The industry benchmark distance assessment uses the major_centers and minor_centers obtained from model training, which are the mean vectors of the industry in the latent space. The user's current temporal features are then input into a hierarchical variational autoencoder model to obtain latent variables. ,calculate Euclidean distance from the center of the industry If the distance exceeds the industry center distance average + 2σ, it is considered abnormal.

[0076] Preferably, the system implementation and multimodal output in step six include:

[0077] Multimodal evaluation report generation: Outputs the accuracy, recall, and F1 score for major and minor classes, and generates classification reports and anomaly detection reports;

[0078] Persistent data storage: Optimal model parameters are saved via torch.save, and preprocessed objects and evaluation results are saved via joblib; multimodal information such as user ID, real label, predicted label, anomaly score, and time-frequency features are saved to data files, supporting backtracking analysis.

[0079] Compared with the prior art, the present invention has the following beneficial effects:

[0080] 1. This invention can precisely distinguish the differences in electricity consumption among sub-sectors under a major category, enabling more refined granular classification;

[0081] 2. This invention can capture the dynamic adaptive capability of industry electricity consumption characteristics to the complex electricity consumption characteristics of different industries, providing a more detailed data foundation for electricity market analysis, user behavior research, etc., and promoting the transformation of electricity services towards refinement and personalization;

[0082] 3. The anomaly detection of this invention adopts a dual judgment standard. By combining the consistency of users' historical behavior and the deviation from industry benchmarks, it achieves "personalization" and "industry adaptability" of anomaly detection, thereby reducing the false alarm rate and the false negative rate.

[0083] 4. This invention effectively integrates time-series load data (such as 24-hour power curves) with industry-level relationships. Through multi-dimensional data linkage analysis, it can deeply explore fine-grained user electricity consumption behavior patterns, providing strong technical support for more accurate and intelligent user behavior analysis.

[0084] 5. This invention breaks through the limitations of static processing. By using learnable dynamic industry center parameters and the center update mechanism of exponential moving average, combined with industry grouping data processing logic, it adapts to the dynamic changes in industry electricity consumption characteristics in real time, replacing the traditional static threshold or globally unified processing method, and greatly improving the modeling ability and system adaptability of the dynamic evolution process of industry characteristics. Attached Figure Description

[0085] Figure 1 This is a system architecture and workflow diagram of the power consumption anomaly detection method based on time-frequency behavior mismatch analysis of the present invention.

[0086] Figure 2 This is an industry-level hierarchical classification tree diagram of the power consumption anomaly detection method based on time-frequency behavior mismatch analysis of the present invention;

[0087] Figure 3 This is a flowchart of the multimodal feature extraction and dynamic frequency band discovery process of the power consumption anomaly detection method based on time-frequency behavior mismatch analysis of the present invention.

[0088] Figure 4 This is a diagram of the hierarchical graph convolutional variational autoencoder (HGVAE) model structure of the power consumption anomaly detection method based on time-frequency behavior mismatch analysis of the present invention.

[0089] Figure 5 This is a schematic diagram illustrating the time-frequency consistency anomaly detection principle of the power consumption anomaly detection method based on time-frequency behavior mismatch analysis of the present invention.

[0090] Figure 6 This is a schematic diagram of the hierarchical classification decision-making process of the power consumption anomaly detection method based on time-frequency behavior mismatch analysis of the present invention;

[0091] Figure 7 This is part of the data generated by the power consumption anomaly detection method based on time-frequency behavior mismatch analysis of the present invention;

[0092] Figure 8 This is a classification report generated by the power consumption anomaly detection method based on time-frequency behavior mismatch analysis of the present invention;

[0093] Figure 9 This is a loss data graph of the power consumption anomaly detection method based on time-frequency behavior mismatch analysis of the present invention;

[0094] Figure 10 This is a general result diagram of the power consumption anomaly detection method based on time-frequency behavior mismatch analysis of the present invention.

[0095] Figure 11 This is a subclass result diagram of the power consumption anomaly detection method based on time-frequency behavior mismatch analysis of the present invention;

[0096] Figure 12This is a weighted coefficient diagram of various industries to be welded in the power consumption anomaly detection method based on time-frequency behavior mismatch analysis of this invention. Detailed Implementation

[0097] The following description is intended to disclose the invention and enable those skilled in the art to implement it. The preferred embodiments described below are merely examples, and other obvious variations will occur to those skilled in the art.

[0098] like Figures 1-12 The power consumption anomaly detection method based on time-frequency behavior mismatch analysis shown includes the following steps:

[0099] Step 1: Multimodal Feature Extraction and Dynamic Frequency Band Discovery: Define a tree-like hierarchical mapping relationship between major and minor industry categories; clean the user's time-series electricity consumption data, including outlier correction, missing value imputation, and normalization based on industry grouping; perform spectral analysis on the historical load curves of each major industry category to automatically identify the most representative key frequency bands for that industry; extract the time-domain load characteristics and frequency-domain energy characteristics of each user in the key frequency bands of their respective industry, and concatenate them to form a multimodal feature vector;

[0100] Step 2: Construct a hierarchical graph convolutional variational autoencoder model: Concatenate the multimodal feature vectors with the semantic vectors of the major and minor industry categories obtained through the embedding layer to form a fused feature vector; map the fused feature vector to the latent space through the encoder to obtain the mean μ and variance σ² of the latent variables; construct an industry relationship graph based on the industry hierarchy, use a graph convolutional network to enhance the features of the latent variables, and aggregate neighboring industry information; simultaneously reconstruct the time-domain load curve and the frequency-domain feature vector through the multimodal decoder.

[0101] Step 3: Introduce dynamic hierarchical center constraints and graph guidance: During model training, learnable dynamic center parameters are introduced for each industry category and subcategory; the mean μ of each user's latent variable is constrained to converge to the center of its industry category and subcategory through the loss function; the industry center parameters are dynamically updated using the exponential moving average algorithm; and the latent representation learning is guided by the industry relationship graph to enhance the similarity of representations of the same industry.

[0102] Step 4, Multi-objective model training and optimization: The model is trained using a comprehensive loss function that integrates temporal reconstruction loss, frequency domain reconstruction loss, KL divergence loss and hierarchical center constraint loss. Semantic information is conveyed through industry relationship graphs to improve the model's generalization ability.

[0103] Step 5, Hierarchical Classification and Time-Frequency Consistency Anomaly Detection: For the user to be tested, the trained model is used to extract its latent features. First, the comprehensive similarity score between the user and the typical feature curves of each industry category is calculated to determine the major category. Then, matching is performed within the set of minor categories corresponding to the predicted major category to determine the final minor category classification result. Based on the classification result, the consistency score between the user's current time domain and frequency domain features and its own historical behavior is calculated. Combined with the distance between its latent features and the industry dynamic center, a dual judgment is made.

[0104] Step Six: System Implementation and Multimodal Output: This step involves generating model evaluation reports, visualizing industry relationship graphs, displaying multimodal reconstruction results, and archiving classification and anomaly detection information for retrospective analysis.

[0105] Step one, defining the industry classification hierarchy and discovering dynamic frequency bands, includes the following steps:

[0106] Hierarchical structure modeling: Defines the tree-like mapping relationship between major and minor industry categories, including major categories such as agriculture, residential, and retail, and their corresponding subcategories. It also supports the automatic classification of unknown categories into the "other" category, ensuring the integrity and scalability of the classification system.

[0107] Bidirectional mapping construction: Establish a bidirectional index relationship between major and minor classes to facilitate subsequent hierarchical constraint modeling and graph construction;

[0108] Industry spectrum analysis: Perform fast Fourier transform on the historical load curves of each major industry category, calculate the average power spectral density, and identify the characteristic frequency bands that characterize the electricity consumption patterns of the industry.

[0109] Dynamic frequency band extraction: Based on the spectrum peak detection algorithm, it automatically discovers the N most representative key frequency bands of each industry category and dynamically adjusts the frequency band selection as the data distribution changes.

[0110] Time series data cleaning and feature engineering include:

[0111] Outlier Correction: For hourly data in each industry, outliers are identified based on IQR. Outliers are corrected by threshold truncation; that is, values ​​greater than "upper" are corrected to "upper," and values ​​less than "lower" are corrected to "lower." The formula is as follows:

[0112]

[0113] Where Q1 and Q3 are the 25th and 75th percentiles, respectively, and IQR = Q3 - Q1;

[0114] Missing value imputation: Missing values ​​in time series data are imputed using the industry group median. Specifically, for users within the same industry category, the median of non-missing values ​​for that industry is used for imputation. The formula is:

[0115]

[0116] Fill the remaining missing values ​​with the global median;

[0117] Normalization: Time series data are normalized to the [0,1] interval using MinMaxScaler to eliminate the influence of units and accelerate model convergence. The formula is as follows:

[0118]

[0119] Frequency domain feature extraction: Perform a Fast Fourier Transform on the load curve of each user to calculate its energy intensity in the key frequency band of its industry. The formula is as follows:

[0120]

[0121] Where X(f) is the spectral amplitude at frequency f. This refers to the key frequency bands in the industry.

[0122] Multimodal feature construction: The time-domain load feature vector and the frequency-domain energy feature vector are concatenated to form the final multimodal feature representation, as shown in the formula:

[0123]

[0124] in It is a 24-dimensional time-domain feature. It represents the N-dimensional frequency domain features, where N is the number of key frequency bands.

[0125] The industry embedding layer includes:

[0126] Hierarchical semantic encoding: The industry category code and industry sub-category code are mapped to low-dimensional dense vectors through the embedding layer: the major category embedding dimension is major_embed_dim=4 to capture the macro features of the industry, and the minor category embedding dimension is minor_embed_dim=8 to capture the details of the sub-field.

[0127] Multimodal feature fusion: The temporal feature vector, frequency domain feature vector, and industry embedding vector are concatenated and used as encoder input. The input dimension is 24+N+4+8, where N is the number of key frequency bands extracted. The formula is:

[0128]

[0129] in, It is a 24-dimensional time-domain feature vector. It is an N-dimensional frequency domain eigenvector.

[0130] The encoder and potential space include:

[0131] Multimodal feature extraction network: A high-level representation of fused features is extracted through a two-layer fully connected network. The network structure is (input_dim + 12) → 64 → 32, where input_dim = 24 + N. The activation function is LeakyReLU (negative slope 0.1), and Dropout (p=0.2) is introduced to prevent overfitting. The calculation process is as follows:

[0132]

[0133] ;

[0134] Probability distribution modeling: Output the mean μ and logarithm logσ² of the latent space for variational inference, sampling the latent variable z through reparameterization techniques.

[0135] Step two, the multimodal decoder and dual reconstruction, includes:

[0136] Multimodal feature decoding network: After concatenating the latent variable z, graph convolutional enhanced features, and industry embedding vectors, the decoding network simultaneously reconstructs the time-domain load curve and frequency-domain feature vector.

[0137]

[0138]

[0139] Dual reconstruction loss function: The time-domain reconstruction loss and frequency-domain reconstruction loss are calculated separately using the mean square error, and the formula is as follows:

[0140] .

[0141] Step three, dynamic hierarchical center constraints and graph guidance, includes:

[0142] Dynamic Industry Centers: Learnable parameters `major_centers` and `minor_centers` are introduced. `major_centers` represents the major category centers, and `minor_centers` represents the minor category centers. The latent variables are constrained to converge towards their respective industry centers using MSE loss.

[0143]

[0144] Where, m i mi i The major and minor class codes for sample i;

[0145] Industry center update mechanism: During training, the industry center is dynamically updated using an exponential moving average. The formula is: New center = 0.9 * Old center + 0.1 * Mean of similar samples in the current batch.

[0146]

[0147] Industry Graph Guidance: Utilizing pre-built industry relationship graphs, latent representation learning is enhanced through graph convolutional networks, aggregating semantically similar neighboring industry information, and strengthening the similarity of representations of similar industries.

[0148] Step four, multi-objective model training and optimization, includes:

[0149] Multi-objective loss function: fusion of temporal reconstruction loss, frequency reconstruction loss, KL divergence, and hierarchical center constraint loss, the formula is:

[0150]

[0151] Among them, KL divergence measures the difference between the latent distribution and the standard normal distribution, and the hierarchical constraint weights are 0.3 / 0.7;

[0152] Optimization strategies include:

[0153] The AdamW optimizer is used with a learning rate of lr=1e-4 and weight decay of weight_decay=1e-5 to suppress overfitting. The ReduceLROnPlateau strategy based on validation loss is used. When the validation loss has not decreased for 3 consecutive rounds, the learning rate is decayed to 50% of the current value. The gradient norm is limited to ≤1.0 by clip_grad_norm to prevent gradient explosion.

[0154] The data partitioning and training process includes:

[0155] A two-stage stratification approach is adopted to ensure a balanced industry distribution of the training set, validation set, or test set: First, the training and validation sets are divided into test sets in an 8:2 ratio, based on the major category coding. Then, the training and validation sets are divided into training and validation sets in a 75:25 ratio, also based on the major category coding. The training adopts an early stopping mechanism: when the validation loss has not improved for 5 consecutive rounds, the training is terminated early to save the optimal model parameters.

[0156] Step five, the hierarchical classification and time-frequency consistency anomaly detection, includes:

[0157] Hierarchical classification assessment: For each valid industry, latent variable samples are generated through VAE, and the mean curve is calculated after decoding as the typical feature of the industry; when making category prediction, the comprehensive similarity score between the time series curve of the test sample and the typical curve of each category is calculated: When making category prediction, the comprehensive score between the time series curve of the test sample and the typical curve of each category is calculated using the formula: Score=0.4·DTW+0.5·MSE-0.1·Corr, where DTW is the dynamic time warping distance, MSE is the mean squared error, and Corr is the Pearson correlation coefficient. The weights reflect the emphasis on the curve shape DTW and the numerical difference MSE.

[0158] The category with the lowest overall score is selected as the prediction result. Sub-category prediction is then performed, matching only within the set of sub-categories corresponding to the predicted major category to narrow the search space. The method is consistent with the major category prediction. Finally, the sub-category prediction result is output. The anomaly detection mechanism includes:

[0159] Time-frequency behavior consistency detection: Record the time-domain and frequency-domain features of the user in the most recent T periods, and calculate the current time-domain features. With historical time domain characteristics DTW distance and current frequency domain characteristics Historical frequency domain characteristics Cosine distance; Overall score The average of the two distances reflects the difference between the user's electricity consumption behavior and their own historical patterns. If the overall score exceeds the industry average + 3σ, it is marked as a potential anomaly.

[0160] ;

[0161] Industry mean and standard deviation: The DTW distance distribution of all users in each industry is calculated using the training set to obtain the industry-specific normal fluctuation range;

[0162] Time window T: Set according to industry characteristics;

[0163] The industry benchmark distance assessment uses the major_centers and minor_centers obtained from model training, which are the mean vectors of the industry in the latent space. The user's current temporal features are then input into a hierarchical variational autoencoder model to obtain latent variables. ,calculate Euclidean distance from the center of the industry If the distance exceeds the industry center distance average + 2σ, it is considered abnormal.

[0164] Step six, system implementation and multimodal output, includes:

[0165] Multimodal evaluation report generation: Outputs the accuracy, recall, and F1 score for major and minor classes, and generates classification reports and anomaly detection reports;

[0166] Visualization output: Enables visualization of industry relationship graphs, comparative display of multimodal reconstruction results, and time-frequency behavior consistency analysis charts;

[0167] Persistent data storage: Optimal model parameters are saved via torch.save, and preprocessed objects and evaluation results are saved via joblib; multimodal information such as user ID, real label, predicted label, anomaly score, and time-frequency features are saved to data files, supporting backtracking analysis.

[0168] Traditional anomaly detection methods (such as single threshold method and isolated forest) have two major drawbacks. First, they ignore the consistency of users' historical behavior. That is, users' electricity consumption patterns may change naturally over time (such as seasonal load fluctuations). It is easy to misjudge normal fluctuations as anomalies by comparing the current features with the global benchmark. Second, the electricity consumption patterns of different industries are significantly different (such as high energy consumption in industry vs. low energy consumption in commerce). A uniform threshold cannot adapt to industry-specific characteristics.

[0169] This patented anomaly detection employs a dual-criteria approach. By combining the consistency of historical user behavior with deviations from industry benchmarks, it achieves both "personalized" and "industry-adaptable" anomaly detection, reducing false alarm and false negative rates. First, a classification consistency test is performed. The core idea is that the electricity consumption behavior of the same user should be stable within a short period (e.g., similar weekly load curves). If the similarity between current characteristics and historical classification results decreases significantly, anomalies may exist (e.g., electricity theft, equipment malfunction). Specific technical implementation: Records the user's classification results (major / minor category labels) and their corresponding time-series characteristics (e.g., daily load curves) for the most recent T-period (e.g., the last 30 days); acquires the user's current period's time-series characteristics in real time. ;calculate With historical characteristics The DTW distance (Dynamic Time Warped Distance) measures the difference in curve shape; if the DTW distance exceeds the industry average + 3σ (σ is the standard deviation of the DTW distance among users in the industry), it is marked as a potential anomaly.

[0170] Key parameter descriptions:

[0171] Industry mean and standard deviation: The DTW distance distribution of all users in each industry is calculated using the training set to obtain the normal fluctuation range specific to the industry (e.g., the DTW distance mean of retail users is 15 and the standard deviation is 3, so the threshold is 15 + 3 × 3 = 24).

[0172] Time window T: Set according to industry characteristics (e.g., weekly cycle for industrial users, daily cycle for commercial users) to ensure that historical data is comparable to current data.

[0173] The second step is to conduct an industry benchmark distance assessment. The core idea is to assume that the electricity consumption characteristics of users within the same industry should cluster around the industry's dynamic center (e.g., the typical load curves of the "fast food service" industry have similar peak periods). If user characteristics deviate from the industry center by a certain range, it is considered an anomaly. Technically, this is achieved through model training to obtain `major_centers` and `minor_centers`, which are the mean vectors of the industry in the latent space. The user's current time-series characteristics are then input into the HVAE model to obtain the latent variables. ,calculate If the Euclidean distance to the industry center exceeds the average distance to the industry center plus 2σ (σ is the standard deviation of the distance between users and the center within the industry), it is considered abnormal.

[0174] c) Anomaly scoring calculation

[0175] The deviations from both indicators are combined to generate an anomaly score ranging from 0 to 100. Example formula: ,in The system calibrates weights using industry data; when a score exceeds a set threshold of 80 points, an alert is triggered and the anomaly type is marked.

[0176] E. System Implementation and Output

[0177] Generates an evaluation report, outputting the accuracy, recall, and F1 score for the major and minor classes, and generating a classification report; saves the optimal model parameters (best_model.pth) via torch.save, and saves the preprocessing object (preprocessor.pkl) and evaluation results (evaluation_results.pkl) via joblib; saves information such as user ID, true label, predicted label, and anomaly score to a CSV file, supporting backtracking analysis.

[0178] It should be noted that the embodiments of the present invention are verified based on a continuous period of business data (lasting one week). The main purpose is to verify the basic performance and superiority of the model architecture in fine-grained classification and anomaly detection. The following is an example of the experimental implementation:

[0179] Experimental setup: Power consumption data from a certain area in Tai'an for one week (7 days) was used for verification (24 time points per day). A total of 2180 users were involved, covering 5 major categories and 17 subcategories.

[0180] 1. Fine-grained classification performance comparison experiment: To verify the ability of our method (HVAE) to distinguish between different industry segments, we compared it with several baseline models. The results are shown in the table below:

[0181]

[0182] Conclusion: The method of this application improves the F1 score of minor classes by 9 percentage points compared to the second-best performing ordinary VAE model. This eloquently demonstrates the significant improvement of this invention in fine-grained classification, completely resolving the problem of "not proving its actual ability to improve fine-grained discrimination".

[0183] 2. Anomaly detection performance comparison experiment:

[0184]

[0185] Conclusion: Our method also performs best on the anomaly detection task, with a significantly higher F1 score than the comparison model. This demonstrates the effectiveness of the "dual anomaly detection mechanism".

[0186] 3. Ablation Study: To demonstrate the necessity of each module, we conducted an ablation study.

[0187]

[0188] Conclusion: Removing any core module significantly degrades performance. This strongly demonstrates that the industry embedding layer and dynamic center constraint module are indispensable core innovations, and their integration with VAE forms an organic whole, generating a synergistic effect.

[0189] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention. The scope of protection claimed by the appended claims and their equivalents is defined.

Claims

1. A power consumption anomaly detection method based on time-frequency behavior mismatch analysis, characterized in that: Comprising the following steps: Step one, multi-modal feature extraction and dynamic frequency band discovery: define the tree-like hierarchical mapping relationship of industry categories and sub-categories; clean the user's time series power consumption data, including outlier correction based on industry grouping, missing value filling and normalization processing; perform frequency spectrum analysis on the historical load curve of each industry category to automatically identify the key frequency band most representative of the industry; extract the time domain load features of each user and the frequency domain energy features in the key frequency band of its industry, and splice to form a multi-modal feature vector; Step two, build a hierarchical graph convolutional variational autoencoder model: splice the multi-modal feature vector with the semantic vector of the industry category and sub-category obtained through the embedding layer to form a fusion feature vector; map the fusion feature vector to the latent space through the encoder to obtain the mean mu and variance sigma 2 of the latent variable; construct an industry relationship graph based on the industry hierarchical relationship, use a graph convolutional network to enhance the features of the latent variable and aggregate neighbor industry information; reconstruct the time domain load curve and frequency domain feature vector simultaneously through a multi-modal decoder; Step three, introduce dynamic hierarchical center constraints and graph guidance: introduce a learnable dynamic center parameter for each industry category and sub-category during model training; constrain the mean mu of the latent variable of each user to converge to the center of its industry category and sub-category through a loss function; and dynamically update the industry center parameter using an exponential moving average algorithm; use the industry relationship graph to guide latent representation learning to enhance the similarity of representations of the same industry; Step four, multi-objective model training and optimization: train the model using a comprehensive loss function that combines time domain reconstruction loss, frequency domain reconstruction loss, KL divergence loss, and hierarchical center constraint loss, and use the industry relationship graph to transfer semantic information to improve the model's generalization ability; Step five, hierarchical classification and time-frequency consistency anomaly detection: for the user to be tested, use the trained model to extract its latent features, first calculate the comprehensive similarity score of its time domain and frequency domain features with the typical feature curve of each industry category to determine the category, then match within the sub-category set corresponding to the predicted category to determine the final sub-category classification result; based on the classification result, calculate the consistency score of the user's current time domain and frequency domain features with its historical behavior, and combine the distance between its latent features and the industry dynamic center for double determination; the double determination includes: first, time-frequency behavior consistency-based anomaly detection; second, industry benchmark distance-based anomaly detection. When either detection result is determined to be abnormal, the user's behavior is finally determined to be abnormal; Step six, system implementation and multi-modal output: implement model evaluation report generation, industry relationship graph visualization, multi-modal reconstruction result display, and classification and anomaly detection information archiving for retrospective analysis. 2.The power consumption anomaly detection method based on time-frequency behavior mismatch analysis according to claim 1, characterized in that: The industry classification hierarchy system definition and dynamic frequency band discovery in step one includes the following steps: Hierarchical structure modeling: define the tree-like mapping relationship of industry categories and sub-categories, including the categories of agriculture, residents, retail industry, etc. and their corresponding sub-categories, and support automatic classification of unknown categories to the "other" category to ensure the completeness and scalability of the classification system; Bidirectional mapping construction: Establish the bidirectional index relationship between the major category and the minor category, which is convenient for subsequent hierarchical constraint modeling and graph construction; Industry spectrum analysis: Perform fast Fourier transform on the historical load curve of each industry major category, calculate the average power spectral density, and identify the characteristic frequency band representing the power consumption mode of the industry; Dynamic frequency band extraction: Based on the frequency spectrum peak detection algorithm, automatically find the N key frequency bands most representative of each industry major category, and dynamically adjust the frequency band selection as the data distribution changes. 3.The time-frequency behavior mismatch analysis based power consumption anomaly detection method according to claim 1, characterized in that: The time series data cleaning and feature engineering includes: Outlier correction: For each industry's hourly data, identify outliers based on IQR, and correct outliers by threshold truncation, that is, correct greater than upper to upper and less than lower to lower, the formula is: Where Q1 and Q3 are the 25th and 75th percentiles, and IQR = Q3-Q1; Missing value filling: Fill the missing values of the time series data using the industry grouping median, that is, for users in the same industry category, fill the missing values with the median of the non-missing values in the industry, the formula is: Fill the remaining missing values with the global median; Normalization: Normalize the time series data to the [0, 1] interval using MinMaxScaler to eliminate the dimension effect and speed up model convergence, the formula is: Frequency domain feature extraction: Perform fast Fourier transform on the load curve of each user to calculate the energy intensity in the key frequency band of the industry, the formula is: where X(f) is the spectral magnitude at frequency f, is the industry key band range; Multi-modal feature construction: Concatenate the time domain load feature vector and the frequency domain energy feature vector to form the final multi-modal feature representation, the formula is: wherein is a 24-dimensional time-domain feature, is an N-dimensional frequency-domain feature, N is the number of key frequency bands. 4.The time-frequency behavior mismatch analysis based power consumption anomaly detection method according to claim 1, characterized in that: The industry embedding layer includes: Hierarchical semantic encoding: The industry major category encoding and the industry minor category encoding are mapped to low-dimensional dense vectors through the embedding layer: the major category embedding dimension is major_embed_dim=4, capturing industry macro features, and the minor category embedding dimension is minor_embed_dim=8, capturing detailed field details; Multi-modal feature fusion: Concatenate the time domain feature vector, the frequency domain feature vector, and the industry embedding vector as the input of the encoder, the input dimension is 24+N+4+8, where N is the number of extracted key frequency bands, the formula is: wherein, is a 24-dimensional time-domain feature vector, is an N-dimensional frequency-domain feature vector.

5. The time-frequency behavior mismatch analysis based power consumption anomaly detection method according to claim 1, characterized in that: The encoder and latent space include: Multi-modal feature extraction network: Extract the high-level representation of the fused features through a two-layer fully connected network, the network structure is (input_dim + 12) → 64 → 32, where input_dim = 24 + N, the activation function uses LeakyReLU (negative slope 0.1), and Dropout (p=0.2) is introduced to prevent overfitting, the calculation process is as follows: ; Probability distribution modeling: Output the mean μ and variance logσ2 of the latent space for variational inference, and sample the latent variable z through the reparameterization trick. 6.The time-frequency behavior mismatch analysis based power consumption anomaly detection method according to claim 1, characterized in that: The multi-modal decoder and double reconstruction in step two include: Multi-modal feature decoding network: Concatenate the latent variable z, the graph convolution enhanced feature, and the industry embedding vector, and then reconstruct the time domain load curve and the frequency domain feature vector through the decoding network: Dual reconstruction loss function: The mean square error is used to calculate the time domain reconstruction loss and the frequency domain reconstruction loss, respectively, and the formula is: 。 7.The time-frequency behavior mismatch analysis based power consumption anomaly detection method according to claim 1, characterized in that: The dynamic hierarchical center constraint in step three and the atlas guide include: Dynamic industry center: Introducing learnable parameters major_centers and minor_centers, major_centers is the major center, and minor_centers is the minor center. The latent variable converges to the industry center to which it belongs through the MSE loss constraint: where m i , mi i are the macro and micro class codes for sample i; Industry center updating mechanism: During the training process, the industry center is dynamically updated through the exponential moving average, and the new center = 0.9 * old center + 0.1 * current batch average of the same class samples, and the formula is: Industry atlas guide: Use the pre-constructed industry relationship atlas to enhance latent representation learning through graph convolution network, aggregate neighbor industry information with similar semantics, and enhance the similarity of the same industry representation. The edge weight of the industry relationship atlas is determined by the hierarchical distance of the industry in the classification tree and the dynamic time warping (DTW) distance of its historical load curve, that is: edge weight = α * hierarchical similarity + (1-α) * DTW similarity. 8.The time-frequency behavior mismatch analysis based power consumption anomaly detection method according to claim 1, characterized in that: The multi-objective model training and optimization in step four includes: Multi-objective loss function: Fusion of time domain reconstruction loss, frequency domain reconstruction loss, KL divergence, hierarchical center constraint loss, formula: Wherein, KL divergence measures the difference between the latent distribution and the standard normal distribution, and the hierarchical constraint weight is 0.3 / 0.7; The optimization strategy includes: Using AdamW optimizer, learning rate lr=1e-4, weight decay=1e-5, and suppressing overfitting; ReduceLROnPlateau strategy based on validation loss, when the validation loss does not decrease for 3 consecutive rounds, the learning rate is reduced to 50% of the current value, and clip_grad_norm_ is used to limit the gradient norm ≤1.0 to prevent gradient explosion; The data division and training process includes: Using two-layered division to ensure the balanced distribution of industries in the training set, validation set or test set: first, divide the training and validation set and the test set according to the ratio of 8:2, and the hierarchical basis is the major code, then divide the training and validation set into training set and validation set according to the ratio of 75:25, and the hierarchical basis is the major code, among which the training uses early stopping mechanism, when the validation loss does not improve for 5 consecutive rounds, the training is terminated in advance, and the optimal model parameters are saved. 9.The time-frequency behavior mismatch analysis based power consumption anomaly detection method according to claim 1, characterized in that: The hierarchical classification and time-frequency consistency anomaly detection in step five includes: Hierarchical classification evaluation: For each valid industry, generate latent variable samples through VAE, calculate the mean curve as the typical characteristics of the industry after decoding; when making macro-category prediction, calculate the comprehensive similarity score of the test sample time curve and the typical curve of each macro-category; when making macro-category prediction, calculate the comprehensive score of the test sample time curve and the typical curve of each macro-category, the formula is: Score = 0.4·DTW + 0.5·MSE - 0.1·Corr, wherein, DTW is the dynamic time warping distance, MSE is the mean square error, Corr is the Pearson correlation coefficient, and the weight reflects the emphasis on the curve shape DTW and the numerical difference MSE; Select the macro-category with the smallest comprehensive score as the prediction result, then perform micro-category prediction, only match within the small category set corresponding to the predicted macro-category, narrow the search space, the method is consistent with the macro-category prediction, and finally output the micro-category prediction result; the abnormality detection mechanism comprises: Time-frequency behavior consistency detection: Record the time-domain and frequency-domain features of the user in the most recent T periods, and calculate the current time-domain features. With historical time domain characteristics DTW distance and current frequency domain characteristics Historical frequency domain characteristics Cosine distance; Overall score The average of the two distances reflects the difference between the user's electricity consumption behavior and their own historical patterns. If the overall score exceeds the industry average + 3σ, it is marked as a potential anomaly. ; Industry mean and standard deviation: calculate the DTW distance distribution of all users in each industry through the training set, and obtain the normal fluctuation range special for the industry; Time window T: set according to the characteristics of the industry; Industry benchmark distance evaluation, major_centers and minor_centers obtained by model training, i.e. the mean vector of the industry in the latent space, input the current time series features of the user into the hierarchical variational autoencoder model to obtain the latent variables , calculate the Euclidean distance from the industry center , if the distance exceeds the mean + 2σ of the industry center distance, it is determined to be abnormal. 10.The time-frequency behavior mismatch analysis based power consumption anomaly detection method according to claim 1, characterized in that: The system implementation and multi-modal output in step six comprise: Multi-modal evaluation report generation: output the accuracy, recall rate and F1 value of the macro-category / micro-category, generate a classification report and an abnormality detection report; Data persistent storage: save the optimal model parameters through torch.save, save the preprocessing objects and evaluation results through joblib; save the user number, real label, predicted label, abnormality score, time-frequency characteristics and other multi-modal information to a data file, and support backtracking analysis.

Citation Information

Patent Citations

  • Methods, devices, equipment and storage media for fine-grained classification of electricity users

    CN115809406B

  • Power consumption behavior diagnosis system and method based on anomaly detection model

    CN119918005A