NILM event detection method and system based on double sliding windows
By using adaptive dual sliding window and logarithmic generalized likelihood ratio detection method in NILM event detection, the problem of high false alarm rate caused by relying on preset templates in the prior art is solved, and variable point detection with high precision and low false alarm rate is achieved.
Patent Information
- Application Number
- CN202411779166.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-12-05
AI Technical Summary
The existing NILM event detection methods rely on preset templates and cannot adapt to data changes, resulting in high false positive rates.
The event detection method based on the double sliding window is adopted, and the long and short double sliding window sequences are extracted through the adaptive double sliding window, and the logarithmic linear general likelihood ratio test method is used to detect, and the change point is output.
It improves the variable point detection accuracy of non-invasive load monitoring, reduces false alarm rate, is suitable for complex and non-priori distribution load data, real-time detection and efficient power load monitoring.
Smart Images

Figure CN119720020A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of non-intrusive load monitoring, and in particular to a NILM event detection method and system based on double sliding windows. Background Art
[0002] In non-intrusive load monitoring (NILM), event detection is a very important link, which plays a key role in the accuracy of load identification and resource saving. The main task of event detection is to accurately detect the start and end time of the event from the total power and other data in real time, laying the foundation for the subsequent feature extraction and identification of the load.
[0003] At present, most of the existing event detection methods are based on pattern matching. Pattern matching methods detect whether an event has occurred by matching the sequence fragments corresponding to the event transient process with the established feature library. Pattern matching methods perform well in detecting certain specific types of events, but their accuracy and interpretability cannot meet the requirements when faced with complex events. This method usually requires developers to manually set decision rules and select appropriate conditions to adapt to data characteristics. Therefore, the accuracy of the model depends largely on the developer's professional knowledge and experience. As the scale of data continues to expand and the complexity increases, the preset model may be difficult to adapt to the needs of new data. Over-reliance on manually set rules and conditions makes the model too rigid and unable to flexibly adapt to changes and anomalies in the data. Summary of the invention
[0004] In view of this, in order to solve the technical problem that most of the existing NILM event detection methods rely on preset templates and cannot adapt to data changes, resulting in a high false alarm rate, the present invention proposes a NILM event detection method based on a double sliding window, the method comprising the following steps:
[0005] Acquire high-frequency load data and store the high-frequency load data in a circular queue form to obtain a data sequence;
[0006] A double sliding window is formed in the queue, data is extracted from the data sequence based on the adaptive double sliding window, and a long and short double sliding window sequence is output;
[0007] For the long and short double sliding window sequence, a log-linear generalized likelihood ratio test method is used to perform detection and output the change point.
[0008] In some embodiments, the original high-frequency load data needs to be preprocessed to ensure data quality and applicability, including:
[0009] The original high-frequency load data is cleaned, missing values, outliers and noise are processed, and then normalized to scale the data to the preset range.
[0010] In some embodiments, the step of forming a double sliding window in the queue, extracting data from the data sequence based on the adaptive double sliding window, and outputting a long and short double sliding window sequence specifically includes:
[0011] Initial double sliding windows, defining the initial length of the first window and the initial length of the second window;
[0012] Calculate the fitting error of the data in the first window and the second window;
[0013] The lengths of the first window and the second window are dynamically adjusted according to the trend change of the load signal.
[0014] Through this preferred step, the double sliding window structure is used to improve the detection accuracy.
[0015] In some embodiments, the step of using a log-linear generalized likelihood ratio test method to detect the long and short double sliding window sequence and outputting the change point specifically includes:
[0016] Set multiple thresholds;
[0017] In different windows, the generalized likelihood ratio test statistic is calculated for each load data point;
[0018] Use recursion to simplify the calculation, and rewrite the calculation formula of the generalized likelihood ratio test statistic based on the recursive idea;
[0019] The generalized likelihood ratio test statistic of each threshold is summed and solved for the maximum value, and compared with the decision threshold to obtain the change point.
[0020] In some embodiments, the step of detecting the long and short double sliding window sequence using a log-linear generalized likelihood ratio test method and outputting a change point further includes:
[0021] The pruning technique is used to reduce the computational complexity, and each candidate change point is screened during the recursive calculation process.
[0022] The present invention also proposes a NILM event detection system based on a double sliding window, the system comprising:
[0023] A data sorting module is used to obtain high-frequency load data and store the high-frequency load data in a circular queue form to obtain a data sequence;
[0024] A data extraction module forms a double sliding window in the queue, extracts data from the data sequence based on the adaptive double sliding window, and outputs a long and short double sliding window sequence;
[0025] The data detection module detects the long and short double sliding window sequences using a log-linear generalized likelihood ratio test method and outputs a change point.
[0026] Based on the above scheme, the present invention provides a NILM event detection method and system based on dual sliding windows. The change point detection accuracy of non-invasive load monitoring is improved by combining the dual sliding window structure with pruning technology and log-linear non-parametric algorithm; wherein, the short window is used to quickly respond to instantaneous changes in the load, while the long window captures the overall trend, so that the detection takes into account both sensitivity and stability. In addition, the pruning technology reduces the amount of calculation by eliminating insignificant candidate points, thereby achieving real-time detection. The empirical cumulative distribution function under multiple thresholds is used to improve detection accuracy and robustness, making the present invention particularly suitable for complex load data without prior distribution. The present invention not only reduces the false alarm rate, but also significantly improves the detection efficiency, and is suitable for power load monitoring scenarios that require real-time and high-precision in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is a flow chart of the steps of a NILM event detection method based on double sliding windows of the present invention;
[0028] Figure 2 It is a flowchart of data extraction based on adaptive double sliding windows in a specific embodiment of the present invention;
[0029] Figure 3 It is a structural block diagram of a NILM event detection system based on double sliding windows of the present invention. DETAILED DESCRIPTION
[0030] The double sliding windows in the prior art are usually fixed windows or windows of the same length. Event detection using fixed windows is easily interfered by noise, especially in high-frequency data streams, where short-term fluctuations may be mistaken for load changes. Secondly, the fixed window size cannot flexibly adapt to changes in different time scales. When the load changes are small or slow, the fixed window size may lead to a decrease in detection accuracy. Many prior arts rely on specific statistical assumptions (such as Gaussian distribution). In actual load data, these assumptions often fail to hold, resulting in increased false alarm and missed alarm rates.
[0031] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0032] It should be noted that, for the convenience of description, only the parts related to the relevant invention are shown in the drawings. In the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other.
[0033] It should be understood that the "system", "device", "unit" and / or "module" used in this application is a method for distinguishing different components, elements, parts, portions or assemblies at different levels. However, if other words can achieve the same purpose, the word can be replaced by other expressions.
[0034] As shown in this application and claims, unless the context clearly indicates an exception, the words "a", "an", "a kind" and / or "the" do not refer to the singular, but also include the plural. Generally speaking, the terms "include" and "comprise" only indicate the inclusion of clearly identified steps and elements, and these steps and elements do not constitute an exclusive list. The method or device may also include other steps or elements. The elements defined by the sentence "includes a..." do not exclude the existence of other identical elements in the process, method, commodity or device that includes the elements.
[0035] In the description of the embodiments of the present application, "plurality" means two or more than two. The following terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features.
[0036] In addition, flow charts are used in the present application to illustrate the operations performed by the system according to the embodiments of the present application. It should be understood that the preceding or following operations are not necessarily performed accurately in order. On the contrary, the various steps may be processed in reverse order or simultaneously. At the same time, other operations may also be added to these processes, or a certain step or several steps of operations may be removed from these processes.
[0037] Reference Figure 1 , is a flow chart of an optional example of a NILM event detection method based on a double sliding window proposed in the present invention, which can be applied to a computer device. The detection method proposed in this embodiment may include but is not limited to the following steps:
[0038] Step S1, obtaining high-frequency load data and storing it in a circular queue form to obtain a data sequence;
[0039] Step S2, extracting data from the data sequence based on an adaptive double sliding window, and outputting a long and short double sliding window sequence;
[0040] Step S3: Based on the log-linear generalized likelihood ratio test method, the long-short double sliding window sequence is tested to obtain a change point detection result.
[0041] In some feasible embodiments, the step S1 further includes:
[0042] Before performing change point detection, the original high-frequency load data needs to be preprocessed to ensure data quality and applicability. First, the data is cleaned to deal with missing values, outliers and noise, and then normalized to scale the data to a uniform range for subsequent analysis.
[0043] Then the processed data is stored in the form of a circular queue, and a double sliding window is formed in the queue. The load data sequences in the front and rear sliding windows can be expressed as [y l,1 ,y l,2 ,…,y l,L ]、[y r,1 ,y r,2 ,…,y r,L ], where L is the length of the sliding window.
[0044] In some feasible embodiments, the step S2 specifically includes:
[0045] S2.1. Initialize the double sliding window and define the initial length L of the short window small and the initial length of the long window L large The short window is used to capture the rapid characteristics of load changes, while the long window is used to observe the overall trend. At the beginning of the window, the initial window length is set and the preliminary statistical characteristics of the load data series are calculated, including the mean and standard deviation.
[0046] S2.2, calculate the fitting error within the window, for the short window L small and long window L large Calculate the fitting error for the data in:
[0047]
[0048] Among them, y i Represents the load data within the window, is the mean of the data in the window, and Δy represents the difference between the maximum and minimum values of the load data in the window.
[0049] S2.3, dynamically adjust the window length, according to the trend of the load signal to adjust the window length. Divide the short window into N small part.
[0050] Calculate the rising or falling trend of a short window by linear regression. Calculate N by linear regression small The slope k of the fitting line of the segment datai (i∈1,2,…,N small ). If |k i |>k threshold , it is considered an upward trend; if |k i | <k threshold , it is considered a downward trend. After calculating the multi-segment trend slope of the sliding window, the weighted average slope is used instead of directly using the slope adjustment of a single segment. To reflect the overall trend, the formula is:
[0051]
[0052] Among them, w i is the weight of each piece of data (e.g., set according to location or variance), k i is the slope of each segment. This will make it smoother when adjusting the sliding window. Then, adjust the length of the short window L according to the following formula small :
[0053]
[0054] The window length adjustment takes into account the error and trend changes of the entire window, thereby reducing false positives caused by abnormal single-segment data.
[0055] If the load signal fluctuates, adjust the long window L according to the following formula: large Length:
[0056]
[0057] Where |Δv| represents the difference between the maximum and minimum values of the load data fluctuation.
[0058] When the signal fluctuates greatly (i.e. |Δv| is large), the window L large The length of the long window L will be shortened accordingly to quickly track fluctuations; when the fluctuation is small (that is, |Δv| is small), the long window length L large Increase,adapt to stationary signals, thus reducing false positives and,lowering computational burden.
[0059] Data extraction process based on adaptive double sliding windows Figure 2 .
[0060] In this embodiment, the dual sliding window structure enables the short window to capture rapid load changes, while the long window is used to track the overall trend, which effectively reduces false alarms caused by short-term fluctuations. In addition, the multi-threshold eCDF calculation increases the multi-scale monitoring capability of load changes, thereby further improving the detection accuracy.
[0061] In some feasible embodiments, the step S3 specifically includes:
[0062] The application of the log-linear non-parametric change point detection algorithm (NP-FOCuS) in NILM is mainly used to detect load change points in power signals in real time. The algorithm is based on the log-linear generalized likelihood ratio (GLR) test and is implemented through a non-parametric method. It does not rely on specific distribution assumptions of the data and is particularly suitable for complex power load data without prior distribution.
[0063] S3.1, Assume that the input of one of the windows in step 1 is [y1,y2,…,y L ], assuming θ = F L (p m ),θ∈[0,1],p m ∈{1,2,…,M} at the threshold p m The true distribution function, multiple thresholds p m It can significantly improve the detection accuracy and robustness. Specifically, multiple thresholds can provide a multi-level perspective to analyze the changes in power signals, so that the change point detection algorithm can more accurately capture load change events. For each threshold p m , calculate the empirical cumulative distribution function of the window sample, which is defined as follows:
[0064]
[0065] in is the indicator function, indicating that sample y i If the value is less than or equal to the threshold p, it takes the value 1, otherwise it takes the value 0. The eCDF of the observed value is calculated at each time point t and updated in real time as new data arrives.
[0066] S3.2. For load data without prior distribution, θ is unknown. In this case, the definition of the generalized likelihood ratio test GLR can be expressed as follows:
[0067] g(x n ,θ)=x n logθ+(1-x n )log(1-θ),
[0068] in
[0069] Within this window, the likelihood ratio test statistic for each load data point is expressed as follows:
[0070]
[0071] Among them, θ represents the distribution function of the entire data when there is no change point, t represents the time point; m represents the sequence number of the threshold, and n is the total number of time points. g(x t,θ) represents the generalized likelihood ratio test, τ represents the change point, θ0 and θ1 represent the distribution functions before and after the change point τ, respectively, max(·) represents the likelihood ratio test statistic that maximizes all possible change points τ, θ0 and θ1 represent the distribution functions before and after the change point τ, respectively, max(·) represents the likelihood ratio test statistic that maximizes all possible change points τ.
[0072] S3.3. Since the log-likelihood function is usually a concave function, meaning that its curve is "valley-like" for certain parameter values, in this case the negative sign can be seen as converting the minimization problem into a maximization problem. In this process, the negative sign in the formula is actually only used as an intermediate step to ensure that subsequent recursion and optimization can be performed in the correct form. The negative sign in the recursive formula is removed when constructing the initial test statistic because we want the maximum value, not the minimum value. Therefore, the likelihood ratio test statistic can be rewritten as:
[0073]
[0074] in It means fitting the overall data without change points;
[0075] Indicates that when there is a change point, the sequence is divided into two segments {x1,…,x τ} and {x τ+1 ,…,x n} respectively fit the maximum likelihood of parameters θ0 and θ1.
[0076] S3.4. In order to avoid directly solving the multiple maximization problems about τ, θ0 and θ1, we can use recursion to simplify the calculation. Define a recursive relation:
[0077]
[0078] in, The maximum likelihood ratio test statistic at the nth time point assuming that the load data change point location and parameters are fixed.
[0079] According to the recursive thinking, can be rewritten as:
[0080]
[0081] in n=1,2,...,L.
[0082] S3.5, use pruning technology to reduce computational complexity. When , for each candidate change point τ, the candidate points can be screened by the following rules:
[0083] 1) Whether the contribution of the candidate point in the GLR test is always less than zero:
[0084] If the generalized likelihood ratio increment g(x n ,θ) is always negative in the subsequent accumulation process, that is, the increment of the candidate point has an influence on the statistic. If the contribution of is negative, it can be considered that the candidate point will not make The maximum value is reached. Therefore, it can be pruned directly and the candidate point is no longer considered.
[0085] 2) The statistics of the current candidate point are much smaller than those of other candidate points:
[0086] If the GLR test statistic of a candidate point At the current moment, it is already much smaller than other candidate points. Even if its incremental contribution at subsequent moments is calculated, it is difficult to catch up with other candidate points. In this case, the candidate point can be eliminated to reduce the amount of calculation.
[0087] During the pruning process, the GLR statistics of all candidate points are compared, and at each time point only those with the largest statistics that are likely to be important in future increments are retained. Candidate points with significant contributions.
[0088] S3.6. For each threshold p m The GLR test statistic is summed and the maximum value is obtained, and then compared with the threshold to obtain the change point. The formula is as follows:
[0089]
[0090]
[0091] where η sum and η max It is the threshold set by the Monte Carlo algorithm. When the GLR test statistic satisfies one of the above relationships, the time point n can be determined to be a change point, otherwise n=n+1 and returns to S3.2 and executes again until a change point is found.
[0092] If all data points are traversed, the output is a point without change and the window slides.
[0093] In this embodiment, the pruning technology is used to remove candidate points that contribute less to the generalized likelihood ratio (GLR), thereby reducing unnecessary calculations. At the same time, the recursive calculation method further simplifies the multiple maximization calculations, significantly improving the real-time performance of the algorithm, and making it suitable for NILM scenarios that require real-time response. The non-parametric characteristics of the NP-FOCuS algorithm are utilized, and it does not rely on prior distribution assumptions, so that the present invention can adapt to various complex power load data types. By monitoring load changes through non-invasive methods, the problems of irregular distribution and frequent fluctuations in power signals are solved, and it performs particularly well in multi-change point detection.
[0094] like Figure 3 As shown, a NILM event detection system based on double sliding windows includes:
[0095] A data sorting module is used to obtain high-frequency load data and store it in a circular queue to obtain a data sequence;
[0096] A data extraction module extracts data from the data sequence based on an adaptive double sliding window and outputs a long and short double sliding window sequence;
[0097] The data detection module detects the long and short double sliding window sequences based on a log-linear generalized likelihood ratio test method to obtain a change point detection result.
[0098] The contents of the above method embodiments are all applicable to the present system embodiments. The functions specifically implemented by the present system embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0099] A NILM event detection device based on double sliding windows:
[0100] at least one processor;
[0101] at least one memory for storing at least one program;
[0102] When the at least one program is executed by the at least one processor, the at least one processor implements the NILM event detection method based on double sliding windows as described above.
[0103] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0104] A storage medium stores instructions executable by a processor, wherein the instructions executable by the processor are used to implement the above-mentioned NILM event detection method based on double sliding windows when executed by the processor.
[0105] The contents of the above method embodiments are all applicable to the present storage medium embodiments. The functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0106] The above is a specific description of the preferred implementation of the present invention, but the invention is not limited to the embodiments. Those skilled in the art may make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of this application.
Claims
1. A NILM event detection method based on double sliding windows, characterized in that: The following steps are involved: Obtain high-frequency load data and store it in a circular queue to obtain a data sequence; Extracting data from the data sequence based on an adaptive double sliding window, and outputting a long and short double sliding window sequence; Based on the log-linear generalized likelihood ratio test method, the long-short double sliding window sequence is tested to obtain a change point detection result.
2. The NILM event detection method based on double sliding windows according to claim 1, characterized in that: Also includes: The missing values, abnormal values and noise in the high-frequency load data are processed to obtain preprocessed high-frequency load data.
3. The NILM event detection method based on double sliding windows according to claim 2, characterized in that: The step of extracting data from the data sequence based on the adaptive double sliding window and outputting a long and short double sliding window sequence specifically includes: Set the first window and the second window; Calculating fitting errors for the data in the first window and the second window respectively; The lengths of the first window and the second window are adjusted according to the trend change of the load signal, and a long and short double sliding window sequence is output.
4. The NILM event detection method based on double sliding windows according to claim 3 is characterized in that: The length adjustment formula of the first window is expressed as follows: Among them, L small Indicates the length of the first window, e small represents the fitting error in the first window, N small Indicates the number of segments divided by the first window, w i represents the weight of the i-th segment of data, k i Represents the slope of the i-th segment of data.
5. The NILM event detection method based on double sliding windows according to claim 3 is characterized in that: The length adjustment formula of the second window is as follows: Among them, |Δv| represents the difference between the maximum and minimum values of load data fluctuation, e large represents the fitting error within the second window.
6. The NILM event detection method based on double sliding windows according to claim 1, characterized in that: The log-linear generalized likelihood ratio test method is used to detect the long-short double sliding window sequence to obtain a change point detection result, which specifically includes: Based on the long and short double sliding window sequence, multiple thresholds are set and the window sample empirical cumulative distribution function is calculated; Performing a generalized likelihood ratio test on each load data point in the long-short double sliding window sequence to obtain a generalized likelihood ratio test statistic; Based on a recursive method, the generalized likelihood ratio test statistic is simplified; The generalized likelihood ratio test statistic of each threshold is summed and solved with the maximum value, and compared with the decision threshold, and the change point detection result is output.
7. The NILM event detection method based on double sliding windows according to claim 6, characterized in that: The calculation formula of the likelihood ratio test statistic is as follows: Among them, θ represents the distribution function of the entire data when there is no change point, t represents the time point, m represents the sequence number of the threshold, n is the total number of time points, g(x t ,θ) represents the generalized likelihood ratio test, τ represents the change point, θ0 and θ1 represent the distribution functions before and after the change point τ, respectively, and max(·) represents the likelihood ratio test statistic that maximizes all possible change points τ.
8. The NILM event detection method based on double sliding windows according to claim 6, characterized in that: Also includes: In the process of recursively calculating the likelihood ratio test statistic, the pruning method is used to screen the candidate change points.
9. A NILM event detection system based on double sliding windows, characterized in that: include: A data sorting module is used to obtain high-frequency load data and store it in a circular queue to obtain a data sequence; A data extraction module extracts data from the data sequence based on an adaptive double sliding window and outputs a long and short double sliding window sequence; The data detection module detects the long and short double sliding window sequences based on a log-linear generalized likelihood ratio test method to obtain a change point detection result.
10. A NILM event detection device based on double sliding windows, characterized in that: include: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the NILM event detection method based on double sliding windows as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Event-based two-stage non-invasive load monitoring method
CN111830347A
CUSUM-Bi-LSTM-based edge side online non-intrusive load identification method
CN115186258A
NILM event detection method based on sliding window fusion MK test and iterative fitting
CN117609760A
Cited By
A real-time signal detection method, apparatus, device and medium
CN122571150A
A real-time signal detection method, device, equipment and medium
CN122571150B