CN118152857A - Power consumption abnormality detection method and device and computer readable storage medium - Google Patents

Power consumption abnormality detection method and device and computer readable storage medium Download PDF

Info

Publication number
CN118152857A
CN118152857A CN202410285935.2A CN202410285935A CN118152857A CN 118152857 A CN118152857 A CN 118152857A CN 202410285935 A CN202410285935 A CN 202410285935A CN 118152857 A CN118152857 A CN 118152857A
Authority
CN
China
Prior art keywords
data
vector
electricity consumption
user
power consumption
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410285935.2A
Other languages
Chinese (zh)
Inventor
索思远
任宇路
张美玲
韩霞
杨艳芳
李静
吕相沅
肖春
赵睿
梁中豪
陈晓芳
姚琼琼
孙晋凯
陈晓雯
郭易鑫
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
State Grid Henan Electric Power Co Marketing Service Center
Marketing Service Center of State Grid Shanxi Electric Power Co Ltd
Original Assignee
State Grid Henan Electric Power Co Marketing Service Center
Marketing Service Center of State Grid Shanxi Electric Power Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by State Grid Henan Electric Power Co Marketing Service Center, Marketing Service Center of State Grid Shanxi Electric Power Co Ltd filed Critical State Grid Henan Electric Power Co Marketing Service Center
Priority to CN202410285935.2A priority Critical patent/CN118152857A/en
Publication of CN118152857A publication Critical patent/CN118152857A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/16Matrix or vector computation, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/18Complex mathematical operations for evaluating statistical data, e.g. average values, frequency distributions, probability functions, regression analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/10Pre-processing; Data cleansing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/213Feature extraction, e.g. by transforming the feature space; Summarisation; Mappings, e.g. subspace methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/25Fusion techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0464Convolutional networks [CNN, ConvNet]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0499Feedforward networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/04Forecasting or optimisation specially adapted for administrative or management purposes, e.g. linear programming or "cutting stock problem"
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q50/00Information and communication technology [ICT] specially adapted for implementation of business processes of specific business sectors, e.g. utilities or tourism
    • G06Q50/06Energy or water supply

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Evolutionary Computation (AREA)
  • Artificial Intelligence (AREA)
  • Business, Economics & Management (AREA)
  • Software Systems (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Evolutionary Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Health & Medical Sciences (AREA)
  • Computational Mathematics (AREA)
  • Pure & Applied Mathematics (AREA)
  • Economics (AREA)
  • Mathematical Optimization (AREA)
  • Mathematical Analysis (AREA)
  • Computing Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Human Resources & Organizations (AREA)
  • Computational Linguistics (AREA)
  • Biophysics (AREA)
  • Biomedical Technology (AREA)
  • Molecular Biology (AREA)
  • Strategic Management (AREA)
  • Operations Research (AREA)
  • General Business, Economics & Management (AREA)
  • Databases & Information Systems (AREA)
  • Algebra (AREA)
  • Tourism & Hospitality (AREA)
  • Marketing (AREA)
  • Public Health (AREA)
  • Primary Health Care (AREA)
  • Water Supply & Treatment (AREA)
  • Quality & Reliability (AREA)

Abstract

The invention relates to the technical field of electricity consumption analysis, in particular to a method and a device for detecting abnormal electricity consumption and a computer readable storage medium. The method comprises the following steps: collecting user basic information, electricity consumption data and weather data of a sample, and preprocessing; combining the user basic information and the electricity consumption data into user electricity consumption data, and extracting the synthetic attention characteristics of the user electricity consumption data and the weather data by using an attention mechanism; then, feature extraction is carried out on the synthetic attention features by using a transducer model, so that global features of the electricity utilization behaviors of the user are obtained; carrying out local feature extraction on the electricity consumption data by using a convolutional neural network to obtain electricity consumption features of a load user; and integrating the global characteristic of the electricity consumption behavior of the user with the electricity consumption characteristic of the load user to obtain a combined characteristic, and detecting the electricity consumption abnormality. According to the method, the influence of weather factors on fluctuation of the power consumption data is considered in power consumption abnormality detection, and the accuracy of power consumption abnormality detection is improved.

Description

Power consumption abnormality detection method and device and computer readable storage medium
Technical Field
The invention relates to the technical field of electricity consumption analysis, in particular to a method and a device for detecting abnormal electricity consumption and a computer readable storage medium.
Background
Power spot trading is an important way of trading in the market of electricity, which refers to trading by predicting future power demand and price before actual delivery of the electricity. The abnormal power data can cause misjudgment of the power system state, so that the power spot transaction is affected, and the damage to the power market is generated. Based on the above requirements, how to improve the accuracy of the electricity consumption abnormality detection is currently the key research content.
At present, researchers at home and abroad mostly drive based on original electricity consumption data, dimension reduction is carried out on the data, and abnormal detection of electricity consumption of users is realized by extracting features through a single model. The real-time characteristic between power generation and consumption exists in the power spot transaction scene, and the current market supply and demand conditions are reflected. However, in practical situations, the reduction or increase of the weather temperature, precipitation, humidity and the like can all cause the user to use electricity, and the change of the electricity demand of the user can also affect the electricity consumption. In the prior art, the data for detecting the electricity consumption ignores the correlation between the user basic information and the electricity consumption requirement, and does not consider the dependency relationship between the user electricity consumption data and the weather condition. Moreover, complex and diversified features in the data cannot be captured by using a single feature extraction model, so that the abnormal electricity consumption of the user cannot be effectively and accurately detected.
Disclosure of Invention
Therefore, the invention aims to solve the technical problem of lower accuracy of detecting the abnormal electricity consumption in the prior art.
In order to solve the technical problems, the invention provides a method for detecting abnormal electricity consumption, which comprises the following steps:
Collecting a sample data set, and preprocessing the sample data set; the sample data set comprises user basic information, power consumption data and weather data;
Combining the preprocessed user basic information data vector and the power consumption data into a user power consumption vector, taking the preprocessed weather data as a weather data vector, and carrying out cross attention learning on the user power consumption vector and the weather data vector by using an attention mechanism to obtain a synthesized attention feature vector; then, feature extraction is carried out on the synthesized attention feature vector by using a transducer model, and a global feature vector of the user electricity utilization behavior is obtained;
Carrying out local feature extraction on the preprocessed electricity consumption data by using a convolutional neural network to obtain an electricity consumption feature vector of a load user;
And integrating the global feature vector of the user electricity consumption behavior with the feature vector of the load user electricity consumption to obtain a joint feature vector, and carrying out anomaly detection on the user electricity consumption based on the joint feature vector.
In one embodiment of the invention, preprocessing a sample dataset includes:
Mapping the user basic information in the data sample set into a data vector, and standardizing the user basic information data vector, the power consumption data and the weather data to obtain a preprocessed user basic information data vector;
And respectively calculating the dimension of the reserved main component of the standardized electricity consumption data and the standardized weather data by adopting a main component analysis method, and respectively carrying out dimension reduction on the standardized electricity consumption data and the standardized weather data according to the dimension of the reserved main component by adopting a singular value decomposition method to obtain the preprocessed electricity consumption data and the preprocessed weather data.
In one embodiment of the present invention, a principal component analysis method is adopted to calculate dimensions of a reserved principal component of standardized electricity consumption data and weather data, and dimension reduction is performed on the standardized electricity consumption data and weather data according to the dimensions of the reserved principal component by a singular value decomposition method, so as to obtain preprocessed electricity consumption data and weather data, including:
standardized electricity consumption data are recorded as Normalized weather data is notedWhere t represents time,The normalized electricity consumption data at time t,Weather data representing the normalized time t;
Carrying out principal component analysis on the standardized electricity consumption data and the standardized weather data to obtain the contribution rate of each principal component, taking the first K principal components to ensure that the accumulated contribution rate is positioned between preset intervals, and obtaining the standardized electricity consumption data and the standardized weather data, wherein the dimensionalities of the reserved principal components are K e and K w respectively;
singular value decomposition is respectively carried out on the standardized electricity consumption data and the standardized weather data:
Wherein U e and U w are respectively left singular vector matrices of normalized power consumption data and normalized weather data, Σ e and Σ w are respectively diagonal matrices composed of singular values of normalized power consumption data and normalized weather data, and V e and V w are respectively right singular vector matrices of normalized power consumption data and normalized weather data;
and respectively carrying out dimension reduction on the standardized electricity consumption data and the standardized weather data according to the dimension of the reserved main component, wherein the formula is as follows:
Wherein, For the power consumption data after dimension reduction,And the weather data after dimension reduction.
In one embodiment of the present invention, a preprocessed user basic information data vector and power consumption data are combined into a user power consumption vector, preprocessed weather data is used as a weather data vector, and a attention mechanism is used to perform cross attention learning on the user power consumption vector and the weather data vector to obtain a synthesized attention feature vector, including:
The preprocessed user basic information data vector is recorded as Where n represents the vector dimension number,User basic information data with a dimension n after standardization is represented;
combining the preprocessed user basic information data vector and the power consumption data into a user power consumption vector Power consumption vector and weather data vector/>, for user using attention mechanismPerforming cross attention learning, wherein the formula comprises:
Where attention_weight is the Attention weight, softmax represents the softmax function, For the weather data after dimension reduction,Attention feature vector for user power consumption vector,As attention feature vectors of weather data, S t is a synthetic attention feature vector.
In one embodiment of the present invention, feature extraction is performed on the synthesized attention feature vector by using a transducer model to obtain a global feature vector of the user power consumption behavior, including:
The synthesized attention feature vector S t is input into a transducer model, and the synthesized attention feature vector S t is embedded to obtain an embedded vector E, wherein the formula is as follows:
E=Embedding(St)
Wherein Embedding denotes an embedding operation, and E is an embedding vector output by the embedding operation;
And carrying out position coding on the embedded vector E, wherein the formula is as follows:
Epos=E+PositionalEncoding(E)
Wherein PositionalEncoding denotes a position-coding operation, and E pos denotes a position-coded embedded vector;
The position-coded embedded vector E pos is input into the multi-head self-attention layer, with the formula:
A=MultiHeadSelfAttention(Epos)
Wherein MultiHeadSelfAttention denotes a multi-head self-attention layer, and a is an output characteristic of the multi-head self-attention layer;
inputting the output characteristic A of the multi-head self-attention layer into a feedforward network, wherein the formula is as follows:
F=FeedForward(A)
Wherein FeedForward denotes a feed-forward network, and F is an output characteristic of the feed-forward network;
carrying out residual connection and normalization on the output characteristic F of the feedforward network, wherein the formula is as follows:
O=LayerNorm(F+A)
wherein LayerNorm denotes a normalization operation, and O denotes a normalized output feature;
Inputting the characteristic O subjected to residual connection and normalization into a full connection layer, wherein the formula is as follows:
Ht=FullyConnected(O)
Wherein FullyConnected represents a full connection layer, and H t is a global feature vector of user power consumption behavior.
In one embodiment of the present invention, local feature extraction is performed on the preprocessed electricity consumption data by using a convolutional neural network to obtain a load user electricity consumption feature vector, including:
the preprocessed electricity consumption data Inputting a convolutional neural network, and extracting features by using one-dimensional convolution, wherein the formula is as follows:
Wherein Conv represents a convolution operation, W is a convolution operator, b is a bias term, and f is an activation function;
the output characteristics of the one-dimensional convolution are maximally pooled, and the formula is as follows:
Wherein max represents the max pooling operation, and C i is the max pooling output feature;
Activating the maximally pooled output feature C i by adopting a ReLU activation function, wherein the formula is as follows:
C′i=ReLU(Ci)
Wherein, C' i is the output characteristic of the ReLU activation function;
Flattening the activated feature C' i, wherein the formula is as follows:
C'=Flatten(C'i)
wherein, flat represents flattening operation, and C' is the characteristic vector of the power consumption of the load user.
In one embodiment of the present invention, integrating the global feature vector of the user electricity behavior with the feature vector of the load user electricity consumption to obtain a joint feature vector, and performing anomaly detection on the user electricity consumption based on the joint feature vector, including:
Integrating the global characteristic vector H t of the user electricity consumption behavior with the load user electricity consumption characteristic vector C 'to obtain a joint characteristic vector T= [ H t, C' ]; taking the joint feature vector as input, and carrying out anomaly detection on the electricity consumption of the user by utilizing a trained softmax model;
The softmax model comprises a fully connected layer and a softmax layer; the joint feature vector T is input to the fully connected layer of the softmax model, and two neurons T '1 and T' 2 are output, with the formulas:
T′1=W1*T+b1
T′2=W2*T+b2
wherein T '1 and T' 2 are the first and second output neurons, respectively, W 1 and W 2 are the first and second weight matrices, respectively, and b 1 and b 2 are the first and second bias vectors, respectively;
The neurons T ' 1 and T ' 2 are fused into an output feature T ' = [ T ' 1,T'2 ], and input into the softmax layer to obtain a prediction probability y ', wherein the formula is:
y'=softmax(T')
wherein, softmax represents a softmax function, the prediction probability y 'is a vector containing two element values y' 1 and y '2, y' 1 represents the probability that the power consumption data is detected as normal, y '2 represents the probability that the power consumption data is detected as abnormal, and y' e {0,1};
And when the probability y' 2 of the abnormal electricity consumption data is more than or equal to 0.5, judging that the electricity consumption data of the load user is abnormal.
In one embodiment of the present invention, when training the softmax model, the loss function L adopts a cross entropy loss function, and the formula is:
Wherein N represents the number of samples in a batch, and C represents the number of categories, wherein the category includes the detection of the electricity consumption data as normal and abnormal, c=2; the value y ij represents the predicted probability of the j-th class for the i-th sample, 1 when the j-th class equals its true class, and the remainder of 0, y' ij.
The invention also provides a device for detecting the abnormal electricity consumption, which comprises the following components:
the sample collection and preprocessing module is used for collecting a sample data set and preprocessing the sample data set; the sample data set comprises user basic information, power consumption data and weather data;
A global feature extraction module comprising:
The system comprises a synthetic attention feature vector acquisition unit, a calculation unit and a calculation unit, wherein the synthetic attention feature vector acquisition unit is used for combining the preprocessed user basic information data vector and the preprocessed power consumption data into a user power consumption vector, taking the preprocessed weather data as a weather data vector, and carrying out cross attention learning on the user power consumption vector and the weather data vector by using an attention mechanism to obtain a synthetic attention feature vector;
the global feature vector acquisition unit is used for carrying out feature extraction on the synthesized attention feature vector obtained by the synthesized attention feature vector acquisition unit by utilizing a transducer model to obtain a global feature vector of the electricity utilization behavior of the user;
The local feature extraction module is used for carrying out local feature extraction on the preprocessed electricity consumption data by using the convolutional neural network to obtain an electricity consumption feature vector of a load user;
And the detection module is used for integrating the global feature vector of the user electricity consumption behavior with the feature vector of the load user electricity consumption to obtain a joint feature vector, and carrying out anomaly detection on the user electricity consumption based on the joint feature vector.
In one embodiment of the invention, the sample acquisition and preprocessing module comprises:
The normalization unit is used for mapping the user basic information in the data sample set into a data vector, and normalizing the user basic information data vector, the power consumption data and the weather data to obtain a preprocessed user basic information data vector;
And the dimension reduction unit is used for respectively calculating the dimension of the reserved main component of the standardized electricity consumption data and the weather data by adopting a main component analysis method, and respectively reducing the dimension of the standardized electricity consumption data and the weather data according to the dimension of the reserved main component by adopting a singular value decomposition method to obtain the preprocessed electricity consumption data and the preprocessed weather data.
In one embodiment of the present invention, the dimension reduction unit is specifically configured to:
recording the standardized electricity consumption data as Normalized weather data is notedWhere t represents time,Power consumption data representing normalized t time,Weather data representing the normalized time t;
Carrying out principal component analysis on the standardized electricity consumption data and the standardized weather data to obtain the contribution rate of each principal component, taking the first K principal components to ensure that the accumulated contribution rate is positioned between preset intervals, and obtaining the standardized electricity consumption data and the standardized weather data, wherein the dimensionalities of the reserved principal components are K e and K w respectively;
singular value decomposition is respectively carried out on the standardized electricity consumption data and the standardized weather data:
Wherein U e and U w are respectively left singular vector matrices of normalized power consumption data and normalized weather data, Σ e and Σ w are respectively diagonal matrices composed of singular values of normalized power consumption data and normalized weather data, and V e and V w are respectively right singular vector matrices of normalized power consumption data and normalized weather data;
and respectively carrying out dimension reduction on the standardized electricity consumption data and the standardized weather data according to the dimension of the reserved main component, wherein the formula is as follows:
Wherein, For the power consumption data after dimension reduction,And the weather data after dimension reduction.
In one embodiment of the invention, the synthetic attention feature vector acquisition unit is specifically configured to:
marking the preprocessed user basic information data vector as Where n represents the vector dimension number,User basic information data with a dimension n after standardization is represented;
combining the preprocessed user basic information data vector and the power consumption data into a user power consumption vector Power consumption vector and weather data vector/>, for user using attention mechanismPerforming cross attention learning, wherein the formula comprises:
Where attention_weight is the Attention weight, softmax represents the softmax function, For the weather data after dimension reduction,Attention feature vector for user power consumption vector,As attention feature vectors of weather data, S t is a synthetic attention feature vector.
In one embodiment of the present invention, the global feature vector obtaining unit is specifically configured to:
The synthesized attention feature vector S t is input into a transducer model, and the synthesized attention feature vector S t is embedded to obtain an embedded vector E, wherein the formula is as follows:
E=Embedding(St)
Wherein Embedding denotes an embedding operation, and E is an embedding vector output by the embedding operation;
And carrying out position coding on the embedded vector E, wherein the formula is as follows:
Epos=E+PositionalEncoding(E)
Wherein PositionalEncoding denotes a position-coding operation, and E pos denotes a position-coded embedded vector;
The position-coded embedded vector E pos is input into the multi-head self-attention layer, with the formula:
A=MultiHeadSelfAttention(Epos)
Wherein MultiHeadSelfAttention denotes a multi-head self-attention layer, and a is an output characteristic of the multi-head self-attention layer;
inputting the output characteristic A of the multi-head self-attention layer into a feedforward network, wherein the formula is as follows:
F=FeedForward(A)
Wherein FeedForward denotes a feed-forward network, and F is an output characteristic of the feed-forward network;
carrying out residual connection and normalization on the output characteristic F of the feedforward network, wherein the formula is as follows:
O=LayerNorm(F+A)
wherein LayerNorm denotes a normalization operation, and O denotes a normalized output feature;
Inputting the characteristic O subjected to residual connection and normalization into a full connection layer, wherein the formula is as follows:
Ht=FullyConnected(O)
Wherein FullyConnected represents a full connection layer, and H t is a global feature vector of user power consumption behavior.
In one embodiment of the present invention, the local feature extraction module is specifically configured to:
the preprocessed electricity consumption data Inputting a convolutional neural network, and extracting features by using one-dimensional convolution, wherein the formula is as follows:
Wherein Conv represents a convolution operation, W is a convolution operator, b is a bias term, and f is an activation function;
the output characteristics of the one-dimensional convolution are maximally pooled, and the formula is as follows:
Wherein max represents the max pooling operation, and C i is the max pooling output feature;
Activating the maximally pooled output feature C i by adopting a ReLU activation function, wherein the formula is as follows:
C′i=ReLU(Ci)
Wherein, C' i is the output characteristic of the ReLU activation function;
Flattening the activated feature C' i, wherein the formula is as follows:
C'=Flatten(C'i)
wherein, flat represents flattening operation, and C' is the characteristic vector of the power consumption of the load user.
In one embodiment of the present invention, the detection module is specifically configured to:
Integrating the global characteristic vector H t of the user electricity consumption behavior with the load user electricity consumption characteristic vector C 'to obtain a joint characteristic vector T= [ H t, C' ]; taking the joint feature vector as input, and carrying out anomaly detection on the electricity consumption of the user by utilizing a trained softmax model;
The softmax model comprises a fully connected layer and a softmax layer; the joint feature vector T is input to the fully connected layer of the softmax model, and two neurons T '1 and T' 2 are output, with the formulas:
T′1=W1*T+b1
T′2=W2*T+b2
wherein T '1 and T' 2 are the first and second output neurons, respectively, W 1 and W 2 are the first and second weight matrices, respectively, and b 1 and b 2 are the first and second bias vectors, respectively;
The neurons T ' 1 and T ' 2 are fused into an output feature T ' = [ T ' 1,T'2 ], and input into the softmax layer to obtain a prediction probability y ', wherein the formula is:
y'=softmax(T')
wherein, softmax represents a softmax function, the prediction probability y 'is a vector containing two element values y' 1 and y '2, y' 1 represents the probability that the power consumption data is detected as normal, y '2 represents the probability that the power consumption data is detected as abnormal, and y' e {0,1};
And when the probability y' 2 of the abnormal electricity consumption data is more than or equal to 0.5, judging that the electricity consumption data of the load user is abnormal.
The present invention also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the above-described electricity consumption abnormality detection method.
Compared with the prior art, the technical scheme of the invention has the following advantages:
According to the power consumption abnormality detection method, basic information, power consumption data and weather data of a user are collected to be used as a sample data set, the relationship between the power consumption data and the weather data is obtained by using an attention mechanism after the dimension of the sample data is reduced, and then global features are extracted by using a transformer model; and meanwhile, the local characteristics of the power consumption data are extracted by using the convolutional neural network, and the power consumption of the user is detected abnormally after the local characteristics are combined with the global characteristics. According to the method, the influence of weather factors on fluctuation of the power consumption data is considered in power consumption abnormality detection, the accuracy of power consumption abnormality detection is improved, and effective technical support is provided for abnormality identification of the power consumption data in power market transaction.
Drawings
In order that the invention may be more readily understood, a more particular description of the invention will be rendered by reference to specific embodiments thereof that are illustrated in the appended drawings, in which
FIG. 1 is a timing diagram of electricity and weather data for a commercial user with distributed photovoltaic in a region of mountain West province in an embodiment of the present invention; wherein (a) in fig. 1 is a daily electricity consumption timing chart, (b) in fig. 1 is a maximum load power timing chart, (c) in fig. 1 is a daily average temperature timing chart, and (d) in fig. 1 is a daily average humidity timing chart;
FIG. 2 is a diagram showing a correlation between electricity consumption data and weather factors according to an embodiment of the present invention;
FIG. 3 is a flow chart of a method for detecting power consumption abnormality according to the present invention;
FIG. 4 is a block diagram of a method for detecting power consumption anomalies according to the present invention;
FIG. 5 is a flow chart of global feature extraction of user power usage behavior based on an attention mechanism and a transducer model in an embodiment of the present invention;
fig. 6 is a graph comparing AUC analysis of the method for detecting abnormal electricity consumption according to the present invention with that of the conventional method.
Detailed Description
The present invention will be further described with reference to the accompanying drawings and specific examples, which are not intended to be limiting, so that those skilled in the art will better understand the invention and practice it.
Example 1
In the electric power spot transaction scene, because on the power generation side, weather factors can influence renewable energy sources such as distributed solar energy, wind energy and the like, electricity price fluctuation is caused, and further electricity consumption data of a user is influenced; on the electricity consumption side, the electricity consumption data may influence the electricity consumption due to various factors, such as user demand change, weather fluctuation, and the like.
Taking the electricity consumption data and weather factor related data of a commercial user of a distributed photovoltaic in a certain region of Shanxi province as an example, the data timing chart is shown with reference to fig. 1, wherein (a) in fig. 1 is a daily electricity consumption timing chart, (b) in fig. 1 is a maximum load power timing chart, (c) in fig. 1 is a daily average temperature timing chart, and (d) in fig. 1 is a daily average humidity timing chart. Fig. 2 is a correlation coefficient test chart of the electricity consumption data and the weather factor, and it can be seen from fig. 2 that the weather factor has a relatively large correlation with the electricity consumption data. Therefore, the weather data includes a large amount of characteristics of electricity consumption data, so that factors affecting the electricity consumption data of the user are complex, and the traditional electricity consumption abnormality detection method does not take full consideration during detection.
Referring to fig. 3 and 4, the present invention proposes a power consumption abnormality detection method in consideration of user-side factors and weather factors. The following describes the steps of the method for detecting abnormal electricity consumption in detail.
S1, collecting a sample data set, and preprocessing the sample data set; the sample data set includes user basic information, electricity usage data, and weather data.
The user basic information comprises the capacity of user electrical equipment, the electricity utilization time mode, the type of electricity utilization building site and the like. The electricity consumption data comprises total electricity consumption, real-time electricity consumption, power factors, voltage and current data, real-time electricity prices and the like within 15 days. The weather data comprise real-time temperature, wind speed, air humidity, precipitation, cloud cover, air pollution index and the like within 15 days. And classifying the data samples into two types according to whether the data samples are abnormal, wherein the label with normal electricity consumption is 0, and the label with abnormal electricity consumption is 1.
Preprocessing the sample data set includes normalizing and dimension-reducing the sample data.
Recording user basic information asWherein m represents the number of data types in the user basic information,Data representing user basic information of the m-th class; record the 15-day electricity consumption data asThe weather data for 15 days was recorded as Where t represents time,Power consumption data at time t of expression,And weather data at time t.
And mapping the user basic information in the data sample set into a data vector, and standardizing the user basic information data vector, the power consumption data and the weather data to eliminate the influence of units and the value range.
Mapping user basic information into data vectorsWhere n represents the number of vector dimensions after mapping,User basic information data representing a dimension n.
The standardized process is specifically as follows:
firstly, respectively calculating the average value of each characteristic data x ij in the user basic information data vector, the electricity consumption data and the weather data And variance s j, the formula is:
where M is the total number of collected feature data.
According to the average valueAnd variance s j calculates normalized feature data z ij, the formula is:
The normalized user basic information data vector is recorded as Normalized electricity usage data is notedStandardized weather data is recorded asWhereinPower consumption data representing normalized t time,Weather data representing normalized t-time,And representing the normalized user basic information data with the dimension of n.
The normalized user basic information data vectorThe user basic information data vector after preprocessing is obtained. Through the data preprocessing, dimensional differences among features are eliminated, redundant information of data is reduced, and the efficiency of subsequent data processing is improved.
Respectively calculating standardized electricity consumption data by adopting principal component analysis methodAnd weather dataThe dimension of the reserved main component is used for respectively carrying out normalized electricity consumption data/>, according to the dimension of the reserved main component by a singular value decomposition methodAnd weather dataAnd (5) performing dimension reduction.
And carrying out principal component analysis on the standardized electricity consumption data and the standardized weather data to obtain the contribution rate of each principal component, taking the first K principal components to ensure that the accumulated contribution rate is between 85 and 95 percent, and obtaining the dimensions of the reserved principal components of the standardized electricity consumption data and the standardized weather data as K e and K w respectively.
Singular value decomposition is respectively carried out on the standardized electricity consumption data and the standardized weather data, and the formula is as follows:
Wherein U e and U w are respectively left singular vector matrices of normalized power consumption data and normalized weather data, Σ e and Σ w are respectively diagonal matrices composed of singular values of normalized power consumption data and normalized weather data, and V e and V w are respectively right singular vector matrices of normalized power consumption data and normalized weather data.
And respectively carrying out dimension reduction on the standardized electricity consumption data and the standardized weather data according to the dimension of the reserved main component, wherein the formula is as follows:
Wherein, For the power consumption data after dimension reduction,And the weather data after dimension reduction.AndAnd the preprocessed electricity consumption data and the preprocessed weather data are obtained.
S2, the preprocessed user basic information data vectorAnd the preprocessed electricity consumption dataCombined into user power consumption vectorWill preprocessed weather dataAs a weather data vector, the attention mechanism is utilized to carry out cross attention learning on the user power consumption vector and the weather data vector, and a synthesized attention feature vector is obtained; and then, carrying out feature extraction on the synthesized attention feature vector by using a transducer model to obtain a global feature vector of the user electricity utilization behavior.
Referring to fig. 5, the procedure of the specific procedure of S4 will be described below.
The user electricity vectorUser electricity utilization vectorThe Attention weight is input to an Attention mechanism for cross Attention learning, and Attention weight attention_weight is obtained, wherein the formula is as follows:
wherein softmax represents the softmax function.
Attention characteristic vectors of the user power consumption vectors are obtained respectively by using Attention weight attention_weightAnd attention feature vector/>, of weather dataThe formula is:
Wherein, For the weather data after dimension reduction,The attention feature vector of the power consumption vector for the user,As attention feature vectors of weather data, S t is a synthetic attention feature vector. /(I)
Attention feature vector for power consumption vector of userAnd attention feature vector/>, of weather dataFusion to obtain the synthesized attention feature vector
Constructing a transducer model, inputting the synthesized attention feature vector S t into the trained transducer model, and embedding the synthesized attention feature vector S t to obtain an embedded vector E, wherein the formula is as follows:
E=Embedding(St)
Wherein Embedding denotes an embedding operation, and E is an embedding vector output by the embedding operation.
And carrying out position coding on the embedded vector E, wherein the formula is as follows:
Epos=E+PositionalEncoding(E)
Wherein PositionalEncoding denotes a position-coding operation, and E pos denotes a position-coded embedded vector.
The position-coded embedded vector E pos is input into the multi-head self-attention layer, with the formula:
A=MultiHeadSelfAttention(Epos)
Wherein MultiHeadSelfAttention denotes a multi-head self-attention layer, and a is an output characteristic of the multi-head self-attention layer.
Inputting the output characteristic A of the multi-head self-attention layer into a feedforward network, wherein the formula is as follows:
F=FeedForward(A)
Wherein FeedForward denotes a feed-forward network, and F is an output characteristic of the feed-forward network.
Carrying out residual connection and normalization on the output characteristic F of the feedforward network, wherein the formula is as follows:
O=LayerNorm(F+A)
Wherein LayerNorm denotes a normalization operation, and O denotes a normalized output characteristic.
Inputting the characteristic O subjected to residual connection and normalization into a full connection layer, wherein the formula is as follows:
Ht=FullyConnected(O)
Wherein FullyConnected represents a full connection layer, and H t is a global feature vector of user power consumption behavior.
And S3, carrying out local feature extraction on the preprocessed electricity consumption data by using a convolutional neural network. The preprocessed electricity consumption dataInputting a convolutional neural network, and extracting features by using one-dimensional convolution, wherein the formula is as follows:
Wherein Conv represents a convolution operation, W is a convolution operator, b is a bias term, and f is an activation function.
The output characteristics of the one-dimensional convolution are maximally pooled, and the formula is as follows:
Where max represents the max pooling operation and C i is the max pooled output feature.
Activating the maximally pooled output feature C i by adopting a ReLU activation function, wherein the formula is as follows:
C′i=ReLU(Ci)
wherein C' i is the output characteristic of the ReLU activation function.
Flattening the activated feature C' i, wherein the formula is as follows:
C'=Flatten(C'i)
wherein, flat represents flattening operation, and C' is the characteristic vector of the power consumption of the load user.
And S4, integrating the global feature vector of the user electricity consumption behavior and the feature vector of the load user electricity consumption to obtain a combined feature vector T= [ H t, C' ], taking the combined feature vector T as input, and carrying out anomaly detection on the user electricity consumption by utilizing a trained softmax model.
The softmax model includes a fully connected layer and a softmax layer.
When the softmax model is trained, the loss function adopts a cross entropy loss function, and the formula is as follows:
Where softmax represents a softmax function, N represents the number of samples in batch, C represents the number of categories, and the category includes the detection of the electricity consumption data as normal and abnormal, so that c=2; the value y ij represents the predicted probability of the j-th class for the i-th sample, 1 when the j-th class equals its true class, and the remainder of 0, y' ij.
And updating a parameter value theta in the loss function by adopting an Adam random gradient descent algorithm, wherein the parameter value theta comprises a weight parameter and a bias parameter. The specific parameter value updating process is as follows:
respectively initializing first moment estimation and second moment estimation as:
m0=0
v0=0
Where m 0 is the initial first moment estimate and v 0 is the initial second moment estimate;
Calculating a gradient of the parameter value θ:
wherein, θ t is a parameter value at time t, g t is a gradient of the parameter value θ at time t;
Updating the first moment estimate and the second moment estimate, respectively, as:
mt=β1·mt-1+(1-β1)·gt
vt=β2·vt-1+(1-β2)·(gt⊙(gt))
Wherein m t is the first moment estimation updated at time t, and v t is the second moment estimation updated at time t; as indicated by the wise multiplication, β 1 and β 2 were the first and second dynamic attenuation coefficients, respectively, which in this example were 0.9;
Correcting the deviation of the first moment estimation and the second moment estimation at the moment t respectively to obtain corrected first moment estimation and second moment estimation as follows:
Wherein, For the first moment estimation corrected at time t,Is the first dynamic attenuation coefficient at time t,For the second moment estimation after the correction of the moment t,A second dynamic attenuation coefficient at the time t;
updating a parameter value theta t at the time t by using the corrected first moment estimation and second moment estimation:
Wherein θ t+1 is a parameter value at time t+1, α is a learning rate, and e is a small constant added for numerical stability.
The joint feature vector T is input to the fully connected layer in the trained softmax model, outputting two neurons T '1 and T' 2, with the formulas:
T′1=W1*T+b1
T′2=W2*T+b2
Wherein T '1 and T' 2 are the first and second output neurons, respectively, W 1 and W 2 are the first and second weight matrices, respectively, and b 1 and b 2 are the first and second bias vectors, respectively.
Fusing neurons T ' 1 and T ' 2 into an output characteristic T ' = [ T ' 1,T'2 ], and inputting the output characteristic T ' = [ T ' 1,T'2 ] into the softmax layer to obtain a prediction probability y ', wherein the formula is as follows:
y'=softmax(T')
The softmax represents a softmax function, the prediction probability y 'is a vector containing two element values y' 1 and y '2, y' 1 represents the probability that the electricity consumption data is detected as normal, y '2 represents the probability that the electricity consumption data is detected as abnormal, and y' e {0,1}.
And when the probability y' 2 of the abnormal electricity consumption data is more than or equal to 0.5, judging that the electricity consumption data of the load user is abnormal.
In order to verify the effectiveness of the method for detecting abnormal electricity consumption in the invention, the embodiment uses the user load of the distributed photovoltaic in certain town area of Shanxi province as a detection object to obtain the comparison result of the detection method and the traditional detection method. The comparison results are shown in Table 1.
TABLE 1 comparison result table of electric quantity abnormality detection method
Model Accuracy of F1 fraction
Support vector machine 0.706±0.038 0.632±0.025
Decision tree 0.778±0.056 0.696±0.034
This embodiment 0.810±0.054 0.736±0.019
As can be seen from Table 1, the accuracy and F1 fraction of the detection method provided by the invention are higher than those of other methods, which shows that the performance of the detection method is improved compared with the prior art.
In addition, to further examine the performance of the detection method proposed by the present invention, the Area Under the Curve (AUC) was analyzed in this example, and the analysis result is shown in fig. 6. As can be seen from the results of fig. 6, the AUC values of the detection method of the present invention are greater and the performance is better.
In summary, the invention provides a method for detecting abnormal electricity consumption aiming at the characteristics of the power spot transaction scene. According to the detection method, the influence of weather factors on fluctuation of the power consumption data is considered, a global dependency relationship between the power consumption data and weather is captured by combining an attention mechanism and a Transformer model, the capability of feature vector characterization is enhanced by carrying out local feature extraction on the power consumption data through a convolutional neural network, and finally a softmax probability model is constructed to carry out probability prediction on the abnormality of the power consumption. The invention obviously improves the performance of distinguishing the abnormal electricity consumption of the user in the electric power spot transaction scene and provides scientific basis for diagnosing the abnormal electricity consumption data of the electric power market.
Example two
According to the method for detecting the abnormal electricity consumption in the first embodiment, the embodiment provides an apparatus for detecting the abnormal electricity consumption, which comprises a sample collection and preprocessing module, a global feature extraction module, a local feature extraction module and a detection module.
The sample collection and preprocessing module is used for collecting a sample data set and preprocessing the sample data set; the sample data set comprises user basic information, power consumption data and weather data, and comprises a standardization unit and a dimension reduction unit.
The normalization unit is used for mapping the user basic information in the data sample set into a data vector, and normalizing the user basic information data vector, the power consumption data and the weather data to obtain a preprocessed user basic information data vector;
the dimension reduction unit is used for respectively calculating the dimension of the reserved main component of the standardized electricity consumption data and the standardized weather data by adopting a main component analysis method, and respectively reducing the dimension of the standardized electricity consumption data and the standardized weather data according to the dimension of the reserved main component by adopting a singular value decomposition method to obtain the preprocessed electricity consumption data and the preprocessed weather data.
The dimension reduction unit is specifically used for:
recording the standardized electricity consumption data as Normalized weather data is notedWhere t represents time,Power consumption data representing normalized t time,Weather data representing the normalized time t;
Carrying out principal component analysis on the standardized electricity consumption data and the standardized weather data to obtain the contribution rate of each principal component, taking the first K principal components to ensure that the accumulated contribution rate is positioned between preset intervals, and obtaining the standardized electricity consumption data and the standardized weather data, wherein the dimensionalities of the reserved principal components are Ke and Kw respectively;
singular value decomposition is respectively carried out on the standardized electricity consumption data and the standardized weather data:
Wherein U e and U w are respectively left singular vector matrices of normalized power consumption data and normalized weather data, Σ e and Σ w are respectively diagonal matrices composed of singular values of normalized power consumption data and normalized weather data, and V e and V w are respectively right singular vector matrices of normalized power consumption data and normalized weather data;
and respectively carrying out dimension reduction on the standardized electricity consumption data and the standardized weather data according to the dimension of the reserved main component, wherein the formula is as follows:
Wherein, For the power consumption data after dimension reduction,And the weather data after dimension reduction.
The global feature extraction module includes a synthetic attention feature vector acquisition unit.
The synthetic attention feature vector obtaining unit is configured to combine the preprocessed user basic information data vector and the power consumption data into a user power consumption vector, take the preprocessed weather data as a weather data vector, and perform cross attention learning on the user power consumption vector and the weather data vector by using an attention mechanism to obtain a synthetic attention feature vector, and is specifically configured to:
marking the preprocessed user basic information data vector as Where n represents the vector dimension number,User basic information data with a dimension n after standardization is represented;
combining the preprocessed user basic information data vector and the power consumption data into a user power consumption vector Power consumption vector and weather data vector/>, for user using attention mechanismPerforming cross attention learning, wherein the formula comprises: /(I)
Where attention_weight is the Attention weight, softmax represents the softmax function,For the weather data after dimension reduction,Attention feature vector for user power consumption vector,As attention feature vectors of weather data, S t is a synthetic attention feature vector.
The global feature vector obtaining unit is used for carrying out feature extraction on the synthesized attention feature vector obtained by the synthesized attention feature vector obtaining unit by utilizing a transducer model to obtain a global feature vector of the user electricity consumption behavior, and is specifically used for:
The synthesized attention feature vector S t is input into a transducer model, and the synthesized attention feature vector S t is embedded to obtain an embedded vector E, wherein the formula is as follows:
E=Embedding(St)
Wherein Embedding denotes an embedding operation, and E is an embedding vector output by the embedding operation;
And carrying out position coding on the embedded vector E, wherein the formula is as follows:
Epos=E+PositionalEncoding(E)
Wherein PositionalEncoding denotes a position-coding operation, and E pos denotes a position-coded embedded vector;
The position-coded embedded vector E pos is input into the multi-head self-attention layer, with the formula:
A=MultiHeadSelfAttention(Epos)
Wherein MultiHeadSelfAttention denotes a multi-head self-attention layer, and a is an output characteristic of the multi-head self-attention layer;
inputting the output characteristic A of the multi-head self-attention layer into a feedforward network, wherein the formula is as follows:
F=FeedForwar(A)
Wherein FeedForwar denotes a feed-forward network, and F is an output characteristic of the feed-forward network;
carrying out residual connection and normalization on the output characteristic F of the feedforward network, wherein the formula is as follows:
O=LayerNorm(F+A)
wherein LayerNorm denotes a normalization operation, and O denotes a normalized output feature;
Inputting the characteristic O subjected to residual connection and normalization into a full connection layer, wherein the formula is as follows:
Ht=PullyConnected(O)
Wherein FullyConnected represents a full connection layer, and H t is a global feature vector of user power consumption behavior.
The local feature extraction module is used for carrying out local feature extraction on the preprocessed electricity consumption data by using the convolutional neural network to obtain a load user electricity consumption feature vector, and is specifically used for:
the preprocessed electricity consumption data Inputting a convolutional neural network, and extracting features by using one-dimensional convolution, wherein the formula is as follows: /(I)
Wherein Conv represents a convolution operation, W is a convolution operator, b is a bias term, and f is an activation function;
the output characteristics of the one-dimensional convolution are maximally pooled, and the formula is as follows:
Wherein max represents the max pooling operation, and C i is the max pooling output feature;
Activating the maximally pooled output feature C i by adopting a ReLU activation function, wherein the formula is as follows:
C′i=ReLU(Ci)
Wherein, C' i is the output characteristic of the ReLU activation function;
Flattening the activated feature C' i, wherein the formula is as follows:
C'=Flatten(C'i)
wherein, flat represents flattening operation, and C' is the characteristic vector of the power consumption of the load user.
The detection module is used for integrating the global feature vector of the user electricity consumption behavior and the feature vector of the load user electricity consumption to obtain a joint feature vector, and performing anomaly detection on the user electricity consumption based on the joint feature vector, and is specifically used for:
Integrating the global characteristic vector H t of the user electricity consumption behavior with the load user electricity consumption characteristic vector C 'to obtain a joint characteristic vector T= [ H t, C' ]; taking the joint feature vector as input, and carrying out anomaly detection on the electricity consumption of the user by utilizing a trained softmax model;
The softmax model comprises a fully connected layer and a softmax layer; the joint feature vector T is input to the fully connected layer of the softmax model, and two neurons T '1 and T' 2 are output, with the formulas:
T′1=W1*T+b1
T′2=W2*T+b2
wherein T '1 and T' 2 are the first and second output neurons, respectively, W 1 and W 2 are the first and second weight matrices, respectively, and b 1 and b 2 are the first and second bias vectors, respectively;
The neurons T ' 1 and T ' 2 are fused into an output feature T ' = [ T ' 1,T'2 ], and input into the softmax layer to obtain a prediction probability y ', wherein the formula is:
y'=softmax(T')
wherein, softmax represents a softmax function, the prediction probability y 'is a vector containing two element values y' 1 and y '2, y' 1 represents the probability that the power consumption data is detected as normal, y '2 represents the probability that the power consumption data is detected as abnormal, and y' e {0,1};
And when the probability y' 2 of the abnormal electricity consumption data is more than or equal to 0.5, judging that the electricity consumption data of the load user is abnormal.
The present embodiment also provides a computer-readable storage medium having a computer program stored thereon, which when executed by a processor, implements the steps of the electricity consumption abnormality detection method described in the first embodiment.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may 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, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It is apparent that the above examples are given by way of illustration only and are not limiting of the embodiments. Other variations and modifications of the present invention will be apparent to those of ordinary skill in the art in light of the foregoing description. It is not necessary here nor is it exhaustive of all embodiments. And obvious variations or modifications thereof are contemplated as falling within the scope of the present invention.

Claims (16)

1. The method for detecting the abnormal electricity consumption is characterized by comprising the following steps of:
Collecting a sample data set, and preprocessing the sample data set; the sample data set comprises user basic information, power consumption data and weather data;
Combining the preprocessed user basic information data vector with the power consumption data to form a user power consumption vector,
Taking the preprocessed weather data as a weather data vector, and carrying out cross attention learning on the user power consumption vector and the weather data vector by using an attention mechanism to obtain a synthesized attention feature vector; then, feature extraction is carried out on the synthesized attention feature vector by using a transducer model, and a global feature vector of the user electricity utilization behavior is obtained;
Carrying out local feature extraction on the preprocessed electricity consumption data by using a convolutional neural network to obtain an electricity consumption feature vector of a load user;
And integrating the global feature vector of the user electricity consumption behavior with the feature vector of the load user electricity consumption to obtain a joint feature vector, and carrying out anomaly detection on the user electricity consumption based on the joint feature vector.
2. The method of claim 1, wherein preprocessing the sample data set comprises:
Mapping the user basic information in the data sample set into a data vector, and standardizing the user basic information data vector, the power consumption data and the weather data to obtain a preprocessed user basic information data vector;
And respectively calculating the dimension of the reserved main component of the standardized electricity consumption data and the standardized weather data by adopting a main component analysis method, and respectively carrying out dimension reduction on the standardized electricity consumption data and the standardized weather data according to the dimension of the reserved main component by adopting a singular value decomposition method to obtain the preprocessed electricity consumption data and the preprocessed weather data.
3. The method for detecting abnormal electricity consumption according to claim 2, wherein the main component analysis method is adopted to calculate the dimensions of the reserved main components of the standardized electricity consumption data and the weather data respectively, and the singular value decomposition method is adopted to reduce the dimensions of the standardized electricity consumption data and the weather data respectively according to the dimensions of the reserved main components, so as to obtain the preprocessed electricity consumption data and the preprocessed weather data, and the method comprises the steps of:
standardized electricity consumption data are recorded as Standardized weather data is recorded asWhere t represents time,The normalized electricity consumption data at time t,Weather data representing the normalized time t;
Carrying out principal component analysis on the standardized electricity consumption data and the standardized weather data to obtain the contribution rate of each principal component, taking the first K principal components to ensure that the accumulated contribution rate is positioned between preset intervals, and obtaining the standardized electricity consumption data and the standardized weather data, wherein the dimensionalities of the reserved principal components are K e and K w respectively;
singular value decomposition is respectively carried out on the standardized electricity consumption data and the standardized weather data:
Wherein U e and U w are respectively left singular vector matrices of normalized power consumption data and normalized weather data, Σ e and Σ w are respectively diagonal matrices composed of singular values of normalized power consumption data and normalized weather data, and V e and V w are respectively right singular vector matrices of normalized power consumption data and normalized weather data;
and respectively carrying out dimension reduction on the standardized electricity consumption data and the standardized weather data according to the dimension of the reserved main component, wherein the formula is as follows:
Wherein, For the power consumption data after dimension reduction,And the weather data after dimension reduction.
4. The method for detecting abnormal electricity consumption according to claim 3, wherein the step of combining the preprocessed user basic information data vector with the electricity consumption data to obtain the user electricity consumption vector, the step of using the preprocessed weather data as the weather data vector, and the step of using an attention mechanism to perform cross attention learning on the user electricity consumption vector and the weather data vector to obtain the synthesized attention feature vector comprises the steps of:
The preprocessed user basic information data vector is recorded as Where n represents the vector dimension number,User basic information data with a dimension n after standardization is represented;
combining the preprocessed user basic information data vector and the power consumption data into a user power consumption vector Power consumption vector and weather data vector/>, for user using attention mechanismPerforming cross attention learning, wherein the formula comprises:
Where attention_weight is the Attention weight, softmax represents the softmax function, For the weather data after dimension reduction,Attention feature vector for user power consumption vector,As attention feature vectors of weather data, S t is a synthetic attention feature vector.
5. The method for detecting abnormal electricity consumption according to claim 4, wherein the feature extraction of the synthesized attention feature vector by using a transducer model to obtain a global feature vector of the electricity consumption behavior of the user comprises:
The synthesized attention feature vector S t is input into a transducer model, and the synthesized attention feature vector S t is embedded to obtain an embedded vector E, wherein the formula is as follows:
E=Embedding(St)
Wherein Embedding denotes an embedding operation, and E is an embedding vector output by the embedding operation;
And carrying out position coding on the embedded vector E, wherein the formula is as follows:
Epos=E+PositionalEncoding(E)
Wherein PositionalEncoding denotes a position-coding operation, and E pos denotes a position-coded embedded vector;
The position-coded embedded vector E pos is input into the multi-head self-attention layer, with the formula:
A=MultiHeadSelfAttention(Epos)
wherein MultiHeadSelfAttention denotes a multi-head self-attention layer, and a is an output characteristic of the multi-head self-attention layer:
inputting the output characteristic A of the multi-head self-attention layer into a feedforward network, wherein the formula is as follows:
F=FeedForward(A)
Wherein FeedForward denotes a feed-forward network, and F is an output characteristic of the feed-forward network;
carrying out residual connection and normalization on the output characteristic F of the feedforward network, wherein the formula is as follows:
O=LayerNorm(F+A)
wherein LayerNorm denotes a normalization operation, and O denotes a normalized output feature;
Inputting the characteristic O subjected to residual connection and normalization into a full connection layer, wherein the formula is as follows:
Ht=FullyConnected(O)
Wherein FullyConnected represents a full connection layer, and H t is a global feature vector of user power consumption behavior.
6. The method for detecting abnormal electricity consumption according to claim 5, wherein the step of extracting local features of the preprocessed electricity consumption data by using a convolutional neural network to obtain the load user electricity consumption feature vector comprises the steps of:
the preprocessed electricity consumption data Inputting a convolutional neural network, and extracting features by using one-dimensional convolution, wherein the formula is as follows:
Wherein Conv represents a convolution operation, W is a convolution operator, b is a bias term, and f is an activation function;
the output characteristics of the one-dimensional convolution are maximally pooled, and the formula is as follows:
Wherein max represents the max pooling operation, and C i is the max pooling output feature;
Activating the maximally pooled output feature C i by adopting a ReLU activation function, wherein the formula is as follows:
C′i=ReLU(Ci)
Wherein, C' i is the output characteristic of the ReLU activation function;
Flattening the activated feature C' i, wherein the formula is as follows:
C′=Flatten(C′i)
Wherein, flat represents flattening operation, and C' is the characteristic vector of the power consumption of the load user.
7. The method for detecting power consumption abnormality according to claim 6, wherein integrating the global feature vector of the user power consumption behavior with the load user power consumption feature vector to obtain a joint feature vector, and performing abnormality detection on the user power consumption based on the joint feature vector, comprises:
Integrating the global characteristic vector H t of the user electricity consumption behavior with the load user electricity consumption characteristic vector C 'to obtain a joint characteristic vector T= [ H t, C' ]; taking the joint feature vector as input, and carrying out anomaly detection on the electricity consumption of the user by utilizing a trained softmax model;
The softmax model comprises a fully connected layer and a softmax layer; the joint feature vector T is input to the fully connected layer of the softmax model, and two neurons T '1 and T' 2 are output, with the formulas:
T1=W1*T+b1
T′2=W2*T+b2
Wherein T '1 and T' 2 are the first and second output neurons, respectively, W 1 and W 2 are the first and second weight matrices, respectively, and b 1 and b 2 are the first and second bias vectors, respectively;
The neurons T ' 1 and T ' 2 are fused into an output feature T ' = [ T ' 1,T′2 ], and input into the softmax layer to obtain a prediction probability y ', wherein the formula is:
y′=softmax(T′)
Wherein, softmax represents a softmax function, the prediction probability y 'is a vector containing two element values y' 1 and y '2, y' 1 represents the probability that the power consumption data is detected as normal, y '2 represents the probability that the power consumption data is detected as abnormal, and y' e {0,1};
And when the probability y' 2 of the abnormal electricity consumption data is more than or equal to 0.5, judging that the electricity consumption data of the load user is abnormal.
8. The method of claim 7, wherein the loss function L is a cross entropy loss function when training the softmax model, and the formula is:
Wherein N represents the number of samples in a batch, and C represents the number of categories, wherein the category includes the detection of the electricity consumption data as normal and abnormal, c=2; the value y ij represents the predicted probability of the j-th class for the i-th sample, 1 when the j-th class equals its true class, and the remainder of 0, y' ij.
9. An electricity consumption abnormality detection device, characterized by comprising:
the sample collection and preprocessing module is used for collecting a sample data set and preprocessing the sample data set; the sample data set comprises user basic information, power consumption data and weather data;
A global feature extraction module comprising:
The system comprises a synthetic attention feature vector acquisition unit, a calculation unit and a calculation unit, wherein the synthetic attention feature vector acquisition unit is used for combining the preprocessed user basic information data vector and the preprocessed power consumption data into a user power consumption vector, taking the preprocessed weather data as a weather data vector, and carrying out cross attention learning on the user power consumption vector and the weather data vector by using an attention mechanism to obtain a synthetic attention feature vector;
the global feature vector acquisition unit is used for carrying out feature extraction on the synthesized attention feature vector obtained by the synthesized attention feature vector acquisition unit by utilizing a transducer model to obtain a global feature vector of the electricity utilization behavior of the user;
The local feature extraction module is used for carrying out local feature extraction on the preprocessed electricity consumption data by using the convolutional neural network to obtain an electricity consumption feature vector of a load user;
And the detection module is used for integrating the global feature vector of the user electricity consumption behavior with the feature vector of the load user electricity consumption to obtain a joint feature vector, and carrying out anomaly detection on the user electricity consumption based on the joint feature vector.
10. The power consumption abnormality detection apparatus according to claim 9, wherein the sample collection and preprocessing module includes:
The normalization unit is used for mapping the user basic information in the data sample set into a data vector, and normalizing the user basic information data vector, the power consumption data and the weather data to obtain a preprocessed user basic information data vector;
And the dimension reduction unit is used for respectively calculating the dimension of the reserved main component of the standardized electricity consumption data and the weather data by adopting a main component analysis method, and respectively reducing the dimension of the standardized electricity consumption data and the weather data according to the dimension of the reserved main component by adopting a singular value decomposition method to obtain the preprocessed electricity consumption data and the preprocessed weather data.
11. The power consumption abnormality detection apparatus according to claim 10, wherein the dimension reduction unit is specifically configured to:
recording the standardized electricity consumption data as Standardized weather data is recorded asWhere t represents time,The normalized electricity consumption data at time t,Weather data representing the normalized time t;
Carrying out principal component analysis on the standardized electricity consumption data and the standardized weather data to obtain the contribution rate of each principal component, taking the first K principal components to ensure that the accumulated contribution rate is positioned between preset intervals, and obtaining the standardized electricity consumption data and the standardized weather data, wherein the dimensionalities of the reserved principal components are K e and K w respectively;
singular value decomposition is respectively carried out on the standardized electricity consumption data and the standardized weather data:
Wherein U e and U w are respectively left singular vector matrices of normalized power consumption data and normalized weather data, Σ e and Σ w are respectively diagonal matrices composed of singular values of normalized power consumption data and normalized weather data, and V e and V w are respectively right singular vector matrices of normalized power consumption data and normalized weather data;
and respectively carrying out dimension reduction on the standardized electricity consumption data and the standardized weather data according to the dimension of the reserved main component, wherein the formula is as follows:
Wherein, For the power consumption data after dimension reduction,And the weather data after dimension reduction.
12. The power consumption abnormality detection apparatus according to claim 11, wherein the synthetic attention feature vector acquisition unit is specifically configured to:
marking the preprocessed user basic information data vector as Where n represents the vector dimension number,User basic information data with a dimension n after standardization is represented;
combining the preprocessed user basic information data vector and the power consumption data into a user power consumption vector Power consumption vector and weather data vector/>, for user using attention mechanismPerforming cross attention learning, wherein the formula comprises:
Where attention_weight is the Attention weight, softmax represents the softmax function, For the weather data after dimension reduction,Attention feature vector for user power consumption vector,As attention feature vectors of weather data, S t is a synthetic attention feature vector.
13. The power consumption abnormality detection apparatus according to claim 12, wherein the global feature vector acquisition unit is specifically configured to:
The synthesized attention feature vector S t is input into a transducer model, and the synthesized attention feature vector S t is embedded to obtain an embedded vector E, wherein the formula is as follows:
E=Embedding(St)
Wherein Embedding denotes an embedding operation, and E is an embedding vector output by the embedding operation;
And carrying out position coding on the embedded vector E, wherein the formula is as follows:
Epos=E+PositionalEncoding(E)
Wherein PositionalEncoding denotes a position-coding operation, and E pos denotes a position-coded embedded vector;
The position-coded embedded vector E pos is input into the multi-head self-attention layer, with the formula:
A=MultiHeadSelftAttention(Epos)
wherein MultiHeadSelftAttention denotes a multi-head self-attention layer, and a is an output characteristic of the multi-head self-attention layer;
inputting the output characteristic A of the multi-head self-attention layer into a feedforward network, wherein the formula is as follows:
F=FeedForward(A)
Wherein FeedForward denotes a feed-forward network, and F is an output characteristic of the feed-forward network;
carrying out residual connection and normalization on the output characteristic F of the feedforward network, wherein the formula is as follows:
O=LayerNorm(F+A)
wherein LayerNorm denotes a normalization operation, and O denotes a normalized output feature;
Inputting the characteristic O subjected to residual connection and normalization into a full connection layer, wherein the formula is as follows:
Ht=FullyConnected(O)
Wherein FullyConnected represents a full connection layer, and H t is a global feature vector of user power consumption behavior.
14. The power consumption abnormality detection apparatus according to claim 13, wherein the local feature extraction module is specifically configured to:
the preprocessed electricity consumption data Inputting a convolutional neural network, and extracting features by using one-dimensional convolution, wherein the formula is as follows:
Wherein Conv represents a convolution operation, W is a convolution operator, b is a bias term, and f is an activation function;
the output characteristics of the one-dimensional convolution are maximally pooled, and the formula is as follows:
Wherein max represents the max pooling operation, and C i is the max pooling output feature;
Activating the maximally pooled output feature C i by adopting a ReLU activation function, wherein the formula is as follows:
C′i=ReLU(Ci)
Wherein, C' i is the output characteristic of the ReLU activation function;
Flattening the activated feature C' i, wherein the formula is as follows:
C′=Flatten(C′i)
Wherein, flat represents flattening operation, and C' is the characteristic vector of the power consumption of the load user.
15. The device for detecting abnormal electricity consumption according to claim 14, wherein the detecting module is specifically configured to:
Integrating the global characteristic vector H t of the user electricity consumption behavior with the load user electricity consumption characteristic vector C 'to obtain a joint characteristic vector T= [ H t, C' ]; taking the joint feature vector as input, and carrying out anomaly detection on the electricity consumption of the user by utilizing a trained softmax model;
The softmax model comprises a fully connected layer and a softmax layer; the joint feature vector T is input to the fully connected layer of the softmax model, and two neurons T '1 and T' 2 are output, with the formulas:
T′1=W1*T+b1
T′2=W2*T+b2
Wherein T '1 and T' 2 are the first and second output neurons, respectively, W 1 and W 2 are the first and second weight matrices, respectively, and b 1 and b 2 are the first and second bias vectors, respectively;
The neurons T ' 1 and T ' 2 are fused into an output feature T ' = [ T ' 1,T′2 ], and input into the softmax layer to obtain a prediction probability y ', wherein the formula is:
y′=softmax(T′)
Wherein, softmax represents a softmax function, the prediction probability y 'is a vector containing two element values y' 1 and y '2, y' 1 represents the probability that the power consumption data is detected as normal, y '2 represents the probability that the power consumption data is detected as abnormal, and y' e {0,1};
And when the probability y' 2 of the abnormal electricity consumption data is more than or equal to 0.5, judging that the electricity consumption data of the load user is abnormal.
16. A computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, which when executed by a processor, implements the steps of a power consumption abnormality detection method according to any one of claims 1 to 8.
CN202410285935.2A 2024-03-13 2024-03-13 Power consumption abnormality detection method and device and computer readable storage medium Pending CN118152857A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410285935.2A CN118152857A (en) 2024-03-13 2024-03-13 Power consumption abnormality detection method and device and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410285935.2A CN118152857A (en) 2024-03-13 2024-03-13 Power consumption abnormality detection method and device and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN118152857A true CN118152857A (en) 2024-06-07

Family

ID=91299650

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410285935.2A Pending CN118152857A (en) 2024-03-13 2024-03-13 Power consumption abnormality detection method and device and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN118152857A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118395360A (en) * 2024-06-28 2024-07-26 成都太阳高科技有限责任公司 Power load system anomaly analysis method and system based on big data

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118395360A (en) * 2024-06-28 2024-07-26 成都太阳高科技有限责任公司 Power load system anomaly analysis method and system based on big data

Similar Documents

Publication Publication Date Title
CN109842373B (en) Photovoltaic array fault diagnosis method and device based on space-time distribution characteristics
CN111444615B (en) Photovoltaic array fault diagnosis method based on K nearest neighbor and IV curve
CN110490385A (en) The unified prediction of electric load and thermic load in a kind of integrated energy system
CN118152857A (en) Power consumption abnormality detection method and device and computer readable storage medium
CN105678404A (en) Micro-grid load prediction system and method based on electricity purchased on-line and dynamic correlation factor
CN110503153B (en) Photovoltaic system fault diagnosis method based on differential evolution algorithm and support vector machine
CN111695736A (en) Photovoltaic power generation short-term power prediction method based on multi-model fusion
CN115358347B (en) Method for predicting remaining life of intelligent electric meter under different subsystems
CN112418687B (en) User electricity utilization abnormity identification method and device based on electricity utilization characteristics and storage medium
CN113627091A (en) Device and method for predicting energy load
CN115034485A (en) Wind power interval prediction method and device based on data space
CN116502160A (en) Automatic electric quantity data acquisition system
CN115271253A (en) Water-wind power generation power prediction model construction method and device and storage medium
CN117452063A (en) Semi-supervised electricity stealing time positioning method
Zhao et al. A photovoltaic array fault diagnosis method considering the photovoltaic output deviation characteristics
CN117113243B (en) Photovoltaic equipment abnormality detection method
CN117131022B (en) Heterogeneous data migration method of electric power information system
CN111967919A (en) System and method for analyzing electricity consumption behavior of residents based on autoregressive and adaptive boosting algorithm
CN117113086A (en) Energy storage unit load prediction method, system, electronic equipment and medium
CN114971081B (en) Irradiation prediction method based on time sequence analysis and daily statistics
CN111060755A (en) Electromagnetic interference diagnosis method and device
CN113191069B (en) Air conditioner load estimation method and system based on double-branch deep learning model
CN112529285A (en) Photovoltaic power generation power prediction method based on similar daily theory and PCA-PSO-BP
Wu et al. Overview of day-ahead solar power forecasts based on weather classifications
CN110837932A (en) Thermal power prediction method of solar heat collection system based on DBN-GA model

Legal Events

Date Code Title Description
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination