Energy consumption anomaly detection methods, devices, computer equipment, and readable storage media
By combining the error reciprocal weighting mechanism of classical time series prediction and deep time series prediction, and dynamically adjusting the weights, the problem of low accuracy in energy consumption anomaly detection in existing technologies is solved, and more efficient energy consumption anomaly detection is achieved.
Patent Information
- Application Number
- CN202611492189.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-23
- Publication Date
- 2026-11-17
AI Technical Summary
In existing energy consumption anomaly detection schemes, the prediction model fusion scheme lacks dynamic change tracking and response capabilities in the setting of fusion weights, resulting in low detection accuracy.
A method combining classical time series forecasting and deep time series forecasting is adopted. The weights are dynamically adjusted through an error inverse weighting mechanism, and the forecast baseline threshold is fused to detect energy consumption anomalies.
It significantly improves the robustness and adaptability of energy consumption anomaly detection, and increases the detection accuracy.
Smart Images

Figure CN123115873A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of energy consumption detection technology, and in particular to a method, apparatus, computer equipment, and readable storage medium for detecting abnormal energy consumption. Background Technology
[0002] In engineering practice, existing energy consumption anomaly detection schemes generally use a fixed ratio or determine the fusion weights based on an offline validation set in the fusion scheme. This lacks the ability to track and respond to dynamic changes in model performance during operation, resulting in low accuracy in energy consumption anomaly detection. Summary of the Invention
[0003] In view of this, the purpose of the present invention is to overcome the shortcomings of the prior art and provide a method, apparatus, computer device and readable storage medium for detecting abnormal energy consumption.
[0004] This invention provides the following technical solution: In a first aspect, the present invention provides a method for detecting abnormal energy consumption, comprising: Collect valid historical samples from historical energy consumption data; Based on historical valid samples, a classic time-series prediction is performed on the target day to obtain the first predicted energy consumption value of the target day; the first predicted upper bound threshold of the target day is determined based on the first predicted energy consumption value of the target day and the first sensitivity coefficient. Based on historical valid samples, a deep time series prediction is performed on the target day to obtain the second predicted energy consumption value of the target day; the second predicted upper bound threshold of the target day is determined based on the second predicted energy consumption value and the second sensitivity coefficient. Obtain the prediction errors corresponding to classic time series prediction and deep time series prediction respectively to obtain the first error and the second error; normalize according to the reciprocal of the first error and the reciprocal of the second error respectively to obtain the first weight and the second weight; weight and sum the first prediction upper bound threshold and the second prediction upper bound threshold according to the first weight and the second weight respectively to obtain the fusion prediction baseline threshold of the target day. Anomaly detection of actual energy consumption observations on the target day is performed based on the fusion prediction baseline threshold.
[0005] Secondly, the present invention provides an energy consumption anomaly detection device, comprising: The sample acquisition module is used to collect valid historical samples from historical energy consumption data; The first prediction module is used to perform classical time-series prediction of the target day based on historical valid samples to obtain the first predicted energy consumption value of the target day; and to determine the first predicted upper limit threshold of the target day based on the first predicted energy consumption value of the target day and the first sensitivity coefficient. The second prediction module is used to perform deep time-series prediction of the target day based on historical valid samples to obtain the second predicted energy consumption value of the target day; and to determine the second prediction upper bound threshold of the target day based on the second predicted energy consumption value and the second sensitivity coefficient. The threshold calculation module is used to obtain the prediction errors corresponding to classical time series prediction and deep time series prediction, respectively, to obtain the first error and the second error; normalize according to the reciprocal of the first error and the reciprocal of the second error to obtain the first weight and the second weight; and perform weighted summation on the first prediction upper bound threshold and the second prediction upper bound threshold according to the first weight and the second weight to obtain the fusion prediction baseline threshold for the target day. The anomaly detection module is used to detect anomalies in the actual energy consumption observations for the target day based on the fusion prediction baseline threshold.
[0006] Thirdly, the present invention provides a computer device including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, it implements the energy consumption anomaly detection method as described in any of the foregoing embodiments.
[0007] Fourthly, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the energy consumption anomaly detection method as described in any of the foregoing embodiments.
[0008] The energy consumption anomaly detection method, apparatus, computer equipment, and readable storage medium disclosed in this invention integrate the upper bound thresholds of both classical time-series prediction and deep time-series prediction, and introduce an error reciprocal weighting mechanism. This increases the weight of the side with more accurate predictions and decreases the weight of the side with greater errors, thereby obtaining a fused prediction baseline as a judgment criterion for energy consumption anomaly detection, which significantly improves the robustness and adaptability of anomaly detection. Attached Figure Description
[0009] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope of protection of the present invention. In the various drawings, similar components are numbered similarly.
[0010] Figure 1 A schematic diagram of the architecture of the energy consumption anomaly detection system proposed in this embodiment is shown; Figure 2 A schematic diagram of the structure of the electronic device proposed in this embodiment is shown; Figure 3 A flowchart of the energy consumption anomaly detection method proposed in this embodiment is shown; Figure 4Another flowchart of the energy consumption anomaly detection method proposed in this embodiment is shown; Figure 5 This diagram illustrates another step in the energy consumption anomaly detection method proposed in this embodiment. Figure 6 This diagram illustrates another step in the energy consumption anomaly detection method proposed in this embodiment. Figure 7 A schematic diagram of the energy consumption anomaly detection device proposed in this embodiment is shown.
[0011] Explanation of reference numerals in the attached diagram: 101-Energy consumption acquisition device; 102-Energy consumption anomaly detection device; 103-Operation and maintenance terminal; 200-Electronic device; 201-Processor; 202-Memory; 203-Communication interface; 204-Bus; 701-Sample acquisition module; 702-First prediction module; 703-Second prediction module; 704-Threshold calculation module; 705-Anomaly detection module. Detailed Implementation
[0012] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0013] The components of the embodiments of the invention described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0014] In the following, the terms “comprising,” “having,” and their cognates, which may be used in various embodiments of the invention, are intended only to indicate a particular feature, number, step, operation, element, component, or combination thereof, and should not be construed as excluding, firstly, the presence of one or more other features, numbers, steps, operations, elements, components, or combinations thereof, or adding the possibility of one or more features, numbers, steps, operations, elements, components, or combinations thereof.
[0015] Furthermore, the terms "first," "second," and "third" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.
[0016] Unless otherwise specified, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which the various embodiments of the invention pertain. Terms (such as those defined in commonly used dictionaries) shall be interpreted as having the same meaning as in their contextual meaning in the relevant technical field and shall not be interpreted as having an idealized or overly formal meaning, unless clearly defined in the various embodiments of the invention.
[0017] For ease of understanding, some technical terms mentioned in the embodiments of the present invention will be explained here first.
[0018] The target load refers to the energy-consuming object for which anomaly detection is performed. It can be a power circuit, an energy-consuming device, an air conditioning system, or a floor power distribution trunk line. Each detection is performed on one target load. When multiple target loads are detected in parallel, each target load independently performs the following steps and maintains its own continuous energy consumption anomaly count and alarm level.
[0019] An hour refers to a time in hours, denoted as h, where h is an integer from 1 to 24. The h-th hour is the one-hour period between the h-th hour and the h+1-th hour of the day. In this embodiment of the invention, the time step of all hourly quantities is one hour, and the collection, prediction, anomaly detection and error statistics of energy consumption data are all performed at this granularity.
[0020] The statistical forecasting branch performs classic time series forecasting; the intelligent forecasting branch performs deep time series forecasting.
[0021] The predicted energy consumption value is the single-point predicted value given by the branch for a specific hour on a certain day; the upper bound threshold for prediction is the upper bound value constructed by the branch for fusion.
[0022] The quantile prediction value refers to the prediction value output by the intelligent prediction branch according to the preset quantile level q, which corresponds to the second predicted energy consumption value.
[0023] The residual standard deviation is a quantity obtained by performing root mean square operation on the time-by-time residuals within the rolling residual window when the intelligent prediction branch only outputs point predicted energy consumption values. It is used to characterize the degree of deviation of the recent predicted values of the branch from the measured values, including uneliminated systematic biases; in other expressions, it can also be called residual dispersion.
[0024] The sliding evaluation window refers to the time range used to calculate the mean absolute error, which is the most recent W days before the fusion time. The residual statistics at each time point within the preset residual window refer to the statistics performed by the intelligent prediction branch within the rolling residual window of length L.
[0025] Please see Figure 1This invention proposes an energy consumption anomaly detection system for executing energy consumption anomaly detection methods. The system may include an energy consumption acquisition device 101, an energy consumption anomaly detection device 102, and an operation and maintenance terminal 103. The energy consumption acquisition device 101 can be a smart meter, acquisition gateway, or energy meter deployed on the circuit where the target load is located, used to collect and report the energy consumption data of the target load. The energy consumption anomaly detection device 102 can be a server of an energy management platform, an edge gateway, or a terminal device with data processing capabilities, which obtains historical valid samples from the energy consumption acquisition device 101 and executes the methods described in the following embodiments. The operation and maintenance terminal 103 is used to present alarm levels, receive push notifications, and handle work orders.
[0026] Please see Figure 2 The electronic device 200 containing the aforementioned energy consumption anomaly detection device 102 may include a processor 201, a memory 202, a communication interface 203, and a bus 204. The communication interface 203 is used to exchange data with energy consumption acquisition devices and maintenance terminals; the memory 202 stores computer programs and is also used to store data such as valid sample sets, point-predicted energy consumption values of the two branches, prediction upper bound thresholds, fusion prediction baseline thresholds, anomaly logs, and alarm levels; the processor 201 communicates with the memory 202 via the bus 204 and runs the energy consumption anomaly detection device 102, so that the electronic device performs the following energy consumption anomaly detection method. The processor 201 may be at least one of a central processing unit, a digital signal processor, an application-specific integrated circuit, a field-programmable gate array, or other programmable logic devices; the memory 202 may be a read-only memory, random access memory, programmable read-only memory, erasable read-only memory, electrically erasable read-only memory, magnetic disk, or optical disk, etc.
[0027] Please see Figure 3 This embodiment proposes a method for detecting abnormal energy consumption. The method includes steps S301 to S305. The following describes each step in detail, taking an hourly time granularity for energy consumption values as an example. In other embodiments, the time granularity of energy consumption data can also be per minute or other granularities.
[0028] Step S301: Collect historical valid samples from historical energy consumption data.
[0029] In this embodiment, in order to meet the energy consumption anomaly detection requirements of the target load, a historical sample set is collected from historical energy consumption data, and the historical sample set is cleaned to obtain valid historical samples, which are used for prediction and statistics in subsequent steps.
[0030] Specifically, for the target load, complete daily energy consumption data for the past N historical days is collected from historical energy consumption data. Each day includes the energy consumption values for each hour of the 24 hours, forming a historical sample set S. N is flexibly set according to actual data availability and application scenarios, without fixed range constraints. The historical sample set S is updated daily using a rolling window mechanism. Each new day's data is added to the historical sample set, while the oldest day's sample is removed, thus maintaining its size at N days.
[0031] The historical sample set is denoted as: In the formula, For historical sample sets, For the number of days in the sample, For the first A complete daily energy consumption dataset for the day. For the first Heavenly Hour( The energy consumption value is expressed in kWh.
[0032] For example, if The historical sample set contains 60 days of energy consumption data, with each day consisting of 24 hourly energy consumption values, totaling... Energy consumption data points.
[0033] It should be noted that, since the collected energy consumption values may contain missing, interrupted, or abnormal readings, the historical sample set is cleaned to obtain valid historical samples.
[0034] Optionally, the historical sample set can be cleaned by handling single missing points, consecutive missing points, and extreme value removal to obtain valid historical samples. In the formula, For a valid sample set, The number of days that remain as valid samples after cleaning. The first after cleaning Complete daily energy consumption dataset.
[0035] As an example, for handling single-point missing data, if the number of consecutive missing periods in a daily energy consumption dataset does not exceed a preset number of hours, median imputation within the same time period can be used. Specifically, for the first... Heavenly missing values per hour Using historical sample sets of all historical days No. The median of the hourly energy consumption value is used as the filler, and the specific expression is: In the formula, This represents the median. This means only taking the values of other days, and not including the first day. The day is calculated automatically to avoid filling in missing values for itself; This means that only the values that are actually collected are taken; missing or discarded values are not included in the statistics. The expression as a whole means: for the [number]th [value]... Heavenly The missing value of "hour" refers to the historical data excluding the first hour. The first of all other heavens besides the heavens The effective energy consumption values for each hour are collected, sorted, and the median is used to fill in the gaps in the missing values. The preset number of hours can be 5 hours, but this embodiment does not limit this.
[0036] For handling consecutive missing data, if the number of consecutive missing periods in a daily energy consumption dataset exceeds a preset number of hours, the data for that day is marked as unavailable, and the entire daily energy consumption dataset is excluded from the historical sample set and not used for subsequent modeling.
[0037] For extreme value removal, the interquartile range method is used to detect extreme values for each daily energy consumption dataset. The normal value boundary is represented as follows: In the formula, , These are the lower and upper quartiles of the 24 energy consumption values for that day. Remove energy consumption values that exceed the normal threshold from each daily energy consumption dataset.
[0038] When the daily rejection rate exceeds 30% (i.e., more than 7 energy consumption values are rejected), a manual review process is triggered; after rejection, single-point missing data processing is performed on the daily dataset to ensure that it still contains 24 energy consumption values.
[0039] Step S302: Perform classical time-series prediction on the target day based on historical valid samples to obtain the first predicted energy consumption value of the target day; determine the first predicted upper bound threshold of the target day based on the first predicted energy consumption value of the target day and the first sensitivity coefficient.
[0040] In this embodiment, the effective sample set is used. Using historical energy consumption time series as input, a statistical forecasting branch is constructed using classical time series forecasting to explicitly model the trend, seasonality, and residuals of this historical energy consumption time series. The output is the predicted energy consumption values at 24 o'clock on the target day, i.e., the first predicted energy consumption value. .
[0041] Among them, the classic time series forecast can be Holt-Winters triple exponential smoothing method, ARIMA model or ETS decomposition model. In a single deployment, the statistical forecast branch only selects one of the classic time series forecast methods, and runs in parallel with the deep model of the other intelligent forecast branch without substituting for each other.
[0042] Furthermore, a first prediction upper bound threshold is calculated based on the first predicted energy consumption value and the first sensitivity coefficient of the statistical prediction branch, and then the first prediction upper bound threshold is adjusted based on the first predicted energy consumption value using the first sensitivity coefficient.
[0043] In one specific embodiment, the aforementioned step S302 includes: multiplying the sum of the first sensitivity coefficient and the preset value by the first predicted energy consumption value to obtain the first predicted upper limit threshold.
[0044] In this embodiment, the first prediction upper bound threshold The calculation formula is: In the formula, The first upper bound threshold for prediction is the h-th hour of the target day. This is the first sensitivity coefficient, i.e., the relative deviation coefficient, which can be initially set to 0.2, and constrained to... Within the range. This formula makes the width of the first prediction upper bound threshold adaptively scale with the load level, automatically increasing the threshold margin during high load periods and automatically narrowing the threshold margin during low load periods.
[0045] It is understandable that the addition of 1 in the formula for calculating the first upper bound threshold means to retain the point prediction energy consumption value itself, and only add a relative margin on it. If the 1 is omitted and the first sensitivity coefficient is directly multiplied by the point prediction energy consumption value, the result will be lower than the prediction value itself, and the difference will lose its reference.
[0046] For example, if the predicted energy consumption value for the 14th hour of a target day... , The first upper bound threshold for prediction at the 14th hour of the target day. The actual energy consumption observed in the 14th hour of the target day. When this occurs, an exception flag is triggered.
[0047] Step S303: Perform deep time-series prediction on the target day based on historical valid samples to obtain the second predicted energy consumption value of the target day; determine the second predicted upper bound threshold of the target day based on the second predicted energy consumption value and the second sensitivity coefficient.
[0048] In this embodiment, based on the effective sample set Based on historical energy consumption time series data, a deep time series prediction model is used to construct an intelligent prediction branch to learn complex nonlinear patterns in the historical energy consumption time series and output the target day. The predicted energy consumption values at 24 integer points, i.e., the second predicted energy consumption values. .
[0049] The deep time series prediction model can be one of the following: TimesFM time series large model, RNN recurrent neural network, Transformer time series variant, N-BEATS architecture, etc. This embodiment does not limit it.
[0050] Furthermore, a second prediction upper bound threshold is calculated based on the second predicted energy consumption value and the second sensitivity coefficient of the intelligent prediction branch, thereby adjusting the second prediction upper bound threshold based on the second predicted energy consumption value using the second sensitivity coefficient.
[0051] In one specific embodiment, when deep time series prediction supports outputting quantile prediction values, the quantile prediction value is multiplied by a second sensitivity coefficient to obtain a second prediction upper bound threshold; the quantile prediction value is the prediction value output by deep time series prediction at a preset quantile level that corresponds to the second prediction energy consumption value.
[0052] In this embodiment, when the selected deep time series prediction model supports outputting prediction intervals or quantile predictions while outputting the second predicted energy consumption value, the quantile prediction value corresponding to the preset quantile level q is taken. As a basic threshold, a second sensitivity coefficient is further used for adjustment to obtain a second upper bound threshold for prediction when the deep time series prediction model supports prediction intervals or quantiles. Here, q is, for example, 80 or 90, but this embodiment does not impose a limitation.
[0053] The quantile prediction value is the quantile prediction value output by the deep time series prediction at a preset quantile level q at the same whole hour as the second predicted energy consumption value. It represents the upper limit of the q% energy consumption value fluctuation at the corresponding whole hour. The preset quantile level q is a high quantile level of no less than 50%, that is, the quantile prediction value is the upper quantile prediction value, to avoid the upper limit threshold of the second prediction being lower than the normal energy consumption.
[0054] The second prediction upper bound threshold is expressed as: In the formula, The second upper bound threshold for prediction is the h-th hour of the target day. This is the second sensitivity coefficient, i.e., the quantile scaling factor, which can be initially set to 1 and constrained to... Within the range. When the value is 1, the quantile prediction value is directly used as the second upper bound threshold for prediction. When the value is greater than 1, the threshold should be relaxed based on the predicted quantile value to avoid false alarms of abnormal energy consumption. When the value is less than 1, the value is tightened based on the quantile prediction to avoid missing energy consumption anomalies.
[0055] For example, if a certain deep time series prediction model outputs the point prediction value for the 14th hour of the target day... , Quantile predicted values , Then the second prediction upper bound threshold is .
[0056] Understandably, using the quantiles of the deep time series prediction model's own output as the basic threshold serves to delegate the quantification of prediction uncertainty to the model: the larger q is, the lower the uncertainty. The higher the value, the smaller the proportion of the time period that exceeds the upper limit. Then, a scaling factor is applied to the quantiles to fine-tune the strictness of the alert based on the actual false alarm situation.
[0057] Please see Figure 4 In another specific embodiment, step S303 includes steps S3031 to S3032, and each step is described below.
[0058] Step S3031: When deep time series prediction does not support outputting quantile prediction values, obtain the predicted energy consumption value output by deep time series prediction within the preset residual window; take the difference between the actual energy consumption value corresponding to the preset residual window and the predicted energy consumption value corresponding to the preset residual window as the residual; calculate the root mean square of each residual to obtain the residual standard deviation.
[0059] In this embodiment, when the selected depth time series prediction model only supports point prediction output and does not output quantiles or prediction intervals, the prediction uncertainty of the intelligent prediction branch corresponding to the depth time series prediction is derived from the recent residuals.
[0060] Specifically: in length of Within a preset residual window, the actual energy consumption value at each integer point in the preset residual window is extracted from the predicted energy consumption value at each integer point in the preset residual window, and the difference is calculated hourly to obtain the residual; the root mean square of each residual is calculated to obtain the target day's residual. residual standard deviation Among them, the standard deviation of the residuals on the target date. The calculation formula is: In the formula, For the first time in the preset difference window The actual energy consumption value at each time step. For the intelligent prediction branch to the first The predicted energy consumption value at each time step.
[0061] Step S3032: Add the product of the second predicted energy consumption value and the second sensitivity coefficient and the residual standard deviation to obtain the second predicted upper bound threshold.
[0062] In this embodiment, the formula for calculating the second prediction upper bound threshold is: In the formula, For the intelligent prediction branch to the first The hourly predicted energy consumption value, i.e., the second predicted energy consumption value.
[0063] Understandably, the prediction float is obtained by multiplying the second sensitivity coefficient and the residual standard deviation. The prediction float is then added to the prediction energy consumption value to obtain the second upper bound threshold for the deep time series prediction model when it only supports point prediction output.
[0064] Step S304: Obtain the prediction errors corresponding to classic time series prediction and deep time series prediction respectively, and obtain the first error and the second error; normalize according to the reciprocal of the first error and the reciprocal of the second error respectively, and obtain the first weight and the second weight; weight and sum the first prediction upper bound threshold and the second prediction upper bound threshold according to the first weight and the second weight respectively, and obtain the fusion prediction baseline threshold of the target day.
[0065] In this embodiment, the most recent W historical days before the fusion time of the first and second prediction upper bound thresholds are obtained as a sliding evaluation window. The first and second predicted energy consumption values for the W historical days are predicted by executing the statistical prediction branch of classic time series prediction and the intelligent prediction branch of deep time series prediction, respectively.
[0066] Furthermore, based on the first and second predicted energy consumption values over W historical days, the prediction errors corresponding to classical time series prediction and deep time series prediction are calculated for the actual energy consumption observation values over W historical days.
[0067] For example, taking the prediction error as the mean absolute error, the mean absolute errors of the first and second predicted energy consumption values over W historical days with respect to the actual energy consumption observations over W historical days are calculated to obtain the first error and the second error, which are used as inputs for the fusion weights in this step. The formula for calculating the first error is: The formula for calculating the second error is: .
[0068] In other embodiments, the prediction error may also be root mean square error, mean absolute percentage error, mean square error, etc., which is not limited in this embodiment.
[0069] Understandably, both the statistical prediction branch and the intelligent prediction branch use their respective true point prediction values and actual energy consumption to calculate the prediction error, so that the comparison of the prediction accuracy of different prediction branches is based on a fair and equal methodology.
[0070] Furthermore, normalization is performed using the sum of the two reciprocals of the first and second errors as a common denominator, resulting in the first weight. Second weight The sum of them is always equal to 1, and each of them takes a value that always falls between 0 and 1.
[0071] Understandably, the reciprocal of the prediction error numerically represents the prediction accuracy of the corresponding prediction branch within the sliding evaluation window. The smaller the error, the larger the reciprocal. This makes the weight allocation no longer dependent on a fixed ratio preset by human experience, nor on the one-time calibration of the offline validation set before deployment. Instead, it is objectively determined by the actual prediction performance of the two branches in the most recent period before the fusion time. This transforms the quantity of accuracy, which is better the smaller it is (mean absolute error), into a quantity that is better the larger it is (the reciprocal of the mean absolute error), so that the weight changes in the same direction as the prediction accuracy.
[0072] Furthermore, the product of the first weight and the first prediction upper bound threshold, plus the product of the second weight and the second prediction upper bound threshold, is used to obtain the fusion prediction baseline threshold for the target day. The formula for calculating the fusion prediction baseline threshold is as follows: In the formula, For the target day Hour( The fusion prediction baseline threshold.
[0073] For example, if it is the 14th hour of a target day: , , , , ,but: , , .
[0074] Understandably, the fusion prediction baseline threshold combines the robustness of the statistical prediction branch with the adaptability of the deep prediction branch, and automatically compensates for the failure of a single prediction branch by another branch, forming an adaptive fault-tolerant mechanism.
[0075] In one specific embodiment, step S304 includes: using the reciprocal of the preset temperature parameter as the exponent, and raising the reciprocals of the first error and the second error to powers according to the exponent to obtain a first weighting factor and a second weighting factor; adding the first weighting factor and the second weighting factor to obtain a factor sum value; and dividing the first weighting factor and the second weighting factor by the factor sum value to obtain a first weight and a second weight.
[0076] In this embodiment, the first weight The calculation formula is: Second weight The calculation formula is: In the formula, The first error, This is the second error. Temperature parameter, default. Its adjustable range is The constraints are ,and .
[0077] Understandably, temperature parameters Control the sensitivity of the weights to the mean absolute error. The smaller the value, the more the weights tend to favor branches with smaller mean absolute errors. The larger the value, the more evenly weighted the values.
[0078] Step S305: Detect anomalies in the actual energy consumption observations for the target day based on the fusion prediction baseline threshold.
[0079] In this embodiment, the actual energy consumption observations of the target day at different times are compared and detected hourly with the fusion prediction baseline threshold of the corresponding time to achieve anomaly detection.
[0080] For example, targeting the hour on the target day. ( ), to the actual energy consumption observation value With fusion prediction baseline threshold For comparison, if the actual energy consumption observation value Greater than the fusion prediction baseline threshold If so, the actual energy consumption observation for that hour is abnormal.
[0081] For example, if the actual energy consumption observation value of the 14th hour of a certain target day =168.5kWh, =148.9kWh, then 168.5>148.9, triggering an anomaly flag.
[0082] Please see Figure 5 In one specific embodiment, the aforementioned step S305 is followed by steps S501 to S502, and each step is described below.
[0083] Step S501: Obtain the total count of energy consumption anomaly detections within a preset time period, and obtain the false alarm count among all energy consumption anomaly detections within the preset time period; calculate the ratio of false alarm count to total anomaly count.
[0084] In this embodiment, the total count of anomalies detected based on the comparison of fused prediction baseline thresholds within a preset time period is obtained, i.e., the total count of anomalies detected for each actual energy consumption observation. Greater than the fusion prediction baseline threshold If the total number of exceptions is increased by 1, then the total exception count will be incremented by 1.
[0085] Simultaneously, the number of false alarms of abnormal energy consumption within the preset time period is obtained to obtain the false alarm count, that is, the number of false alarms for each detected true energy consumption observation. Greater than the fusion prediction baseline threshold However, the actual observed energy consumption... If no anomaly occurs, the false alarm count is incremented by 1. The result for cases where no anomaly actually occurred is subject to manual auditing.
[0086] Furthermore, the ratio of false alarm count to total anomaly count is calculated to quantify the false alarm rate.
[0087] The preset time period is, for example, one month, meaning that a false alarm rate audit is performed once a calendar month. This embodiment does not limit this.
[0088] Step S502: If the ratio is greater than the first preset ratio threshold, and the first sensitivity coefficient is less than the first preset coefficient threshold, and the second sensitivity coefficient is less than the second preset coefficient threshold, then the first sensitivity coefficient and the second sensitivity coefficient are increased based on the first preset increment and the second preset increment, respectively; if the ratio is less than the second preset ratio threshold, and the first sensitivity coefficient is greater than the third preset coefficient threshold, and the second sensitivity coefficient is greater than the fourth preset coefficient threshold, and there are no missed anomalies within the preset time period, then the first sensitivity coefficient and the second sensitivity coefficient are decreased based on the first preset increment and the second preset increment, respectively.
[0089] In this embodiment, if the ratio Greater than the first preset ratio threshold, and the first sensitivity coefficient Less than the first preset coefficient threshold, and the second sensitivity coefficient If the value is less than the second preset coefficient threshold, it can be known that the current false alarm level is relatively high. At the same time, the first sensitivity coefficient and the second sensitivity coefficient have not reached their respective safety limits. Therefore, the first sensitivity coefficient and the second sensitivity coefficient are increased based on the first preset increment and the second preset increment, respectively.
[0090] For example, taking a first preset ratio threshold of 50%, a first preset coefficient threshold of 0.5, a second preset coefficient threshold of 1.5, and first and second preset increments of 0.02 and 0.05 respectively as an example, when... and , hour, Increase by 0.02, The value is increased by 0.05, which relaxes the upper bound threshold of both classic time series prediction and deep time series prediction, thereby reducing false alarms.
[0091] If the ratio is less than the second preset ratio threshold, and the first sensitivity coefficient is greater than the third preset coefficient threshold, and the second sensitivity coefficient is greater than the fourth preset coefficient threshold, and there are no missed anomalies within the preset time period, it can be known that there may be a risk of missed detection in the current anomaly detection. At the same time, if the first sensitivity coefficient and the second sensitivity coefficient exceed their respective safety limits, then the first sensitivity coefficient and the second sensitivity coefficient will be reduced based on the first preset increment and the second preset increment, respectively.
[0092] For example, taking a second preset ratio threshold of 20% as an example, when And there were no omissions, and , hour, Decrease by 0.02, Reducing it by 0.05 allows both classical time series prediction and deep time series prediction to tighten the upper bound threshold of prediction, thereby reducing the chance of missing anomalies.
[0093] If the ratio is greater than or equal to the second preset ratio threshold and less than or equal to the first preset ratio threshold, it can be known that the risk of false alarm and false negative detection of the current anomaly detection is small, so the first sensitivity coefficient and the second sensitivity coefficient will not be adjusted.
[0094] Understandably, the sensitivity parameters for energy consumption anomaly detection can be continuously and adaptively adjusted based on the audit results of the false alarm rate during actual operation, allowing it to converge to the optimal sensitivity equilibrium point over long-term operation without frequent manual intervention in parameter tuning, thus reducing the system's maintenance burden. Furthermore, if only the sensitivity coefficient of a single branch is adjusted while the threshold width of the other branch remains unchanged, the fusion baseline will be excessively pulled to one side; simultaneous adjustment of both branches allows the prediction upper bound width to converge collaboratively to the equilibrium point.
[0095] It should be noted that this embodiment sets a sensitivity coefficient safety constraint: Therefore, when the adjusted sensitivity coefficient value exceeds the boundary, it is truncated to the boundary value. Furthermore, the adjustment step sizes for the first and second sensitivity coefficients are different. Step size 0.02, (Step size 0.05), because the two are of different magnitudes. The relative deviation ratio of the predicted control point values By controlling the scaling ratio of the quantile prediction values, the differential step size ensures that each adjustment has roughly the same impact on the final fusion threshold.
[0096] Please see Figure 6 In one specific embodiment, after step S305, steps S601 to S602 are included. Each step will be described in detail below.
[0097] Step S601: If the actual energy consumption observation value is abnormal, the continuous abnormal count of energy consumption is accumulated, and the relative deviation of the actual energy consumption observation value is calculated based on the difference between the actual energy consumption observation value and the fusion prediction baseline threshold.
[0098] In this embodiment, if the actual energy consumption observation value in the h-th hour is abnormal, the continuous energy consumption anomaly count is accumulated; simultaneously, the difference between the actual energy consumption observation value in the h-th hour and the fusion prediction baseline threshold in the h-th hour is divided by the fusion prediction baseline threshold in the h-th hour to obtain the relative deviation of the actual energy consumption observation value in the h-th hour. The calculation formula is as follows: .
[0099] Understandably, the continuous energy consumption anomaly count is used to record the continuity of energy consumption anomalies, while the relative deviation is used to quantify the degree of energy consumption anomalies.
[0100] It should be noted that if the current actual energy consumption observation value is not abnormal, the current continuous energy consumption anomaly count will be reset to zero, or the continuous energy consumption anomaly count will be reset according to other decay rules. This embodiment does not limit this.
[0101] Step S602: Perform energy consumption anomaly processing based on continuous energy consumption anomaly count and relative deviation.
[0102] In this embodiment, if the current actual energy consumption observation value is abnormal, the first level of processing is first performed on the current energy consumption abnormality. For example, the first level of processing is abnormal recording, that is, the current actual energy consumption observation value with abnormal energy consumption is recorded in the abnormal log, without triggering active notification.
[0103] If the current actual energy consumption observation value is abnormal, and the corresponding relative deviation is greater than a preset deviation threshold, then in addition to performing the first-level processing for the current energy consumption anomaly, the highest-level anomaly processing, namely the third-level processing, is further performed. For example, the third-level processing is a critical alarm, which means pushing a notification of the current energy consumption anomaly and automatically generating a handling work order. The preset deviation threshold is, for example, 50%, but this embodiment does not limit it.
[0104] If an anomaly occurs in the current actual energy consumption observation value, and the corresponding relative deviation is less than or equal to a preset deviation threshold, and if the continuous anomaly count reaches a preset count threshold, it indicates that anomalies have occurred for several consecutive hours. Based on the first-level processing of the current energy consumption anomaly, a second-level processing is further performed. For example, the second-level processing is a primary alarm, i.e., pushing an operation and maintenance notification. The preset count threshold is, for example, 3, but this embodiment does not limit it.
[0105] If the current actual energy consumption observation value is abnormal, and the corresponding relative deviation is less than or equal to the preset deviation threshold, and the continuous energy consumption anomaly count exceeds the preset count threshold, and the second-level processing has been performed and continues, if the relative deviation of the continuous period after the second-level processing is performed increases with time (for example, satisfying Δ(d,h)<Δ(d,h+1)<Δ(d,h+2)), then the third-level processing will be further performed on the current energy consumption anomaly based on the first-level processing.
[0106] For example, energy consumption anomalies are triggered for four consecutive time periods from the 10th to the 13th hour of a target day, with relative deviations of respectively. , , , If the deviation increases hourly, the second level of processing will be triggered in the 12th hour, and the third level of processing will be upgraded in the 13th hour.
[0107] The energy consumption anomaly detection method proposed in this embodiment integrates the upper bound thresholds of both classical time-series prediction and deep time-series prediction, and introduces an error inverse weighting mechanism. This increases the weight of the side with more accurate predictions and decreases the weight of the side with greater errors, thereby obtaining a fused prediction baseline as a judgment criterion for energy consumption anomaly detection, which significantly improves the robustness and adaptability of anomaly detection.
[0108] Furthermore, this disclosure provides an energy consumption anomaly detection device 102, please refer to [link to relevant documentation]. Figure 7 ,include: The sample acquisition module 701 is used to collect historical valid samples from historical energy consumption data; The first prediction module 702 is used to perform classical time-series prediction on the target day based on historical valid samples to obtain a first predicted energy consumption value; and to determine a first prediction upper limit threshold based on the first predicted energy consumption value and a first sensitivity coefficient. The second prediction module 703 is used to perform deep time-series prediction of the target day based on historical valid samples to obtain a second predicted energy consumption value; and to determine a second prediction upper limit threshold based on the second predicted energy consumption value and the second sensitivity coefficient. The threshold calculation module 704 is used to obtain the prediction errors corresponding to classical time series prediction and deep time series prediction respectively, to obtain the first error and the second error; normalize according to the reciprocal of the first error and the reciprocal of the second error respectively to obtain the first weight and the second weight; and perform weighted summation on the first prediction upper bound threshold and the second prediction upper bound threshold according to the first weight and the second weight respectively to obtain the fusion prediction baseline threshold. The anomaly detection module 705 is used to detect anomalies in the actual energy consumption observations of the target day based on the fusion prediction baseline threshold.
[0109] Optionally, the first prediction module 702 is further configured to multiply the sum of the first sensitivity coefficient and the preset value by the first prediction energy consumption value to obtain the first prediction upper limit threshold.
[0110] Optionally, the second prediction module 703 is further configured to multiply the quantile prediction value by a second sensitivity coefficient to obtain a second prediction upper limit threshold when the deep time series prediction supports outputting quantile prediction values; the quantile prediction value is the prediction value output by the deep time series prediction at a preset quantile level that corresponds to the second prediction energy consumption value.
[0111] Optionally, the second prediction module 703 is further configured to: obtain the predicted energy consumption value output by deep time series prediction within a preset residual window when deep time series prediction does not support the output of quantile predicted values; take the difference between the actual energy consumption value corresponding to the preset residual window and the predicted energy consumption value corresponding to the preset residual window as the residual; perform root mean square calculation on each residual to obtain the residual standard deviation; and add the second predicted energy consumption value to the product of the second sensitivity coefficient and the residual standard deviation to obtain the second prediction upper bound threshold.
[0112] Optionally, the threshold calculation module 704 is further configured to use the reciprocal of the preset temperature parameter as an exponent, and to raise the reciprocal of the first error and the reciprocal of the second error to a power according to the exponent to obtain a first weighting factor and a second weighting factor; to add the first weighting factor and the second weighting factor to obtain a factor sum value; and to divide the first weighting factor and the second weighting factor by the factor sum value to obtain a first weight and a second weight.
[0113] Optionally, the system also includes: The anomaly handling module is used to accumulate the continuous anomaly count of energy consumption if the actual energy consumption observation value is abnormal, and calculate the relative deviation of the actual energy consumption observation value based on the difference between the actual energy consumption observation value and the fusion prediction baseline threshold; and perform energy consumption anomaly handling based on the continuous anomaly count and the relative deviation.
[0114] Optionally, the system also includes: The coefficient update module is used to obtain the total count of energy consumption anomaly detections within a preset time period, and to obtain the false alarm count among all energy consumption anomaly detections within the preset time period; calculate the ratio of the false alarm count to the total count of anomalies; if the ratio is greater than a first preset ratio threshold, and the first sensitivity coefficient is less than a first preset coefficient threshold, and the second sensitivity coefficient is less than a second preset coefficient threshold, then the first sensitivity coefficient and the second sensitivity coefficient are increased based on a first preset increment and a second preset increment, respectively; if the ratio is less than a second preset ratio threshold, and the first sensitivity coefficient is greater than a third preset coefficient threshold, and the second sensitivity coefficient is greater than a fourth preset coefficient threshold, and there are no missed anomalies within the preset time period, then the first sensitivity coefficient and the second sensitivity coefficient are decreased based on a first preset increment and a second preset increment, respectively.
[0115] The apparatus provided in this embodiment can perform the steps of the energy consumption anomaly detection method provided in Embodiment 1. To avoid repetition, the steps will not be repeated.
[0116] The energy consumption anomaly detection device proposed in this embodiment integrates the upper bound thresholds of both classical time-series prediction and deep time-series prediction, and introduces an error reciprocal weighting mechanism. This increases the weight of the side with more accurate predictions and decreases the weight of the side with greater errors, thereby obtaining a fused prediction baseline as a judgment criterion for energy consumption anomaly detection, which significantly improves the robustness and adaptability of anomaly detection.
[0117] Furthermore, embodiments of this application provide a computer program product, which includes a computer program or computer-executable instructions stored in a computer-readable storage medium. The processor of an electronic device reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions, causing the electronic device to perform the power consumption anomaly detection method described above in this application embodiment.
[0118] Furthermore, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions or a computer program. When the computer-executable instructions or the computer program are executed by a processor, the processor will execute the power consumption anomaly detection method provided in embodiments of this application. For example, ... Figure 3 The energy consumption anomaly detection method is shown.
[0119] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a variety of devices including one or any combination of the above-mentioned memories.
[0120] In some embodiments, computer-executable instructions may take the form of programs, software, software modules, scripts, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as stand-alone programs or as modules, components, subroutines, or other units suitable for use in a computing environment.
[0121] As an example, computer-executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple co-located files (e.g., files that store one or more modules, subroutines, or code sections).
[0122] In all examples shown and described herein, any specific values should be interpreted as merely exemplary and not as limitations; therefore, other examples of exemplary embodiments may have different values.
[0123] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0124] The above-described embodiments are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention.
Claims
1. A method for detecting abnormal energy consumption, characterized in that, include: Collect valid historical samples from historical energy consumption data; Based on the historical valid samples, a classic time-series prediction is performed on the target day to obtain the first predicted energy consumption value of the target day; based on the first predicted energy consumption value of the target day and the first sensitivity coefficient, the first predicted upper bound threshold of the target day is determined. Based on the historical valid samples, a deep time-series prediction is performed on the target day to obtain a second predicted energy consumption value for the target day; based on the second predicted energy consumption value and the second sensitivity coefficient, a second predicted upper bound threshold for the target day is determined. The prediction errors corresponding to the classical time series prediction and the deep time series prediction are obtained respectively to obtain the first error and the second error; the first weight and the second weight are obtained by normalizing the first error and the second error respectively; the first prediction upper bound threshold and the second prediction upper bound threshold are obtained by weighted summation according to the first weight and the second weight respectively to obtain the fusion prediction baseline threshold of the target day. Anomaly detection is performed on the actual energy consumption observations for the target day based on the fusion prediction baseline threshold.
2. The energy consumption anomaly detection method according to claim 1, characterized in that, The step of determining the first upper bound threshold of the target day based on the first predicted energy consumption value and the first sensitivity coefficient of the target day includes: The sum of the first sensitivity coefficient and the preset value is multiplied by the first predicted energy consumption value to obtain the first predicted upper limit threshold.
3. The energy consumption anomaly detection method according to claim 1, characterized in that, The step of determining the second predicted upper bound threshold for the target day based on the second predicted energy consumption value and the second sensitivity coefficient for the target day includes: If the depth time series prediction does not support output quantile prediction values, obtain the predicted energy consumption value output by the depth time series prediction within a preset residual window; The difference between the actual energy consumption value corresponding to the preset residual window and the predicted energy consumption value corresponding to the preset residual window is taken as the residual; The root mean square of each residual is calculated to obtain the standard deviation of the residual. The second predicted energy consumption value is added to the product of the second sensitivity coefficient and the residual standard deviation to obtain the second predicted upper bound threshold.
4. The energy consumption anomaly detection method according to claim 1, characterized in that, The step of determining the second predicted upper bound threshold for the target day based on the second predicted energy consumption value and the second sensitivity coefficient for the target day includes: When the depth time series prediction supports outputting quantile prediction values, the quantile prediction value is multiplied by the second sensitivity coefficient to obtain the second prediction upper bound threshold; the quantile prediction value is the prediction value output by the depth time series prediction at a preset quantile level, corresponding to the second prediction energy consumption value.
5. The energy consumption anomaly detection method according to claim 1, characterized in that, The step of normalizing based on the reciprocals of the first error and the second error to obtain the first weight and the second weight includes: The reciprocal of the preset temperature parameter is used as the exponent. The reciprocals of the first error and the second error are raised to powers based on the exponent to obtain the first weighting factor and the second weighting factor. Add the first weighting factor to the second weighting factor to obtain the factor sum value; Divide the first weight factor and the second weight factor by the sum of the factors and values respectively to obtain the first weight and the second weight.
6. The energy consumption anomaly detection method according to claim 1, characterized in that, After performing anomaly detection on the actual energy consumption observations of the target day based on the fusion prediction baseline threshold, the process includes: If the actual energy consumption observation value is abnormal, the continuous abnormal energy consumption count is accumulated, and the relative deviation of the actual energy consumption observation value is calculated based on the difference between the actual energy consumption observation value and the fusion prediction baseline threshold. Energy consumption anomaly processing is performed based on the continuous energy consumption anomaly count and the relative deviation.
7. The energy consumption anomaly detection method according to claim 1, characterized in that, After performing anomaly detection on the actual energy consumption observations of the target day based on the fusion prediction baseline threshold, the process includes: Obtain the total count of energy consumption anomaly detections within a preset time period, and obtain the false alarm count among all energy consumption anomaly detections within the preset time period; Calculate the ratio of the false alarm count to the total anomaly count; If the ratio is greater than a first preset ratio threshold, and the first sensitivity coefficient is less than a first preset coefficient threshold, and the second sensitivity coefficient is less than a second preset coefficient threshold, then the first sensitivity coefficient and the second sensitivity coefficient are increased based on the first preset increment and the second preset increment, respectively. If the ratio is less than the second preset ratio threshold, and the first sensitivity coefficient is greater than the third preset coefficient threshold, and the second sensitivity coefficient is greater than the fourth preset coefficient threshold, and there are no missed anomalies within the preset time period, then the first sensitivity coefficient and the second sensitivity coefficient are reduced based on the first preset increment and the second preset increment, respectively.
8. An energy consumption anomaly detection device, characterized in that, include: The sample acquisition module is used to collect valid historical samples from historical energy consumption data; The first prediction module is used to perform classical time-series prediction on the target day based on the historical valid samples to obtain the first predicted energy consumption value of the target day; and to determine the first prediction upper bound threshold of the target day based on the first predicted energy consumption value of the target day and the first sensitivity coefficient. The second prediction module is used to perform deep time-series prediction on the target day based on the historical valid samples to obtain the second predicted energy consumption value of the target day; and to determine the second predicted upper bound threshold of the target day based on the second predicted energy consumption value and the second sensitivity coefficient. The threshold calculation module is used to obtain the prediction errors corresponding to the classic time series prediction and the deep time series prediction respectively, to obtain a first error and a second error; normalize according to the reciprocal of the first error and the reciprocal of the second error respectively to obtain a first weight and a second weight; and perform a weighted summation on the first prediction upper bound threshold and the second prediction upper bound threshold according to the first weight and the second weight respectively to obtain the fusion prediction baseline threshold of the target day. An anomaly detection module is used to detect anomalies in the actual energy consumption observations of the target day based on the fusion prediction baseline threshold.
9. A computer device, characterized in that, It includes a memory and a processor, the memory storing a computer program that, when executed by the processor, implements the energy consumption anomaly detection method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the energy consumption anomaly detection method as described in any one of claims 1 to 7.
