Power consumption anomaly detection method and system based on anomaly score

By preprocessing electricity consumption data and extracting multi-scale features, combined with the KNN algorithm and scoring formula, the problems of low efficiency and low accuracy in electricity anomaly detection are solved, automated electricity anomaly detection is achieved, and manpower and computing resources are saved.

CN120597071APending Publication Date: 2025-09-05张启秀
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510675077.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-23
Publication Date
2025-09-05

AI Technical Summary

Technical Problem

The existing power consumption anomaly detection methods are inefficient and inaccurate, and the machine learning algorithm needs to frequently optimize the training model during detection, resulting in a large consumption of computing resources and time.

Method used

By preprocessing electricity consumption data, extracting multi-scale electricity consumption features, and using the KNN algorithm and scoring formula for preliminary and secondary detection, combined with the abnormal score interval for judgment, automatic electricity consumption anomaly detection is achieved.

Benefits of technology

The accuracy and efficiency of power consumption anomaly detection are improved, the consumption of computing resources and time is reduced, and automated detection is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120597071A_ABST
    Figure CN120597071A_ABST
Patent Text Reader

Abstract

The invention discloses an abnormal score-based electricity consumption abnormity detection method and system. The method comprises the following steps of: 1, collecting electricity consumption data of a user in a historical time period and preprocessing the electricity consumption data; step 2, inputting the preprocessed data into a KNN algorithm to obtain a user electricity consumption abnormity prediction condition; 3, inputting the preprocessed data corresponding to the users with abnormal electricity consumption into a scoring formula to obtain an abnormal score; 4, training a KNN algorithm and a scoring formula according to the real power utilization condition of the user; 5, collecting and preprocessing power consumption data of the user in a target time period; and 6, inputting the preprocessed data into a KNN algorithm, if the power consumption of the user is abnormal, inputting the preprocessed data into an optimal score formula, and secondarily judging the power consumption condition of the user according to an abnormal score. According to the method, manpower is saved, efficiency and accuracy are improved, and consumption of computing resources and time is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of power consumption anomaly detection, and in particular to a power consumption anomaly detection method and system based on anomaly scores. Background Art

[0002] With the rapid development of smart grid and IoT technologies, user electricity usage data is being collected with increasing accuracy and frequency, providing a rich foundation for in-depth analysis of electricity usage behavior. However, user electricity usage scenarios are complex and diverse, and abnormal electricity usage patterns are frequent, such as abnormal power consumption caused by equipment failures, leakage caused by aging lines, and even malicious power theft. These anomalies not only lead to increased electricity bills and safety hazards for users (such as fires caused by overloaded lines), but also cause economic losses and challenges to power supply stability for power grid companies. Traditional detection relies on manual inspections or simple threshold judgments, which are inefficient and prone to missed detections and false positives. Some machine learning algorithms, leveraging their ability to learn from massive amounts of historical data, can accurately capture normal user electricity usage patterns and identify anomalies by comparing them with real-time data. However, these algorithms require time to optimize and train the models. Long periods of inactivity can reduce detection accuracy and consume significant computing resources and time. Summary of the Invention

[0003] To address the low efficiency and accuracy of existing manual methods for detecting anomalies in electricity usage, as well as the significant consumption of computing resources and time caused by the frequent optimization and training of machine learning algorithms, the present invention provides a method and system for detecting anomalies in electricity usage based on anomaly scores. This method preprocesses electricity usage data over a period of time to obtain electricity usage characteristics at multiple scales. These characteristics are then input into a KNN algorithm for preliminary detection. For users detected to have anomalies, the characteristics are then input into a scoring formula to obtain an anomaly score. The final detection result is then determined based on a preset anomaly score range.

[0004] In order to achieve the above object, the technical solution of the present invention is:

[0005] A first aspect of the present invention provides a method for detecting anomaly in electricity consumption based on anomaly scores, comprising:

[0006] Step 1: Collect the user's electricity consumption data within the historical time period and preprocess it to obtain multi-scale electricity consumption characteristics;

[0007] Step 2: Input the preprocessed data into the KNN algorithm to obtain the abnormal prediction of user electricity consumption for preliminary anomaly detection;

[0008] Step 3: Input the pre-processed data corresponding to users with abnormal electricity consumption into a preset scoring formula to obtain an abnormality score for secondary detection;

[0009] Step 4: Train the scoring formula based on the user's actual electricity usage over a historical period to obtain the optimal scoring formula to improve accuracy.

[0010] Step 5: Collect and pre-process the user's electricity consumption data within the target time period to obtain multi-scale electricity consumption characteristics;

[0011] Step 6: Input the preprocessed data into the KNN algorithm. If the user's electricity usage is abnormal, input the preprocessed data into the optimal scoring formula to obtain the abnormality score. The user's electricity usage is then judged again based on the abnormality score.

[0012] Furthermore, the step 1 specifically includes:

[0013] Collect electricity consumption data from users over a historical period; electricity consumption data includes electricity consumption for the month to be tested, monthly average electricity consumption over the historical period, standard deviation of monthly electricity consumption over the historical period, average monthly month-over-month electricity consumption ratio, maximum monthly electricity consumption over the historical period, minimum monthly electricity consumption over the historical period, and total electricity consumption over the historical period;

[0014] Construct electricity consumption features based on electricity consumption data. These features include the degree of electricity consumption anomaly, electricity consumption proportion, relative electricity consumption, and electricity consumption ratio, making it easier to extract features from electricity consumption data at multiple scales.

[0015] Normalize the electricity consumption characteristics.

[0016] Furthermore, the abnormal degree of power consumption is expressed by the following formula:

[0017]

[0018] Among them, R1 is the abnormal degree of electricity consumption, α1, α2 and α3 are different weight coefficients, D1 is the electricity consumption of the month to be detected, D max is the maximum monthly electricity consumption in the historical period, D min is the minimum monthly electricity consumption in the historical period, is the average monthly electricity consumption in the historical period, σ is the standard deviation of monthly electricity consumption in the historical period;

[0019] The electricity consumption ratio is expressed as follows:

[0020]

[0021] Among them, R2 is the proportion of electricity consumption, and E is the average monthly electricity consumption ratio;

[0022] The relative power consumption is expressed as follows:

[0023]

[0024] The electricity consumption ratio is expressed as follows:

[0025]

[0026] Among them, D′ is the total electricity consumption in the historical period, and R4 is the proportion of electricity consumption.

[0027] Furthermore, the K value in the KNN algorithm is calculated according to the following formula:

[0028]

[0029] Among them, K is the number of nearest neighbors used for prediction, N is the total number of samples, and n is the number of types.

[0030] Furthermore, the scoring formula is expressed as follows:

[0031]

[0032] Among them, S is the anomaly score, and β1, β2, β3, β4 and β5 are different weight coefficients.

[0033] Furthermore, the second determination of the user's electricity usage based on the anomaly score specifically includes:

[0034] Calculate the user's anomaly scores over multiple historical time periods and obtain the anomaly score range to facilitate judgment of whether the anomaly score is normal;

[0035] Determine whether the anomaly score is within the anomaly score range. If it is within the anomaly score range, it is determined that the user's electricity usage is normal. If it is outside the anomaly score range, the user's electricity usage is abnormal, so as to ensure the accuracy of the detection.

[0036] Furthermore, the anomaly score interval is expressed by the following formula:

[0037]

[0038] Among them, S min is the minimum anomaly score in the historical time period, S max is the anomaly score within the largest historical time period, m is the total number of historical time periods, The average anomaly score over multiple historical time periods.

[0039] A second aspect of the present invention provides a power consumption anomaly detection system based on anomaly scores, comprising:

[0040] The collection module is used to collect the user's electricity consumption data within the historical time period and pre-process it to obtain multi-scale electricity consumption characteristics;

[0041] The preliminary detection module is used to input the preprocessed data into the KNN algorithm to obtain the user's power consumption anomaly prediction for preliminary anomaly detection;

[0042] The anomaly score module is used to input the pre-processed data corresponding to users with abnormal electricity consumption into a preset scoring formula to obtain an anomaly score for secondary detection;

[0043] The training module is used to train the scoring formula based on the actual electricity consumption of users in the historical time period to obtain the optimal scoring formula to improve the accuracy;

[0044] The preprocessing module is used to collect and preprocess the user's electricity consumption data within the target time period to obtain multi-scale electricity consumption characteristics;

[0045] The detection module is used to input the pre-processed data into the KNN algorithm. If the user's electricity consumption is abnormal, the pre-processed data is input into the optimal scoring formula to obtain the abnormality score. The abnormality score is then used to make a secondary judgment on the user's electricity consumption;

[0046] A third aspect of the present invention proposes an electronic device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements a method for detecting power consumption anomalies based on anomaly scores as described in the first aspect above.

[0047] In a fourth aspect, the present invention provides a computer-readable storage medium, which includes a stored computer program. When the computer program is running, the device where the storage medium is located is controlled to execute a method for detecting power consumption anomalies based on anomaly scores as described in the first aspect above.

[0048] Beneficial effects of the present invention:

[0049] The present invention preprocesses electricity usage data to obtain multiple electricity usage features. These features are then used to extract electricity usage data from multiple scales, facilitating the acquisition of more accurate features and ensuring the accuracy of subsequent detection. Initial and secondary detection are then performed using the KNN algorithm and a scoring formula. Multiple detections further ensure detection accuracy, and anomaly scores are classified according to preset anomaly score intervals to complete electricity anomaly detection. The present invention can achieve automated electricity usage detection, saving manpower and improving efficiency and accuracy. Furthermore, due to multiple detections, frequent training and optimization of the scoring formula is not required, reducing computing resources and time consumption. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 A flowchart of a method for detecting power consumption anomaly based on anomaly scores is provided in an embodiment of the present invention.

[0051] Figure 2 This is an architecture diagram of a power consumption anomaly detection system based on anomaly scores provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0052] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0053] Example 1

[0054] like Figure 1 As shown, a method for detecting power consumption anomaly based on anomaly score includes:

[0055] S101: Collecting and pre-processing the user's electricity consumption data within a historical time period.

[0056] Specifically, the electricity consumption data of the user in the historical time period is collected; wherein, the electricity consumption data includes the electricity consumption of the month to be tested, the monthly average electricity consumption in the historical time period, the standard deviation of monthly electricity consumption in the historical time period, the average monthly month-on-month electricity consumption ratio, the maximum monthly electricity consumption in the historical time period, the minimum monthly electricity consumption in the historical time period and the total electricity consumption in the historical time period.

[0057] Electricity consumption characteristics are constructed based on electricity consumption data; among them, electricity consumption characteristics include the degree of electricity consumption anomaly, electricity consumption proportion, relative electricity consumption and electricity consumption proportion.

[0058] The degree of abnormal power consumption is expressed by the following formula:

[0059]

[0060] Among them, R1 is the abnormal degree of electricity consumption, α1, α2 and α3 are different weight coefficients, D1 is the electricity consumption of the month to be detected, D max is the maximum monthly electricity consumption in the historical period, D min is the minimum monthly electricity consumption in the historical period, is the average monthly electricity consumption during the historical period, and σ is the standard deviation of monthly electricity consumption during the historical period.

[0061] The proportion of electricity consumption is expressed as follows:

[0062]

[0063] Among them, R2 is the proportion of electricity consumption, and E is the average monthly electricity consumption ratio.

[0064] The relative power consumption is expressed as follows:

[0065]

[0066] The proportion of electricity consumption is expressed as follows:

[0067]

[0068] Among them, D′ is the total electricity consumption in the historical period, and R4 is the proportion of electricity consumption.

[0069] The electricity consumption characteristics are normalized to eliminate the dimensional differences of the electricity consumption characteristics.

[0070] S102: Input the preprocessed data into the KNN algorithm to obtain the abnormal prediction of user electricity consumption.

[0071] Specifically, electricity consumption data from multiple historical time periods is collected and preprocessed. The preprocessed historical data from each historical time period is constructed into a detection set. Multiple detection sets are merged to form a target set, and the preprocessed data is set as the set to be detected. The distance between the set to be detected and each detection set in the target set is calculated using the following formula:

[0072]

[0073] Among them, d is the distance between the set to be detected and the detection set, Z i is the i-th data in the set to be detected, m is the total number of data in the set to be detected, Y i is the i-th data in the detection set.

[0074] In order to quickly find the accurate K value when using the KNN algorithm, the present invention proposes a calculation process for the K value, which is specifically calculated according to the following formula:

[0075]

[0076] Among them, K is the number of nearest neighbors used for prediction, N is the total number of samples, that is, the number of detection sets in the target set, and n is the number of types. In the present invention, n is 2 (including two types: normal power consumption and abnormal power consumption).

[0077] Select K detection sets with the shortest distance d, and determine the type of the selected K detection sets with the shortest distance d. If most of the detection sets are of the normal power usage type, then the user's power usage is determined to be normal; if most of the detection sets are of the abnormal power usage type, then the user's power usage is determined to be abnormal.

[0078] S103: Inputting the pre-processed data corresponding to the users with abnormal electricity consumption into a preset scoring formula to obtain an abnormality score.

[0079] Specifically, if the user's electricity usage is normal, the detection is terminated. If the user's electricity usage is abnormal, the corresponding pre-processed data is input into the scoring formula for secondary detection to ensure the accuracy of the detection.

[0080] S104: The scoring formula is trained based on the actual electricity usage of the user in a historical time period to obtain an optimal scoring formula.

[0081] Specifically, the weight coefficients in the scoring formula are continuously adjusted through multiple optimization trainings until the optimal weight coefficients are obtained, and then the optimal scoring formula is obtained.

[0082] S105: Collect and pre-process the user's electricity usage data within the target time period.

[0083] S106: The pre-processed data is input into the KNN algorithm. If the user's electricity usage is abnormal, the pre-processed data is input into the optimal scoring formula to obtain an abnormality score, and the user's electricity usage is secondarily judged based on the abnormality score.

[0084] The present invention pre-processes the collected electricity consumption data and extracts features from the electricity consumption data at multiple scales to construct multiple electricity consumption features, which facilitates more accurate determination of the user's electricity consumption from the electricity consumption features. The K value is then calculated using a preset K value formula, and the KNN algorithm is used to perform a preliminary detection of the electricity consumption features based on the obtained K value. The users with abnormal electricity consumption in the preliminary detection are then determined, and the electricity consumption features of the users with abnormal electricity consumption are input into a preset scoring formula to obtain an abnormality score. Finally, it is finally determined whether the user has abnormal electricity consumption based on the abnormality score. The present invention realizes automated electricity consumption detection throughout the process, saves manpower, improves efficiency and accuracy, and because of multiple detections, there is no need to frequently train and optimize the KNN algorithm and scoring formula, reducing the consumption of computing resources and time.

[0085] Example 2

[0086] Based on the above embodiment, the present invention proposes a scoring formula and anomaly score interval, specifically including:

[0087] In order to more accurately judge the user's electricity usage, the present invention constructs a scoring formula, which concretizes the electricity usage into a score through the scoring formula, so as to facilitate accurate and intuitive completion of abnormality detection and judgment.

[0088] The scoring formula is expressed as follows:

[0089]

[0090] Among them, S is the anomaly score, and β1, β2, β3, β4 and β5 are different weight coefficients.

[0091] The anomaly score is judged according to the preset anomaly score range. If the anomaly score is within the anomaly score range, the user's electricity usage is determined to be normal. If it is outside the anomaly score range, the user's electricity usage is determined to be abnormal.

[0092] The anomaly score interval is obtained by calculating the anomaly scores of the user in multiple historical time periods and obtaining the anomaly score interval. The anomaly score interval is expressed as follows:

[0093]

[0094] Among them, S min is the minimum anomaly score in the historical time period, S max is the anomaly score within the largest historical time period, m is the total number of historical time periods, The average anomaly score over multiple historical time periods.

[0095] Example 3

[0096] Based on the above embodiments, Figure 2 As shown, the present invention proposes a power consumption anomaly detection system based on anomaly score, comprising:

[0097] The collection module is used to collect the user's electricity consumption data within a historical time period and pre-process it.

[0098] The preliminary detection module is used to input the preprocessed data into the KNN algorithm to obtain the abnormal prediction of user electricity consumption.

[0099] The anomaly score module is used to input the pre-processed data corresponding to users with abnormal electricity consumption into a preset scoring formula to obtain an anomaly score.

[0100] The training module is used to train the scoring formula based on the actual electricity consumption of users in a historical time period to obtain the optimal scoring formula.

[0101] The preprocessing module is used to collect and preprocess the user's electricity consumption data within the target time period.

[0102] The detection module is used to input the preprocessed data into the KNN algorithm. If the user's electricity consumption is abnormal, the preprocessed data is input into the optimal scoring formula to obtain the abnormal score, and the user's electricity consumption is judged again based on the abnormal score.

[0103] It should be noted that the power consumption anomaly detection system based on anomaly scores provided in the embodiment of the present invention is intended to implement the above-mentioned power consumption anomaly detection method based on anomaly scores. Its specific functions can be referred to the above-mentioned method embodiments and will not be repeated here.

[0104] Example 4

[0105] Based on the above embodiments, the present invention proposes an electronic device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements a method for detecting power consumption anomalies based on anomaly scores as described in the above embodiments.

[0106] The present invention proposes a computer-readable storage medium, which includes a stored computer program. When the computer program is running, the device where the storage medium is located is controlled to execute a power consumption anomaly detection method based on anomaly scores as described in the above embodiment.

[0107] In summary, the present invention obtains multiple electricity usage features by preprocessing electricity usage data. The electricity usage features are used to extract electricity usage data from multiple scales, facilitating the acquisition of more accurate features and ensuring the accuracy of subsequent detection. The KNN algorithm and scoring formula are then used for initial and secondary detection. Multiple detections further ensure detection accuracy, and the anomaly scores are classified according to preset anomaly score intervals to complete electricity anomaly detection. The present invention can achieve automated electricity usage detection, saving manpower and improving efficiency and accuracy. Furthermore, due to multiple detections, the scoring formula does not need to be frequently trained and optimized, reducing the consumption of computing resources and time.

[0108] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A method for detecting power consumption anomaly based on anomaly score, characterized in that: include: Step 1: Collect the user's electricity consumption data within the historical time period and pre-process it; Step 2: Input the preprocessed data into the KNN algorithm to obtain the abnormal prediction of user electricity consumption; Step 3: Input the pre-processed data corresponding to the users with abnormal electricity consumption into the preset scoring formula to obtain the abnormality score; Step 4: Train the scoring formula based on the user's actual electricity usage over a historical period to obtain the optimal scoring formula; Step 5: Collect and pre-process the user's electricity consumption data within the target time period; Step 6: Input the preprocessed data into the KNN algorithm. If the user's electricity usage is abnormal, input the preprocessed data into the optimal scoring formula to obtain the abnormality score. The user's electricity usage is then judged again based on the abnormality score.

2. The method for detecting anomaly in electricity consumption based on anomaly score according to claim 1, characterized in that: The step 1 specifically includes: Collect electricity consumption data from users over a historical period; electricity consumption data includes electricity consumption for the month to be tested, monthly average electricity consumption over the historical period, standard deviation of monthly electricity consumption over the historical period, average monthly month-over-month electricity consumption ratio, maximum monthly electricity consumption over the historical period, minimum monthly electricity consumption over the historical period, and total electricity consumption over the historical period; Construct electricity consumption characteristics based on electricity consumption data; electricity consumption characteristics include the degree of electricity consumption anomaly, electricity consumption proportion, relative electricity consumption, and electricity consumption proportion; Normalize the electricity consumption characteristics.

3. The method for detecting anomaly in power consumption based on anomaly score according to claim 2, characterized in that: The abnormal degree of power consumption is expressed by the following formula: Among them, R1 is the abnormal degree of electricity consumption, α1, α2 and α3 are different weight coefficients, D1 is the electricity consumption of the month to be detected, D max is the maximum monthly electricity consumption in the historical period, D min is the minimum monthly electricity consumption in the historical period, D is the average monthly electricity consumption in the historical period, and σ is the standard deviation of monthly electricity consumption in the historical period; The electricity consumption ratio is expressed as follows: Among them, R2 is the proportion of electricity consumption, and E is the average monthly electricity consumption ratio; The relative power consumption is expressed as follows: The electricity consumption ratio is expressed as follows: Among them, D′ is the total electricity consumption in the historical period, and R4 is the proportion of electricity consumption.

4. The method for detecting anomaly in electricity consumption based on anomaly score according to claim 1, characterized in that: The K value in the KNN algorithm is calculated according to the following formula: Among them, K is the number of nearest neighbors used for prediction, N is the total number of samples, and n is the number of types.

5. The method for detecting anomaly in power consumption based on anomaly score according to claim 3, characterized in that: The scoring formula is calculated as follows: Among them, S is the anomaly score, and β1, β2, β3, β4 and β5 are different weight coefficients.

6. The method for detecting anomaly in electricity consumption based on anomaly score according to claim 1, characterized in that: The secondary determination of the user's electricity usage based on the anomaly score specifically includes: Calculate the user's anomaly scores over multiple historical time periods and obtain the anomaly score range; Determine whether the anomaly score is within the anomaly score range. If it is within the anomaly score range, it is determined that the user's electricity usage is normal. If it is outside the anomaly score range, the user's electricity usage is abnormal.

7. The method for detecting anomaly in electricity consumption based on anomaly score according to claim 6, characterized in that: The anomaly score interval is expressed as follows: Among them, S min is the smallest anomaly score in the historical time period, S is the anomaly score, and S max is the anomaly score within the largest historical time period, m is the total number of historical time periods, The average anomaly score over multiple historical time periods.

8. A power consumption anomaly detection system based on anomaly score, characterized in that: include: The collection module is used to collect the user's electricity consumption data within the historical time period and pre-process it; The preliminary detection module is used to input the preprocessed data into the KNN algorithm to obtain the abnormal prediction of user electricity consumption; Anomaly score module, used to input the pre-processed data corresponding to users with abnormal electricity consumption into a preset scoring formula to obtain anomaly scores; The training module is used to train the scoring formula based on the actual electricity consumption of users in the historical time period to obtain the optimal scoring formula; A preprocessing module is used to collect and preprocess the user's electricity consumption data within the target time period; The detection module is used to input the preprocessed data into the KNN algorithm. If the user's electricity consumption is abnormal, the preprocessed data is input into the optimal scoring formula to obtain the abnormal score, and the user's electricity consumption is judged again based on the abnormal score.

9. An electronic device, characterized in that: The invention comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the method for detecting power consumption anomaly based on anomaly score according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that The storage medium includes a stored computer program, wherein when the computer program is executed, the device where the storage medium is located is controlled to execute the power consumption anomaly detection method based on anomaly score according to any one of claims 1 to 7.