Power consumption data anomaly detection method and device based on space-time dual-hybrid expert model

By using a spatiotemporal hybrid expert model, which combines a hybrid expert model with time and channel dimensions, the problem of insufficient spatiotemporal dependency modeling in existing electricity consumption data anomaly detection is solved, and efficient anomaly detection of complex time-series data is achieved.

CN121598255APending Publication Date: 2026-03-03BEIJING UNIV OF POSTS & TELECOMM +4
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202511723312.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-21
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

Existing methods for detecting anomalies in electricity consumption data cannot effectively capture the contextual dependencies and complex nonlinear relationships of time series in power systems, and they are difficult to accurately model long-range time dependencies and diverse cross-temporal dependencies, resulting in insufficient robustness and accuracy of anomaly detection.

Method used

We employ a spatiotemporal hybrid expert model, combining a time-dimensional hybrid expert model and a channel-dimensional hybrid expert model with stacked LSTM, variational autoencoder, and adaptive routing mechanism to explicitly model the temporal and spatial dependencies, extract multi-scale feature patterns and cross-spatiotemporal correlation information, and fuse anomaly scores for detection.

Benefits of technology

It achieves unified modeling of spatiotemporal representation of high-dimensional complex time series data, improves the robustness and accuracy of anomaly detection, and significantly enhances the ability to extract normal patterns and identify anomalies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121598255A_ABST
    Figure CN121598255A_ABST
Patent Text Reader

Abstract

The invention discloses an electricity consumption data anomaly detection method and device based on a space-time dual-hybrid expert model, and belongs to the technical field of electric energy metering. The method comprises the following steps: acquiring original power consumption data, preprocessing the original power consumption data, generating a time sequence set, and building a time dimension hybrid expert model and a channel dimension hybrid expert model based on the time sequence set; for a multivariable time sequence anomaly detection task, obtaining target power consumption data, taking the target power consumption data as input of a time dimension hybrid expert model and a channel dimension hybrid expert model, and performing time and space dependency relationship fusion on an output result to obtain a fusion result; and on the basis of a preset comprehensive anomaly score, according to a fusion result, performing anomaly detection, and judging whether the target power consumption data is abnormal or not. According to the implementation of the method, the extraction capability of the model on the normal mode in the high-dimensional complex time series data and the robustness of anomaly judgment are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electricity metering technology, and more specifically, to a method and apparatus for detecting abnormal electricity consumption data based on a spatiotemporal dual-hybrid expert model. Background Technology

[0002] Electricity data serves as a "barometer" of the energy sector and the macroeconomy, playing a crucial role in reflecting economic development and monitoring the effectiveness of economic policies. Currently, the electricity consumption information collection system connects to smart meters of all electricity users within the company's operating area. As the most basic unit directly facing customers in the electricity consumption information collection system, smart meters collect electricity consumption data at different time dimensions, such as daily and hourly. As the company's sole source of user electricity consumption data, it has accumulated massive amounts of electricity user data resources, laying a solid foundation for professional applications such as user energy demand analysis, power grid operation status monitoring, and national power data analysis. However, the volume of electricity user data is enormous, and the timeliness requirements in professional applications are high. Anomaly identification in this massive data often relies on expert experience and threshold judgment rules, and currently lacks robust and highly sensitive intelligent identification tools.

[0003] In electricity consumption time series data, outliers are typically defined as data that do not match the norm. These outliers are sparsely distributed in multidimensional time series and are mixed with a large amount of normal data, making accurate labeling time-consuming and laborious. Therefore, the amount of labeled data available is very limited, making unsupervised methods more attractive. Classic unsupervised anomaly detection methods such as Local Outlier Factor (LOF), One-Class Support Vector Machine (OCSVM), and Isolation Forest (IF) have been applied to electricity consumption anomaly detection, but they ignore the temporal structure of time series data, resulting in an inability to capture the contextual dependencies and complex nonlinear relationships of the time series. Recently, deep learning-based time series anomaly detection methods have been proposed and have shown high anomaly detection capabilities. Deep learning-based time series anomaly detection methods can be broadly divided into reconstruction-based methods and prediction-based methods. However, due to the inherent randomness and unpredictability of time series, accurate prediction of future values ​​is impossible when the prediction period is too long. Therefore, current mainstream deep learning anomaly detection methods mainly focus on reconstruction-based methods.

[0004] In reconstruction-based anomaly detection methods, the model learns a low-dimensional representation of normal data to compress and reconstruct the input data. Since the training process optimizes only for normal samples, the model often produces significant reconstruction errors for anomaly samples, revealing the degree to which they deviate from normal patterns. However, in complex industrial scenarios like power systems, traditional reconstruction methods often focus on the feature extraction capabilities of a single principal component, which significantly limits the performance improvement of such methods. Power equipment exhibits significant business pattern diversity in actual operation, such as different stages of start-up and shutdown cycles, load fluctuations, and fault evolution. Simultaneously, the various components within the equipment follow differentiated collaboration protocols. These factors result in a natural dual complexity for multidimensional time-series data in real-world scenarios: on the one hand, the data exhibits multiple distribution patterns over time; on the other hand, there are intertwined heterogeneous spatial relationships between feature dimensions.

[0005] While channel-based clustering or graph-based methods enhance the spatial representation of anomaly detection models by explicitly modeling dependencies between channels, their robustness to noise information between weakly or uncorrelated channels is insufficient. Furthermore, in practical applications, these methods generally overlook the spatial correlation characteristics between different channels at different time points, making it difficult for the model to accurately extract key channel correlation information from the data, thus leading to deviations in the characterization of normal pattern boundaries.

[0006] Existing methods for detecting anomalies in electricity consumption data that study spatial correlations mostly focus on the global spatial correlations between different channels at the same point in time within a local time window. However, in real-world electricity consumption data, multidimensional power data exhibits different spatial dependencies between different channels, such as asynchronous correlations across different time steps, or the absence of explicit spatial correlations between channels. Although electricity consumption data anomaly detection methods based on channel joint strategies have achieved some success, the following problems still exist:

[0007] 1) Most existing methods focus on the time dependencies within a local window. However, in the power environment, some electricity consumption behaviors have a certain long-term periodicity or continuity. The limited receptive field of existing methods cannot accurately model such long-range time dependencies.

[0008] 2) Existing methods generally focus on the correlation between different channels at the same time step. However, due to the diverse electricity consumption behaviors in real-world scenarios, the dependencies between channels are diversified. Existing methods cannot specifically explore the diverse cross-temporal and spatial dependencies of different strongly correlated channels at different time steps. Summary of the Invention

[0009] To address the above problems, this invention proposes a method for detecting anomalies in electricity consumption data based on a spatiotemporal dual-hybrid expert model, comprising:

[0010] Obtain raw electricity consumption data, preprocess the raw electricity consumption data to generate a time series set, and build a time-dimensional hybrid expert model and a channel-dimensional hybrid expert model based on the time series set.

[0011] For the multivariate time series anomaly detection task, target electricity consumption data is acquired, and the target electricity consumption data is used as input to a time-dimensional hybrid expert model and a channel-dimensional hybrid expert model. The output results are then fused based on temporal and spatial dependencies to obtain the fusion result.

[0012] Based on a pre-set comprehensive anomaly score, anomaly detection is performed according to the fusion results to determine whether the target power consumption data is abnormal.

[0013] Optionally, raw electricity consumption data is acquired, and the raw electricity consumption data is preprocessed, including:

[0014] After obtaining the raw electricity consumption data, a sliding window method is used to divide the time series x in the raw electricity consumption data into: a sub-time series set x = {X1,...,X...} N}∈R NL×D ;

[0015] Among them, X i This represents a sub-time series of length L with D-dimensional variables, where N represents the number of sub-time series in the set.

[0016] Optional, time-dimensional hybrid expert models include:

[0017] Stacked LSTMs are used to extract the temporal distribution patterns at different granularities in the time series set. The first LSTM layer is used as a shared feature extraction layer to extract the temporal correlation information of the global sequence in the time series set, and the latent variable h0 is obtained.

[0018] continuously stacking N t LSTM layer, to obtain intermediate layer latent variables The formula is as follows:

[0019]

[0020] Among them, LSTM i (·) represents the i-th LSTM layer in the stack (i∈[0,N)). t ]);

[0021] Based on the intermediate latent variable information extracted from the i-th layer, the two fully connected Linear layers are... i μ Linear i σThe encoder adaptively extracts the statistical properties μ of the latent distribution at each granularity. i ,σ i The formula is as follows:

[0022] μ i =Linear i μ (h i ),σ i =Linear i σ (h i )

[0023] Introducing the mean memory module M μ ={m1 μ m2 μ ,...m S μ} and variance memory module M σ ={m1 σ m2 σ ,...m S σ}, through the mean memory module and the variance memory module, there are Num total number of memory items m. i μ ,m i σ (i∈[1,Num]), which respectively store the mean and variance information of historical data;

[0024] The attention weights w obtained through the calculation i μ and w i σ Obtain the recombination vector μ based on historical information m 0,σ m 0;

[0025] Where, μ m The expression for the 0 generation process is as follows:

[0026] W i μ =softmax(m i μ ⊙μ0.T)

[0027]

[0028] Where β is the hard contraction threshold, η is the adjustment factor to ensure numerical stability, and ⊙ represents dot product;

[0029] In all time-dimensional hybrid expert models, including independent expert models without memory modules, all latent variable representations obtained from reconstruction are resampled and decoded and reconstructed using a Decoder consisting of fully connected layers with shared parameters, as shown in the following formula:

[0030] Reparameterize(μ i ,σ i ,∈ i )=μ i +∈ i ⊙σ i

[0031] z0=Decoder(Reparameterize(μ m 0,σ m 0,∈0))

[0032] z i =Decoder(Reparameterize(μ i ,σ i ,∈ i ), i∈[1,N t ]

[0033] Among them, the latent variables z1, z2, ..., z output by the independent expert model temp Summing to fuse feature tables at various scales yields Will The final aggregated output x is obtained by adaptively weighting and fusing z0 extracted from the shared expert model. temp .

[0034] Optional, channel-dimensional hybrid expert models, including:

[0035] The channel adaptive routing mechanism is based on an asynchronous spatiotemporal expert model with a random mapping layer and a one-dimensional convolutional layer, as well as a synchronous spatiotemporal expert model based on a global phenomenon mapping.

[0036] Among them, the channel adaptive routing mechanism:

[0037] By fusing channel attention information from the time and frequency domains, the correlation between feature channels is explicitly modeled to distribute the most correlated feature clusters at the corresponding scale, providing experts with key structured guidance information. The formula is as follows:

[0038] x freq =DCT(x)

[0039] A temp =xT⊙x,A freq =x freq .T⊙x freq

[0040] Where T represents the transpose operation and ⊙ represents the dot product operation;

[0041] Two MLP layers are used to adaptively combine the channel correlation matrices in the time-frequency domain. After passing through a Softmax layer, the overall time-frequency spatial correlation matrix A is obtained. pre ∈R D×D The formula is as follows:

[0042]

[0043] By introducing an adaptive weighting factor Calculate the weight score vector assigned to the experts.

[0044] Where, N c This represents the number of asynchronous spatiotemporal experts;

[0045] The gate weight scores are normalized using the Sigmoid function, and a learnable bias factor β is introduced, as shown in the following formula:

[0046] S = sigmoid(W) d A prior )+β

[0047] C(x) = TopKIndex(S)

[0048] Where C(x) represents the index of the TopK experts distributed for each feature in the input sequence;

[0049] Copy input x to N c Based on C(x), the structured guidance information is distributed. The feature part corresponding to the distributed index is retained, and the remaining part is masked with 0. At the same time, a corresponding Mask matrix is ​​generated and represented by ChannelClutering(·).

[0050]

[0051] in, The feature set and channel mask matrix corresponding to the structured guidance information are stored respectively, c i Mask i [i≤N c [] represents the input corresponding to the i-th expert;

[0052] Asynchronous spatiotemporal expert models based on random mapping layers and one-dimensional convolutional layers, and synchronous spatiotemporal expert models based on global phenomenon mapping:

[0053] The asynchronous spatiotemporal expert model is used to perform attention matrix operations on the normalized feature inputs of each branch, where for the i-th expert i∈[1,N] c The corresponding generated spatiotemporal correlation matrix A i,c ∈R D×D The overall process, where D is the dimension, includes:

[0054] For the input feature set c i Layer normalization is performed to obtain the normalized feature input c. i,norm After normalization, the random mapping layer RPLayer is used on both branches. i,1 ,RPLayer i,2 For c i,norm Perform random mapping and then use the corresponding Conv1D. i,1 Conv1D i,2 The formula for aggregating the time information from different timestamps for each feature is as follows:

[0055] Q i =Conv1D i,1 (RPLayer i,1 (c i,norm )),K i =Conv1D i,2 (RPLayer i,2 (c i,norm )),

[0056] in, It corresponds to the query and key obtained, Conv1D i,1 Conv1D i,2 It is a 1D convolution with both kernel length and stride of (2×i). By setting different kernel length and stride on different experts, asynchronous spatial correlation characteristics of different time spans can be extracted.

[0057] Finally, by calculating the attention matrix and the mask matrix, the spatiotemporal correlation matrix A representing each branch is obtained. i,c The formula is as follows:

[0058]

[0059] Summing the attention matrices of all experts yields an asynchronous spatial correlation attention matrix A encompassing all scales. ct The formula is as follows:

[0060]

[0061] The synchronous spatiotemporal expert model utilizes the global mapping capability of the linear layer to process all feature channels, thereby enabling the synchronous spatiotemporal expert model to possess the ability to establish global spatial correlations and obtain common spatial correlation information across all channels, including:

[0062] Global Channel Attention Matrix A global Through A global With A ct Aggregation yields a channel attention matrix A with diverse distribution patterns. channel .

[0063] Optionally, the output results can be fused based on temporal and spatial dependencies, including:

[0064] x will aggregate the time-dimensional features output by multiple distribution patterns. temp And channel-related attention matrices that aggregate synchronous and asynchronous spatial relationships, with x temp As a bond with A channel The formula for calculating attention is as follows:

[0065]

[0066] Optionally, the formula for calculating the comprehensive anomaly score AS is as follows:

[0067]

[0068] MSE represents the reconstruction anomaly score.

[0069] Optionally, the prior feature correlation matrix A obtained by calculating the integrated time-frequency domain information can be used. prior The spatial association matrix A with synchronous and asynchronous space channel The cosine similarity between the two values ​​is used to calculate the adaptive adjustment factor α of the reconstruction loss, as shown in the following formula:

[0070]

[0071] The reconstructed anomaly score of outliers is increased by (1-α).

[0072] Furthermore, this invention also proposes a device for detecting abnormal electricity consumption data based on a spatiotemporal dual-hybrid expert model, comprising:

[0073] The modeling unit is used to acquire raw electricity consumption data, preprocess the raw electricity consumption data to generate a time series set, and build a time-dimensional hybrid expert model and a channel-dimensional hybrid expert model based on the time series set.

[0074] The fusion unit is used for a multivariate time series anomaly detection task to acquire target electricity consumption data, use the target electricity consumption data as input to a time-dimensional hybrid expert model and a channel-dimensional hybrid expert model, and fuse the output results according to the time and space dependencies to obtain the fusion result.

[0075] An anomaly detection unit is used to perform anomaly detection based on a pre-set comprehensive anomaly score and the fusion result, and to determine whether the target power consumption data is abnormal.

[0076] In another aspect, the present invention also provides a computing device, comprising: one or more processors;

[0077] A processor is used to execute one or more programs;

[0078] When the one or more programs are executed by the one or more processors, the method described above is implemented.

[0079] In another aspect, the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed, implements the method described above.

[0080] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0081] This invention provides a method for detecting anomalies in electricity consumption data based on a spatiotemporal hybrid expert model, comprising: acquiring raw electricity consumption data and preprocessing the raw electricity consumption data to generate a time series set; building a time-dimensional hybrid expert model and a channel-dimensional hybrid expert model based on the time series set; for a multivariate time series anomaly detection task, acquiring target electricity consumption data, using the target electricity consumption data as input to the time-dimensional hybrid expert model and the channel-dimensional hybrid expert model, and fusing the output results according to temporal and spatial dependencies to obtain a fusion result; based on a pre-set comprehensive anomaly score, performing anomaly detection according to the fusion result to determine whether the target electricity consumption data is abnormal. This invention achieves unified modeling for spatiotemporal representation, significantly improving the model's ability to extract normal patterns and its robustness in anomaly detection from high-dimensional complex time series data. Attached Figure Description

[0082] Figure 1 This is a flowchart of the method of the present invention;

[0083] Figure 2 This is an overall flowchart of an embodiment of the method of the present invention;

[0084] Figure 3 This is a flowchart of the time expert model and time sharing expert model in an embodiment of the method of the present invention;

[0085] Figure 4 The flowcharts for the synchronous and asynchronous spatiotemporal expert models are shown in the embodiments of the present invention.

[0086] Figure 5 This is a structural diagram of the device of the present invention. Detailed Implementation

[0087] Exemplary embodiments of the invention will now be described with reference to the accompanying drawings. However, the invention may be embodied in many different forms and is not limited to the embodiments described herein. These embodiments are provided to fully and completely disclose the invention and to fully convey its scope to those skilled in the art. The terminology used in the exemplary embodiments illustrated in the drawings is not intended to limit the invention. In the drawings, the same units / elements are referred to by the same reference numerals.

[0088] Unless otherwise stated, the terms used herein (including technical terms) have their common meaning as understood by one of ordinary skill in the art. Furthermore, it is understood that terms defined in commonly used dictionaries should be understood to have a meaning consistent with the context of their relevant field, and not to be interpreted as having an idealized or overly formal meaning.

[0089] Example 1:

[0090] This invention proposes a method S100 for detecting anomalies in electricity consumption data based on a spatiotemporal dual-hybrid expert model, such as... Figure 1 As shown, it includes:

[0091] S101, acquire raw electricity consumption data, preprocess the raw electricity consumption data to generate a time series set, and build a time-dimensional hybrid expert model and a channel-dimensional hybrid expert model based on the time series set.

[0092] S102, For the multivariate time series anomaly detection task, acquire target electricity consumption data, use the target electricity consumption data as input to the time-dimensional hybrid expert model and the channel-dimensional hybrid expert model, and fuse the output results in terms of time and space dependencies to obtain the fusion result;

[0093] S103, based on the pre-set comprehensive anomaly score, perform anomaly detection according to the fusion result, and determine whether the target power consumption data is abnormal.

[0094] The following is a detailed explanation of steps S101-S103:

[0095] The above model is described as follows:

[0096] This invention uses a sliding window approach to divide the original electricity consumption data time series x into a sub-time series set x = {X1, ..., X}.N}∈R NL×F , where X i This represents a sub-time series of length L with D-dimensional variables at time points, where N represents the number of sub-time series in the set;

[0097] The implementation process of this invention, as follows: Figure 2 As shown, it mainly includes two branches: time-dimensional hybrid expert and channel-dimensional hybrid expert.

[0098] For the input sub-time series X, a masking operation is performed after reversible normalization via ReVIN in the time dimension, thereby mitigating the impact of distribution drift on the mining of time-dimensional correlations.

[0099] Subsequently, the sequence is processed by a hierarchically arranged Long Short-Term Memory (LSTM) network for feature extraction, and then fed into two different expert models: a time-sharing expert model and an independent time expert model. In the independent time expert model, a variational autoencoder (VAE) is used to extract temporal dependencies across different time scales. In the time-sharing expert model, a mean and variance dual-memory matrix is ​​used to store long-period time distribution pattern information, thereby uncovering long-period time dependencies. Finally, the outputs of all time-dimensional expert models are fused to obtain a comprehensive output x of the global time features. temp .

[0100] Furthermore, to further enhance the model's ability to extract diverse spatial dependencies between different channels, this invention further constructs a channel-dimensional hybrid expert model. This model integrates time-domain and frequency-domain feature correlation information to build a time-frequency fusion adaptive routing mechanism, distributing strongly correlated features. Based on this, synchronous and asynchronous spatiotemporal expert models are established.

[0101] For each distributed set of strongly correlated features, the asynchronous spatiotemporal expert model significantly enhances the attention given to the correlated events of strongly correlated features at different time steps through random mapping and one-dimensional convolution, thereby explicitly mining cross-spatiotemporal dependencies. Leveraging the multi-scale analysis characteristics of one-dimensional convolution, a fine-grained cross-spatiotemporal local spatial correlation matrix is ​​generated. Simultaneously, in the shared expert model, the synchronous spatial dependencies between different channels are studied, generating a global synchronous channel correlation matrix. Finally, the diverse channel matrices obtained from the asynchronous spatiotemporal expert model and the shared expert model are fused to obtain a comprehensive spatial correlation matrix. This matrix is ​​then combined with the global temporal feature output obtained from the temporal hybrid expert model for attention calculation, resulting in a final reconstructed output that integrates diverse temporal and spatial distribution patterns.

[0102] Explanation of the time-dimensional hybrid expert model:

[0103] The output x is obtained by reversible instance normalization using RevIN. Rev This invention utilizes stacked Long Short-Term Memory (LSTM) networks to extract temporal distribution patterns at different granularities. The first LSTM layer is used as a shared feature extraction layer to extract global temporal correlation information from the sequence, yielding the latent variable h0. Based on this, N layers are continuously stacked... t The LSTM layer ultimately yields the latent variables of the intermediate layers. The process is as follows.

[0104]

[0105] LSTM i (·) represents the i-th LSTM layer in the stack (i∈[0,N)). t For the intermediate latent variable information extracted from the i-th layer, the two fully connected Linear layers are... i μ Linear i σ The encoder adaptively extracts the statistical properties μ of the latent distribution at each granularity. i ,σ i .

[0106] μ i =Linear i μ (h i ),σ i =Linear i σ (h i )

[0107] In addition to modeling the multi-level semantic patterns of the current time window, the temporal-dimensional hybrid expert model also incorporates a memory-enhanced variational autoencoder (VAE) model within the time-sharing expert layer to mine the global semantics extracted from the shared LSTM layers, thereby enhancing the model's memory and utilization of long-term historical distribution patterns. Specifically, such as... Figure 3 As shown, this invention introduces a mean memory module M. μ ={m1 μ m2 μ ,...m S μ} and variance memory module M σ ={m1 σ m2 σ ,...m S σ}, through which there are Num memory items m i μ ,m i σ(i∈[1,Num]) store the mean and variance information of the historical data respectively. Finally, the attention weights w are obtained. i μ and w i σ Obtain the recombination vector μ based on historical information m 0,σ m 0. With μ m Taking the 0 generation process as an example, the specific process is as follows:

[0108] W i μ =softmax(m i μ ⊙μ0.T)

[0109]

[0110] Where β is the hard contraction threshold and η is an adjustment factor to ensure numerical stability. ⊙ represents dot product. Subsequently, all reconstructed latent variable representations are resampled in all expert models, including independent expert models without memory modules, thereby enhancing the model's generalization ability to complex data distributions. For all reparameterized latent variables, a shared-parameter Decoder consisting of fully connected layers is used for decoding and reconstruction. The overall process is shown below:

[0111] Reparameterize(μ i ,σ i ,∈ i )=μ i +∈ i ⊙σ i ,

[0112] z0=Decoder(Reparameterize(μ m 0,σ m 0,∈0)),

[0113] z i =Decoder(Reparameterize(μ i ,σ i ,∈ i ), i∈[1,N t ],

[0114] The latent variables z1, z2, ..., z output by the independent time expert model are included. temp Direct summation to fuse feature tables at various scales yields The final aggregated output x is obtained by adaptively weighting and fusing z0 extracted from the shared expert model. temp .

[0115] Channel-dimensional hybrid expert model explanation:

[0116] Channel adaptive routing mechanism:

[0117] To uncover the correlations between channels with finer granularity, this invention uses the cross-temporal correlation between different channels as the key basis for channel clustering. Specifically, an adaptive channel routing mechanism is designed, which adaptively guides the asynchronous spatiotemporal expert network to focus on a specific scale, thereby accurately mining the most significant spatiotemporal correlation features at that scale. By fusing channel attention information in the time and frequency domains, the correlations between feature channels are explicitly modeled, thus providing key structured guidance information to the corresponding experts for distributing the most correlated feature clusters at the corresponding scale. The overall process is as follows:

[0118] x freq =DCT(x)

[0119] A temp =xT⊙x,A freq =x freq .T⊙x freq

[0120] Where .T represents the Transpose operation. Subsequently, two MLP layers are used to adaptively combine the channel correlation matrices in the time-frequency domain, and after passing through a Softmax layer, the overall time-frequency spatial correlation matrix A is obtained. pre ∈R D×D This will provide prior feature association information for the subsequent distribution of feature routes.

[0121]

[0122] Finally, we introduce an adaptive weighting factor. Calculate the weighted score vector assigned to each subsequent expert. Where N c This represents the number of asynchronous spatiotemporal experts. Furthermore, the gating weight scores are normalized using the Sigmoid function, and a learnable bias factor β is introduced to ensure a more balanced load for each expert. The overall process is as follows:

[0123] S = sigmoid(W) d A prior )+β

[0124] C(x) = TopKIndex(S)

[0125] Where C(x) represents the index of the Top K experts distributed for each feature in the input sequence. Then, to ensure consistency in the number and position of input features, the input x is copied N times. cThe feature portion corresponding to the index of the distribution is retained, and the remaining portion is masked with 0. Simultaneously, to further avoid the influence of irrelevant channels during subsequent attention matrix calculations, a corresponding Mask matrix is ​​generated. All the above processes are represented by ChannelClutering(·).

[0126]

[0127] in Each expert's corresponding feature set and channel mask matrix are stored separately, c i Mask i [i≤N c [N] represents the total number of [something]. c The input of the i-th expert.

[0128] Asynchronous spatiotemporal expert models and synchronous spatiotemporal expert models:

[0129] To more effectively extract multi-scale inter-channel spatiotemporal correlations, this invention designs an asynchronous spatiotemporal expert model based on a random mapping layer and a one-dimensional convolutional layer, as well as a synchronous spatiotemporal expert model based on a global phenomenon mapping, such as... Figure 4 As shown.

[0130] An asynchronous spatiotemporal expert model is used to perform attention matrix operations on the normalized feature inputs in each branch to explore the spatiotemporal correlations within each feature cluster. Where the i-th expert i∈[1,N]... c The corresponding generated spatiotemporal correlation matrix A i,c ∈R D×D The overall process is as follows: First, the input feature set c... i Layer normalization is performed to obtain the normalized feature input c. i,norm After normalization, the random mapping layer RPLayer is used on both branches. i,1 ,RPLayer i,2 For c i,norm Perform random mapping and then use the corresponding Conv1D. i,1 Conv1D i,2 Aggregate the time information from different timestamps on each feature:

[0131] Q i =Conv1D i,1 (RPLayer i,1 (c i,norm )),K i =Conv1D i,2 (RPLayer ,i2 (c i,norm ))

[0132] in This corresponds to the retrieved query and key. Conv1D i,1 Conv1D i,2 It is a 1D convolution with a kernel size and stride of (2×i). By setting different kernel lengths and strides on different experts, asynchronous spatial correlation characteristics across different time spans can be extracted. Finally, the spatiotemporal correlation matrix A characterized by each branch is obtained by calculating the attention matrix and combining it with the mask matrix. i,c .

[0133]

[0134] Summing the attention matrices of all experts yields an asynchronous spatial correlation attention matrix A encompassing all scales. ct .

[0135]

[0136] Simultaneously, in the synchronous spatiotemporal expert model, the global mapping capability of the linear layer is utilized to process all feature channels, ensuring that the model possesses the ability to establish basic global spatial relationships and obtain common spatial correlation information for all channels. Other computational processes are similar to those in the asynchronous spatiotemporal expert model described above, ultimately yielding the global channel attention matrix A. global Through A global With A ct Aggregation yields a channel attention matrix A with diverse distribution patterns. channel .

[0137] Explanation of temporal and spatial dependency fusion:

[0138] Finally, the time-dimensional features output by aggregating multiple distribution patterns are represented as x. temp And a channel association attention matrix that aggregates synchronous and asynchronous spatial relationships, x temp As a key, with A channel The overall process for performing attention calculations is as follows:

[0139] Anomaly detection instructions:

[0140] For multivariate time series anomaly detection tasks, the goal is to determine whether anomalies have occurred at each time point in the time series. However, due to the difficulty in obtaining labeled data, it is impossible to directly predict whether anomalies have occurred at each time point in the test data. Current mainstream methods use reconstruction-based unsupervised methods to replace direct prediction of anomaly labels for anomaly detection. This invention presents a method and system for electricity data anomaly detection based on a spatiotemporal dual-hybrid expert model, designing a comprehensive anomaly score (AS) to determine whether anomalies have occurred at a time point. Simultaneously, an adaptive adjustment factor α for the reconstruction loss is designed, and the prior feature correlation matrix A obtained by integrating time-frequency domain information is calculated. prior The synchronous-asynchronous spatial correlation matrix A extracted by subsequent fusion with the model channel The cosine similarity between them is obtained. In normal pattern data, α should be higher, while in contaminated data, due to the existence of dynamic patterns different from normal pattern data, the two will have a deviation, and α will be lower. By using α, we can adaptively increase the learning ability of normal pattern data and reduce the impact of the model on contaminated data.

[0141]

[0142] In this invention, MSE is used as a measure of the reconstructed anomaly score, and the reconstruction error of the anomaly points is further amplified by (1-α).

[0143] This invention first compares DMoE-AD with 13 more advanced models on 5 authoritative real-world datasets and actual electricity consumption datasets that represent the diversity of time series data distributions, and confirms the effectiveness and advancement of the proposed multi-dimensional time series electricity consumption data anomaly detection method.

[0144] AUC-ROC was selected as the evaluation metric to assess the performance of the proposed method and the baseline. AUC-ROC is a commonly used metric in anomaly detection, representing the area under the receiver operating characteristic curve (ROC) with FPR (False Positive Rate) and TPR (True Positive Rate) as the x and y axes, obtained at different thresholds. AUC-ROC directly reflects the anomaly detection performance of the algorithm after excluding the influence of the threshold. Its range is from 0 to 1; a perfect algorithm has an AUC-ROC value of 1, while a random guessing model has an AUC-ROC value close to 0.5. The formulas for calculating TPR and FPR are shown below.

[0145]

[0146] Wherein, TP (True Postive) and FP (False Postive) are the number of true and false postive time points detected, respectively, and TN (True Negative) and FN (False Negative) are the number of true and false normal time points detected, respectively.

[0147] Introduction to the comparison method:

[0148] This invention compares the proposed method with 13 multivariate time series anomaly detection methods, including traditional machine learning methods: LOF, OCSVM, Isolation Forest (IF); prediction-based methods: GDN, GTA; and reconstruction methods: MSCRED, USAD, InterFusion, TranAD, AT, RAE, DiffAD, and TSMAE.

[0149] Implementation details:

[0150] A sliding time window approach is used to divide the training and testing time window sets. The reconstruction window length for both training and testing is 100. During training, the step size of the sliding time window is 20, and during testing, the step size is 100. DMoE-AD is implemented based on PyTorch, and all experiments are run on a server equipped with an Intel(R) Core(TM) i9-10900X CPU 3.70GHz and an NVIDIA GeForce RTX 4090. It is trained using the Adam optimizer with a learning rate of 1e-4 and employs an early stopping strategy; if the loss on the validation set does not decrease after four consecutive epochs, early stopping is triggered. All experimental results used in this invention are the average results after five independent runs on different seeds.

[0151] 8.4 Introduction to Public Datasets:

[0152] Five real-world datasets from three application areas were used. The datasets consist of monitoring data from multiple complex physical devices or large facilities. Specific information for each dataset is shown in Table 1.

[0153] Table 1

[0154]

[0155] Evaluation of results from public datasets:

[0156] The results of the proposed method and various comparative methods under the AUC-ROC metric are shown in Table 2. Bold text in the table indicates the highest average AUC-ROC and the best ranking. The adversarial time-frequency domain contamination filtering and two-stage loss correction multivariate electricity consumption data time series anomaly detection method proposed in this invention is represented by DMoE-AD in the table. The results in the table show that, under the AUC metric, DMoE-AD achieved three best results across all five public datasets, with a significantly higher average score than other baseline methods and the best average ranking, indicating that DMoE-AD's anomaly detection performance is superior to other comparative methods.

[0157] Table 2

[0158]

[0159] Introduction to actual electricity consumption datasets:

[0160] The specific characteristics of the actual electricity consumption dataset (ELE) are shown in Table 3. This dataset was collected from 9 physical three-phase electricity meters in multiple distribution areas. Each device includes 22 sensor values: current (phase A, phase B, phase C), voltage (phase A, phase B, phase C), energy reading (positive active), energy reading (reverse active), energy reading (positive reactive), energy reading (reverse reactive), active power (phase A, phase B, phase C, total), reactive power (phase A, phase B, phase C, total), and power factor (phase A, phase B, phase C, total).

[0161] Table 3

[0162]

[0163] Evaluation of actual electricity consumption dataset results:

[0164] Table 4 shows the AUC results of the embodiments of the present invention and other comparative methods on a real-world electricity consumption dataset. The results show that, compared to all comparative methods, the DMoE-AD proposed in this invention achieves the highest AUC-ROC score, indicating that its anomaly detection performance on the real-world electricity consumption dataset is superior to the comparative methods, demonstrating the reliability and superiority of DMoE-AD in real-world environments. Experimental results on both public datasets and real-world electricity consumption datasets demonstrate that the method proposed in this invention can effectively improve the accuracy of anomaly detection in electricity consumption data.

[0165] Table 4

[0166] method OCSVM LOF iForest MSCRED USAD InterFusion GDN AUC 0.6017 0.5694 0.5262 0.5720 0.4615 0.5985 0.5617 method GTA TranAD AT TSMAE RAE DiffAD DMoE-AD AUC 0.5429 0.5051 0.4956 0.5341 0.5347 0.5344 0.6491

[0167] By employing a dual-branch hybrid expert model architecture, both temporal and spatial dependencies are extracted, especially cross-temporal and spatiotemporal dependencies. This enhances the model's ability to jointly model global dependencies across windows and diverse cross-temporal and spatiotemporal relationships, thereby improving its generalization ability across data with diverse and complex distribution patterns.

[0168] Furthermore, to ensure the model's ability to extract semantic information from multi-level temporal distribution patterns, this invention further constructs a temporal hybrid expert model. This model can hierarchically extract multi-scale distribution pattern information of the current window and uses a memory module to store long-range historical memory information to extract cross-window global dependencies using a memory replay mechanism. Simultaneously, this invention also constructs a channel-dimensional hybrid expert model. Through a random mapping mechanism, it strengthens the convolutional layers' focus on key correlation events between strongly correlated features, thereby enhancing the model's ability to mine diverse cross-temporal and spatial correlations between strongly correlated features and comprehensively improving the accuracy and robustness of anomaly detection.

[0169] Example 2:

[0170] Furthermore, this invention also proposes a power consumption data anomaly detection device 200 based on a spatiotemporal dual-hybrid expert model, such as... Figure 5 As shown, it includes:

[0171] Modeling unit 201 is used to acquire raw electricity consumption data, preprocess the raw electricity consumption data to generate a time series set, and build a time-dimensional hybrid expert model and a channel-dimensional hybrid expert model based on the time series set.

[0172] The fusion unit 202 is used to acquire target electricity consumption data for a multivariate time series anomaly detection task, use the target electricity consumption data as input to a time-dimensional hybrid expert model and a channel-dimensional hybrid expert model, and fuse the output results based on time and space dependencies to obtain the fusion result.

[0173] The anomaly detection unit 203 is used to perform anomaly detection based on a pre-set comprehensive anomaly score and the fusion result, and to determine whether the target power consumption data is abnormal.

[0174] This invention realizes a unified model for spatiotemporal representation, which significantly improves the model's ability to extract normal patterns and its robustness in anomaly detection in high-dimensional complex time series data.

[0175] Example 3:

[0176] Based on the same inventive concept, this invention also provides a computer device, which includes a processor and a memory. The memory stores a computer program, which includes program instructions. The processor executes the program instructions stored in the computer storage medium. The processor may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. It is the computing and control core of the terminal, suitable for implementing one or more instructions, specifically suitable for loading and executing one or more instructions in the computer storage medium to implement corresponding method flows or corresponding functions, thereby implementing the steps of the methods in the above embodiments.

[0177] Example 4:

[0178] Based on the same inventive concept, this invention also provides a storage medium, specifically a computer-readable storage medium (Memory), which is a memory device in a computer device used to store programs and data. It is understood that the computer-readable storage medium here can include both the built-in storage medium in the computer device and extended storage media supported by the computer device. The computer-readable storage medium provides storage space that stores the terminal's operating system. Furthermore, this storage space also stores one or more instructions suitable for loading and execution by a processor. These instructions can be one or more computer programs (including program code). It should be noted that the computer-readable storage medium here can be high-speed RAM or non-volatile memory, such as at least one disk storage device. The processor can load and execute one or more instructions stored in the computer-readable storage medium to implement the steps of the method in the above embodiments.

[0179] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of the present invention can be implemented using various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.

[0180] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0181] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0182] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0183] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.

[0184] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.

Claims

1. A method for detecting anomalies in electricity consumption data based on a spatiotemporal dual-hybrid expert model, characterized in that, include: Obtain raw electricity consumption data, preprocess the raw electricity consumption data to generate a time series set, and build a time-dimensional hybrid expert model and a channel-dimensional hybrid expert model based on the time series set. For the multivariate time series anomaly detection task, target electricity consumption data is acquired, and the target electricity consumption data is used as input to a time-dimensional hybrid expert model and a channel-dimensional hybrid expert model. The output results are then fused based on temporal and spatial dependencies to obtain the fusion result. Based on a pre-set comprehensive anomaly score, anomaly detection is performed according to the fusion results to determine whether the target power consumption data is abnormal.

2. The method for detecting abnormal electricity consumption data according to claim 1, characterized in that, The process of acquiring raw electricity consumption data and preprocessing the raw electricity consumption data includes: After obtaining the raw electricity consumption data, a sliding window method is used to divide the time series x in the raw electricity consumption data into: a sub-time series set x = {X1,...,X...} N }∈R NL×D ; Among them, X i This represents a sub-time series of length L with D-dimensional variables, where N represents the number of sub-time series in the set.

3. The method for detecting abnormal electricity consumption data according to claim 1, characterized in that, The time-dimensional hybrid expert model includes: Stacked LSTMs are used to extract the temporal distribution patterns at different granularities in the time series set. The first LSTM layer is used as a shared feature extraction layer to extract the temporal correlation information of the global sequence in the time series set, and the latent variable h0 is obtained. continuously stacking N t A multi-layer LSTM is used to obtain the latent variables h1, h2, ..., in the intermediate layers. The formula is as follows: Among them, LSTM i (·) represents the i-th LSTM layer in the stack (i∈[0,N)). t ]); Based on the intermediate latent variable information extracted from the i-th layer, the two fully connected Linear layers are... i μ Linear i σ The encoder adaptively extracts the statistical properties μ of the latent distribution at each granularity. i ,σ i The formula is as follows: μ i =Linear i μ (h i ),σ i =Linear i σ (h i ) Introducing the mean memory module M μ ={m1 μ m2 μ ,...m S μ } and variance memory module M σ ={m1 σ m2 σ ,...m S σ }, through the mean memory module and the variance memory module, there are Num total number of memory items m. i μ ,m i σ (i∈[1,Num]), which respectively store the mean and variance information of historical data; The attention weights w obtained through the calculation i μ and w i σ Obtain the recombination vector μ based on historical information m 0,σ m 0; Where, μ m The expression for the 0 generation process is as follows: W i μ =softmax(m i μ ⊙μ0.T) Where β is the hard contraction threshold, η is the adjustment factor to ensure numerical stability, and ⊙ represents dot product; In all time-dimensional hybrid expert models, including independent expert models without memory modules, all latent variable representations obtained from reconstruction are resampled and decoded and reconstructed using a Decoder consisting of fully connected layers with shared parameters, as shown in the following formula: Reparameterize(μ i ,s i ,∈ i )=μ i +∈ i ⊙s i z0<Decoder(Reparameterize(μ m 0,σ m 0,∈0)) z i =Decoder(Reparameterize(μ i ,s i ,∈ i )),i∈[1,N t ] Among them, the latent variables z1, z2, ..., z output by the independent expert model temp Summing to fuse feature tables at various scales yields Will The final aggregated output x is obtained by adaptively weighting and fusing z0 extracted from the shared expert model. temp .

4. The method for detecting abnormal electricity consumption data according to claim 1, characterized in that, The channel-dimensional hybrid expert model includes: The channel adaptive routing mechanism is based on an asynchronous spatiotemporal expert model with a random mapping layer and a one-dimensional convolutional layer, as well as a synchronous spatiotemporal expert model based on a global phenomenon mapping. Among them, the channel adaptive routing mechanism: By fusing channel attention information from the time and frequency domains, the correlation between feature channels is explicitly modeled to distribute the most correlated feature clusters at the corresponding scale, providing experts with key structured guidance information. The formula is as follows: x freq =DCT(x) A temp =x.T⊙x,A freq =x freq .T⊙x freq Where T represents the transpose operation and ⊙ represents the dot product operation; Two MLP layers are used to adaptively combine the channel correlation matrices in the time-frequency domain. After passing through a Softmax layer, the overall time-frequency spatial correlation matrix A is obtained. pre ∈R D×D The formula is as follows: By introducing an adaptive weighting factor Calculate the weight score vector assigned to the experts. Where, N c This represents the number of asynchronous spatiotemporal experts; The gate weight scores are normalized using the Sigmoid function, and a learnable bias factor β is introduced, as shown in the following formula: S=sigmoid(W d A prior )+β C(x) = TopKIndex(S) Where C(x) represents the index of the TopK experts distributed for each feature in the input sequence; Copy input x to N c Based on C(x), the structured guidance information is distributed. The feature part corresponding to the distributed index is retained, and the remaining part is masked with 0. At the same time, a corresponding Mask matrix is ​​generated and represented by ChannelClutering(·). in, The feature set and channel mask matrix corresponding to the structured guidance information are stored respectively, c i Mask i [i≤N c [] represents the input corresponding to the i-th expert; Asynchronous spatiotemporal expert models based on random mapping layers and one-dimensional convolutional layers, and synchronous spatiotemporal expert models based on global phenomenon mapping: The asynchronous spatiotemporal expert model is used to perform attention matrix operations on the normalized feature inputs of each branch, where for the i-th expert i∈[1,N] c The corresponding generated spatiotemporal correlation matrix A i,c ∈R D×D The overall process, where D is the dimension, includes: For the input feature set c i Layer normalization is performed to obtain the normalized feature input c. i,norm After normalization, the random mapping layer RPLayer is used on both branches. i,1 ,RPLayer i,2 For c i,norm Perform random mapping and then use the corresponding Conv1D. i,1 Conv1D i,2 The formula for aggregating the time information from different timestamps for each feature is as follows: Q i =Conv1D i,1 (RPLayer i,1 (c i,norm )),K i =Conv1D i,2 (RPLayer i,2 (c i,norm )), in, It corresponds to the query and key obtained, Conv1D i,1 Conv1D i,2 It is a 1D convolution with both kernel length and stride of (2×i). By setting different kernel length and stride on different experts, asynchronous spatial correlation characteristics of different time spans can be extracted. Finally, by calculating the attention matrix and the mask matrix, the spatiotemporal correlation matrix A representing each branch is obtained. i,c The formula is as follows: Summing the attention matrices of all experts yields an asynchronous spatial correlation attention matrix A encompassing all scales. ct The formula is as follows: The synchronous spatiotemporal expert model utilizes the global mapping capability of the linear layer to process all feature channels, thereby enabling the synchronous spatiotemporal expert model to possess the ability to establish global spatial correlations and obtain common spatial correlation information across all channels, including: Global Channel Attention Matrix A global Through A global With A ct Aggregation yields a channel attention matrix A with diverse distribution patterns. channel .

5. The method for detecting abnormal electricity consumption data according to claim 1, characterized in that, The process of fusing the temporal and spatial dependencies of the output results includes: x will aggregate the time-dimensional features output by multiple distribution patterns. temp And channel-related attention matrices that aggregate synchronous and asynchronous spatial relationships, with x temp As a bond with A channel The formula for calculating attention is as follows:

6. The method for detecting abnormal electricity consumption data according to claim 1, characterized in that, The formula for calculating the comprehensive anomaly score AS is as follows: MSE represents the reconstruction anomaly score.

7. The method for detecting abnormal electricity consumption data according to claim 6, characterized in that, The prior feature correlation matrix A obtained by calculating the integrated time-frequency domain information is... prior The spatial association matrix A with synchronous and asynchronous space channel The cosine similarity between the two values ​​is used to calculate the adaptive adjustment factor α of the reconstruction loss, as shown in the following formula: The reconstructed anomaly score of outliers is increased by (1-α).

8. A device for detecting abnormal electricity consumption data based on a spatiotemporal dual-hybrid expert model, characterized in that, include: The modeling unit is used to acquire raw electricity consumption data, preprocess the raw electricity consumption data to generate a time series set, and build a time-dimensional hybrid expert model and a channel-dimensional hybrid expert model based on the time series set. The fusion unit is used for a multivariate time series anomaly detection task to acquire target electricity consumption data, use the target electricity consumption data as input to a time-dimensional hybrid expert model and a channel-dimensional hybrid expert model, and fuse the output results according to the time and space dependencies to obtain the fusion result. An anomaly detection unit is used to perform anomaly detection based on a pre-set comprehensive anomaly score and the fusion result, and to determine whether the target power consumption data is abnormal.

9. A computer device, characterized in that, include: One or more processors; A processor is used to execute one or more programs; When the one or more programs are executed by the one or more processors, the method described in any one of claims 1-7 is implemented.

10. A computer-readable storage medium, characterized in that, It contains a computer program, which, when executed, implements the method as described in any one of claims 1-7.

Citation Information

Cited By

  • Non-supervision detection method for metal surface defects based on variational auto-encoder

    CN122023419A

  • Unsupervised detection method for metal surface defects based on variational autoencoder

    CN122023419B

  • Customer reply generation method based on three-path routing hybrid expert large language model

    CN122221922A