A NILM Event Detection Method and System Based on Dual Sliding Windows
Through adaptive window length adjustment and logarithmic linear generalized likelihood ratio test based on dual sliding windows, combined with pruning technology, the problem of high false alarm rate in the existing NILM method is solved, and high-precision and real-time load monitoring is achieved.
Patent Information
- Application Number
- CN202411779166.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2044-12-05
AI Technical Summary
The existing NILM event detection methods rely on manually set mode templates and cannot flexibly adapt to data changes, resulting in high false positive rates, especially in complex event detection.
The method based on dual-sliding window is adopted, combined with adaptive window length adjustment and logarithmic generalized likelihood ratio testing, high-frequency load data is extracted through adaptive dual-sliding windows, and the pruning technology and multi-threshold empirical cumulative distribution function are detected to output the change point.
It improves the accuracy and robustness of event detection, reduces the false alarm rate, adapts to complex load data, and meets the needs of real-time and high-precision.
Smart Images

Figure CN119720020B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of non-intrusive load monitoring, and particularly to a NILM event detection method and system based on dual 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 the saving of resources. The main task of event detection is to accurately detect the start time and end time of an event from data such as total power in real time, laying a foundation for subsequent feature extraction and identification of loads.
[0003] Currently, most existing event detection methods are pattern matching-based methods. The pattern matching method detects whether an event occurs by matching the sequence segment corresponding to the event transient process with the established feature library. The pattern matching method performs well in the detection of certain specific types of events. However, in the face of complex events, its accuracy and interpretability cannot meet the requirements. This method usually requires developers to manually set decision rules and select appropriate conditions to adapt to the data characteristics. Therefore, the accuracy of the model depends to a large extent on the professional knowledge level and experience of developers. With the continuous expansion of data scale and the increase in complexity, the preset patterns may be difficult to meet the needs of new data. Over-reliance on manually set rules and conditions makes the model too rigid 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 existing NILM event detection methods rely on manually preset templates, and thus cannot adapt to data changes, resulting in a high false alarm rate, the present invention proposes a NILM event detection method based on dual sliding windows. The method includes the following steps:
[0005] Obtain high-frequency load data and store the high-frequency load data in the form of a circular queue to obtain a data sequence;
[0006] Form dual sliding windows in the queue, and perform data extraction on the data sequence based on the adaptive dual sliding windows to output long and short dual sliding window sequences;
[0007] For the long and short dual sliding window sequences, use the logarithmic-linear generalized likelihood ratio test method for detection to output change points.
[0008] In some embodiments, it is necessary to preprocess the original high-frequency load data to ensure data quality and applicability. It further includes:
[0009] Clean the original high-frequency load data, process missing values, outliers and noise, and then perform normalization processing to scale the data to a 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] Initialize a double sliding window, defining the initial length of the first window and the initial length of the second window;
[0012] Calculate the fitting error of the data within the first window and the second window;
[0013] Dynamically adjust the lengths of the first window and the second window 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 detecting the long and short double sliding window sequence by using the logarithmic linear generalized likelihood ratio test method and outputting a change point specifically includes:
[0016] Set multiple thresholds;
[0017] Calculate the generalized likelihood ratio test statistic for each load data point within different windows;
[0018] Use recursive simplification to rewrite the calculation formula of the generalized likelihood ratio test statistic according to the recursive idea;
[0019] Solve the sum and maximum value of the generalized likelihood ratio test statistic for each threshold, and compare 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 by using the logarithmic linear generalized likelihood ratio test method and outputting a change point further includes:
[0021] Use pruning technology to reduce the calculation complexity, and screen each change point candidate during the recursive calculation process.
[0022] The present invention also proposes a NILM event detection system based on a double sliding window, and the system includes:
[0023] A data sorting module for obtaining high-frequency load data and storing the high-frequency load data in a circular queue form to obtain a data sequence;
[0024] A data extraction module that 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 performs detection on the long and short double sliding window sequences by using the logarithmic linear generalized likelihood ratio test method and outputs change points.
[0026] Based on the above solution, the present invention provides a NILM event detection method and system based on a double sliding window. By combining a double sliding window structure with pruning technology and a logarithmic linear nonparametric algorithm, the change point detection accuracy of non-intrusive load monitoring is improved. Among them, the short window is used to quickly respond to the instantaneous change of the load, while the long window captures the overall trend, making the detection take into account both sensitivity and stability. In addition, the pruning technology reduces the computational amount by eliminating insignificant candidate points and realizes real-time detection. Using the empirical cumulative distribution function under multiple thresholds improves the detection accuracy and robustness, making the present invention particularly suitable for complex load data without a 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 performance and high accuracy in practical applications. Brief Description of the Drawings
[0027] Figure 1 is a flowchart of the steps of a NILM event detection method based on a double sliding window according to the present invention;
[0028] Figure 2 is a schematic flowchart of data extraction based on an adaptive double sliding window in a specific embodiment of the present invention;
[0029] Figure 3 is a block diagram of the structure of a NILM event detection system based on a double sliding window according to the present invention. Detailed Embodiments
[0030] The double sliding windows in the prior art are usually fixed windows or windows with the same length. Event detection using fixed windows is easily interfered by noise. Especially in high-frequency data streams, short-term fluctuations may be misinterpreted as load changes. Secondly, the fixed window size cannot flexibly adapt to changes in different time scales. When the load change is 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), and in actual load data, these assumptions often do not hold, resulting in an increase in false alarm rate and missed alarm rate.
[0031] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0032] It should be noted that for ease of description, only parts related to the relevant invention are shown in the drawings. Without conflict, the embodiments in the present application and the features in the embodiments can be combined with each other.
[0033] It should be understood that the "system", "device", "unit" and / or "module" used in the present application is a way to distinguish different components, elements, parts, portions or assemblies at different levels. However, if other words can achieve the same purpose, this word can be replaced by other expressions.
[0034] As shown in the present application and the claims, unless the context clearly indicates an exception, words such as "a", "an", "one" and / or "the" are not specifically singular and may also include the plural. Generally speaking, the terms "comprising" and "including" only indicate the inclusion of the 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. An element defined by the statement "comprising one..." does not exclude the existence of another identical element in the process, method, commodity or device including the element.
[0035] In the description of the embodiments of the present application, "a plurality" means two or more than two. The following terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features.
[0036] In addition, flowcharts 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 previous or subsequent operations do not necessarily need to be executed precisely in sequence. On the contrary, the steps can be processed in reverse order or simultaneously. At the same time, other operations can also be added to these processes, or one or several steps can be removed from these processes.
[0037] Referring to Figure 1 , which is a schematic flowchart of an optional example of the NILM event detection method based on dual sliding windows proposed by the present invention. This method 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: Obtain high-frequency load data and store it in the form of a circular queue to obtain a data sequence;
[0039] Step S2: Extract data from the data sequence based on an adaptive dual sliding window and output a long and short dual 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 regarded as an upward trend; if |k i | < k threshold , it is regarded as a downward trend. After calculating the multi-segment trend slopes of the sliding window, instead of directly using the slope adjustment of a single segment, the weighted average slope is used to reflect the overall trend. The formula is:
[0051]
[0052] where w i is the weight of each segment of data (set according to position or variance), and k i is the slope of each segment. This makes the adjustment of the sliding window smoother. Then, the length L small of the short window is adjusted according to the following formula:
[0053]
[0054] The window length adjustment takes into account the error and trend changes of the entire window, thereby reducing false alarms caused by abnormal single-segment data.
[0055] For the case where the load signal fluctuates or undulates, the length of the long window L large is adjusted according to the following formula:
[0056]
[0057] where |Δv| represents the difference between the maximum and minimum values of the load data fluctuation.
[0058] When the signal has large fluctuations (i.e., |Δv| is large), the length of the window L large will be correspondingly shortened to quickly track the fluctuation changes; when the fluctuations are small (i.e., |Δv| is small), the length of the long window L large increases to adapt to the stable signal, thereby reducing false alarms and reducing the computational burden.
[0059] The data extraction process based on the adaptive double sliding window refers to Figure 2 .
[0060] In this embodiment, the double 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 ability of load changes, thereby further improving the detection accuracy.
[0061] In some feasible embodiments, step S3 specifically includes:
[0062] The application of the log-linear non-parametric change-point detection algorithm (NP-FOCuS) in NILM is mainly used for real-time detection of load change points in power signals. This algorithm is based on the log-linear generalized likelihood ratio (GLR) test and is implemented by non-parametric methods. It does not depend 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 , assume θ = F L (p m ), θ ∈ [0, 1], p m ∈ {1, 2, …, M} is the true distribution function at the threshold p m . Multiple thresholds p m can significantly improve the detection accuracy and robustness. Specifically, multiple thresholds can provide multi-level perspectives to analyze the changes in power signals, enabling the change-point detection algorithm to more accurately capture load change events. For each threshold p m , calculate the empirical cumulative distribution function of the window samples, defined as follows:
[0064]
[0065] where is the indicator function, indicating that the sample y i is less than or equal to the threshold p and takes the value 1, otherwise 0. Calculate the eCDF of the observed values at each time point t and update it 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] where
[0069] Within this window, the likelihood ratio test statistic for each load data point is expressed as follows:
[0070]
[0071] where θ represents the overall distribution function of the data when there is no change point, t represents the time point; m represents the serial number of the threshold, and n takes 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 change point candidate 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 , θ) of a certain candidate point τ is always negative during the subsequent accumulation process, that is, the increment of this candidate point contributes negatively to the statistic , then it can be considered that this candidate point will not make reach the maximum value. Therefore, this candidate point can be directly pruned and no longer considered.
[0085] 2) The statistic of the current candidate point is much smaller than that of other candidate points:
[0086] If the GLR test statistic of a certain candidate point is much smaller than that of other candidate points at the current moment, and it is difficult to catch up with other candidate points even if the incremental contribution in the subsequent moment is calculated, then this candidate point can be eliminated, thereby reducing the calculation amount.
[0087] During the pruning process, compare the GLR statistics of all candidate points, and only retain those candidate points with the largest statistics and may make significant contributions to in the future increments at each time point.
[0088] S3.6. For each threshold p m calculate the sum and maximum value of the GLR test statistic, and then compare with the threshold to obtain the change point. The formula is as follows:
[0089]
[0090]
[0091] where η sum and η max are thresholds set by the Monte Carlo algorithm. When the GLR test statistic satisfies one of the above relationships, it can be determined that the time point n is the change point; otherwise, n = n + 1 and return to S3.2 to execute again until the change point is found.
[0092] If all data points are traversed, output no change point and slide the window.
[0093] In this embodiment, based on pruning technology, by removing candidate points that contribute less to the Generalized Likelihood Ratio (GLR), unnecessary computational complexity is reduced. Meanwhile, the recursive calculation method further simplifies the multiple maximization calculation, significantly improving the real-time performance of the algorithm and making it suitable for NILM scenarios that require real-time response. Utilizing the non-parametric characteristics of the NP-FOCuS algorithm and not relying on prior distribution assumptions enables the present invention to adapt to various complex types of electric load data. By monitoring load changes through non-intrusive methods, the problems of irregular distribution and frequent fluctuations in electrical signals are solved, and it performs particularly well in change point detection.
[0094] As Figure 3 shown, a NILM event detection system based on a dual sliding window includes:
[0095] A data sorting module, configured to obtain high-frequency load data and store it in the form of a circular queue to obtain a data sequence;
[0096] A data extraction module, which extracts data from the data sequence based on an adaptive dual sliding window and outputs a long and short dual sliding window sequence;
[0097] A data detection module, which detects the long and short dual sliding window sequence based on the log-linear generalized likelihood ratio test method to obtain a change point detection result.
[0098] The content in the above method embodiments is applicable to the system embodiments of the present system. The functions specifically implemented in the system embodiments of the present system are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those in the above method embodiments.
[0099] A NILM event detection device based on a dual sliding window:
[0100] At least one processor;
[0101] At least one memory, configured to store 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 a NILM event detection method based on a dual sliding window as described above.
[0103] The content in the above method embodiments is applicable to the device embodiments of the present device. The functions specifically implemented in the device embodiments of the present device are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those in the above method embodiments.
[0104] A storage medium, in which instructions executable by a processor are stored, and the instructions executable by the processor are used to implement a NILM event detection method based on a dual sliding window as described above when executed by the processor.
[0105] The content in the method embodiments described above is applicable to the storage medium embodiments. The functions specifically implemented in the storage medium embodiments are the same as those in the method embodiments, and the beneficial effects achieved are also the same as those in the method embodiments.
[0106] The above is a specific description of the preferred embodiments of the present invention. However, the present invention is not limited to the described embodiments. Those skilled in the art can make various equivalent deformations or substitutions without departing from the spirit of the present invention, and these equivalent deformations or substitutions are all included within the scope defined by the claims of this application.
Claims
1. A NILM event detection method based on a double sliding window, characterized in that It includes the following steps: Obtain high-frequency load data and store it in the form of a circular queue to obtain a data sequence; Extract data from the data sequence based on an adaptive double sliding window and output a long and short double sliding window sequence; Detect the long and short double sliding window sequence based on the logarithmic-linear generalized likelihood ratio test method to obtain a change point detection result; The step of extracting data from the data sequence based on an adaptive double sliding window and outputting a long and short double sliding window sequence specifically includes: Set a first window and a second window; Calculate the fitting errors for the data within the first window and the second window respectively; Adjust the lengths of the first window and the second window according to the trend change of the load signal and output a long and short double sliding window sequence; The length adjustment formula of the first window is expressed as follows: Among them, L small represents the length of the first window, e small represents the fitting error within the first window, N small represents the number of segments into which the first window is divided, w i represents the weight of the i-th segment of data, k i represents the slope of the i-th segment of data; The length adjustment formula of the second window is expressed as follows: where |Δv| represents the difference between the maximum and minimum values of the load data fluctuation, and e large represents the fitting error within the second window; The step of detecting the long and short double sliding window sequence based on the logarithmic-linear generalized likelihood ratio test method to obtain a change point detection result specifically includes: Based on the long and short double sliding window sequence, set multiple thresholds and calculate the empirical cumulative distribution function of the window samples; Perform a generalized likelihood ratio test on each load data point in the long and short double sliding window sequence to obtain a generalized likelihood ratio test statistic; Simplify the generalized likelihood ratio test statistic based on a recursive method; Solve the sum and maximum value of the generalized likelihood ratio test statistic for each threshold and compare it with a decision threshold to output a change point detection result.
2. The method for NILM event detection based on a double sliding window according to claim 1, wherein It also includes: Process the missing values, outliers and noises in the high-frequency load data to obtain preprocessed high-frequency load data.
3. The method for NILM event detection based on a double sliding window according to claim 2, characterized in that, The calculation formula of the likelihood ratio test statistic is as follows: Among them, θ represents the distribution function of the overall data when there is no change point, t represents the time point, m represents the serial number of the threshold, n takes the total number of time points, and g(x t , θ) represents the generalized likelihood ratio test, τ represents the change point, θ0 and θ1 respectively represent the distribution functions before and after the change point τ, and max(·) represents maximizing the likelihood ratio test statistic for all possible change points τ.
4. The method for NILM event detection based on a double sliding window according to claim 3, wherein It also includes: During the recursive calculation of the likelihood ratio test statistic, use a pruning method to screen the change point candidate points.
5. A NILM event detection system based on a double sliding window, characterized in that, Used to execute a NILM event detection method based on a double sliding window as described in claim 1, including: A data arrangement module for obtaining high-frequency load data and storing it in the form of a circular queue to obtain a data sequence; A data extraction module for extracting data from the data sequence based on an adaptive double sliding window and outputting a long and short double sliding window sequence; A data detection module for detecting the long and short double sliding window sequence based on the logarithmic-linear generalized likelihood ratio test method to obtain a change point detection result.
6. A NILM event detection device based on a double sliding window, characterized in that, It includes: 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 a NILM event detection method based on a double sliding window as described in any one of claims 1-4.
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