A non-invasive load identification method based on KNN combined with logistic regression

By combining the non-intrusive load identification method of KNN and logistic regression, and optimizing the classification model through data smoothing and feature extraction, the problem of poor accuracy and efficiency compatibility in existing technologies is solved, achieving high accuracy and high efficiency load identification.

CN114943298BActive Publication Date: 2025-10-28HOHAI UNIV
View PDF 1 Cites -1 Cited by

Patent Information

Application Number
CN202210620603.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-02
Publication Date
2025-10-28
Estimated Expiration
2042-06-02

AI Technical Summary

Technical Problem

Existing non-invasive load identification algorithms struggle to balance high accuracy and efficiency when dealing with noise and large sample sizes. KNN, logistic regression, and SVM algorithms suffer from low accuracy or low efficiency in load identification.

Method used

By combining the KNN algorithm with logistic regression, steady-state features are extracted through data smoothing and bilateral cumulative summation to locate the tangent point. After KNN is used to select nearest neighbors, logistic regression is used for classification. Euclidean distance and log-likelihood function are used to optimize the classification model.

Benefits of technology

It improves the accuracy and efficiency of load identification, solves the problem of the incompatibility between high accuracy and high efficiency, and enhances the effect of non-invasive load identification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114943298B_ABST
    Figure CN114943298B_ABST
Patent Text Reader

Abstract

This invention discloses a non-intrusive load identification method based on KNN combined with logistic regression, comprising: collecting load data of electrical appliances in a non-intrusive manner as the original load dataset; performing data smoothing on the load data; locating the load switching point using bilateral cumulative sum, extracting steady-state features of the load data, and constructing a feature library; calculating the two nearest neighbors of the test sample using the KNN algorithm, and extracting the corresponding data from the feature library as a secondary feature library; and using the logistic regression algorithm to make the final identification of the two nearest neighbors based on the secondary feature library, outputting the category of the test sample. This invention utilizes a recognition algorithm combining the KNN algorithm and logistic regression, improving the accuracy of load identification while simultaneously increasing the computational efficiency of the algorithm, solving the problem of the incompatibility between high accuracy and high efficiency in recognition algorithms, and effectively improving the non-intrusive load identification effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of smart grids and relates to non-intrusive load identification technology, specifically a non-intrusive load identification method based on KNN combined with logistic regression. Background Technology

[0002] Non-intrusive load identification has become an important research direction in smart grid construction due to its ease of installation, convenient maintenance, and high economic efficiency. Non-intrusive load identification plays a crucial role in understanding residents' electricity consumption habits, analyzing their electricity consumption behavior, proposing reasonable electricity consumption strategies, and guiding residents to conserve electricity.

[0003] Data processing and load identification are key steps in non-intrusive load identification methods. Currently, most algorithms do not consider the impact of noise and other factors on load data during data processing; and in load identification, current algorithms struggle to achieve a balance between high accuracy and high efficiency, such as KNN, logistic regression, and SVM algorithms commonly used for classification problems. When used for load identification, the KNN algorithm offers fast model training and a simple, straightforward approach with high efficiency. However, due to its limitation of relying on the majority rule in voting, its accuracy in identifying similar loads is not high. Logistic regression is commonly used for binary classification problems with good results. When applied to multi-class problems, it uses the binary classification principle, treating one class as positive and the others as negative, building a classification model based on the number of classes. This approach is efficient but prone to data imbalance, ultimately leading to low accuracy. The SVM algorithm is efficient and accurate when handling multi-class problems with small sample sizes. However, because it requires training multiple classifiers, each with all samples as input, its efficiency drops significantly with large sample sizes. Furthermore, it is prone to misclassification when dealing with similar features.

[0004] Therefore, a new technological solution is needed to address these issues. Summary of the Invention

[0005] Purpose of the invention: In order to overcome the shortcomings of the existing technology, a non-intrusive load identification method based on KNN combined with logistic regression is provided, which solves the problem of the influence of noise and other adverse factors on load data. In the load identification stage, by combining the KNN algorithm with logistic regression, the problem of the incompatibility between high accuracy and high efficiency of the identification algorithm is solved, and the non-intrusive load identification effect is effectively improved.

[0006] Technical Solution: To achieve the above objectives, this invention provides a non-invasive load identification method based on KNN combined with logistic regression, comprising the following steps:

[0007] S1: The load data of electrical appliances is collected in a non-intrusive manner as the raw load dataset;

[0008] S2: Perform data smoothing on the load data;

[0009] S3: Utilize bilateral cumulative sums to locate load switching points, extract steady-state characteristics of load data, and construct a feature library;

[0010] S4: The KNN algorithm is used to calculate and obtain the two nearest neighbors of the test sample, and the corresponding data is extracted from the feature library as a secondary feature library.

[0011] S5: Using the logistic regression algorithm, based on the secondary feature library, the first two nearest neighbors are finally identified, and the category of the test sample is output.

[0012] Further, the data smoothing process in step S2 includes: taking N (N>=5) consecutive data points in the load data as a segment, calculating the mean of each segment, determining a threshold H based on the difference in mean between adjacent data segments, calculating the difference in mean between adjacent data segments, and replacing data segments with a value greater than the threshold H with the mean of the preceding and following 2N data points; data segments with a value less than the threshold H are retained.

[0013] Furthermore, the specific steps of the data smoothing process in step S2 are as follows:

[0014] A1: Take steady-state current data from M consecutive points (M is 30 in this paper) of the load data, and divide the N data points into a small segment. Calculate the average value of each small segment.

[0015] A2: Based on the average value The formula for calculating the data deviation from the threshold H is as follows:

[0016]

[0017] A3: For the original load current data, repeat step S1 to determine the difference between the mean of the current data segment and the mean of the adjacent data segment. If it is less than H, retain it; if it is greater than H, perform the following processing:

[0018]

[0019] Further, step S3 specifically includes:

[0020] By using bilateral cumulative calculations and location-based load switching points, the standard deviation X of continuous data points is continuously accumulated. n When the cumulative standard deviation exceeds the set threshold e, it is determined that a switching event has occurred (A=1).

[0021]

[0022] Among them, S n This represents the sum of the cumulative standard deviations of the current data points;

[0023] Based on the location of the switching event, extract the stable data segments before and after, and extract steady-state features such as steady-state current, third harmonic, active power, and 2nd-10th harmonic distortion rate. These features are then matched one-to-one with the electrical appliance tags and stored in the first steady-state feature library.

[0024] Furthermore, the method for constructing the secondary feature library in step S4 is as follows:

[0025] B1: Calculate the Euclidean distance from the test sample to all data in the first steady-state feature library. The calculation formula is as follows:

[0026]

[0027] Where, x tj As a test sample, X t For its set; x ij For data in a feature library, j is the dimension, j=6, X i For its set; d(X) t ,X i ) is x tj Compared with data x in a feature library ij The set of distances between them;

[0028] B2: For the distance set d(X) obtained in step B1 t ,X i The data in the sample are combined in descending order, and the first two data points are taken as the nearest neighbors of the test sample.

[0029] B3: Based on the first two nearest neighbors of the test sample, extract all data and labels corresponding to the nearest neighbors from the primary feature library to construct the secondary feature library.

[0030] Furthermore, step S5 specifically includes the following process:

[0031] C1: Sets the initial values ​​for the iterative learning rate α and the number of iterations c;

[0032] C2: According to the sigmoid function formula f(y)=1 / (1+e y This yields the logistic regression classification model:

[0033]

[0034] Among them, ωx=ω0+ω1x1+…ω i x i And x1, x2, ... x i These are the load features in the quadratic feature library, ω0, ω1, ... ωi These are the regression parameters of the classification model;

[0035] C3: Solve for the regression parameters ω0, ω1, ... ω of the model. i ;

[0036] C4: Update regression parameters ω j The formula is

[0037] C5: If the number of iterations is less than the initial value c, repeat step C4; use the final sigmoid formula to calculate the classification probability P1 = g(ω). T x),P2=1-g(ω T x), which determines the category of the test sample based on the classification probability.

[0038] Furthermore, in step C3, the regression parameters ω0, ω1, ... ω i The solution process is as follows:

[0039] Determine the log-likelihood function:

[0040]

[0041] Solve for the regression parameters using the log-likelihood function:

[0042]

[0043] in, Because the KNN algorithm only takes the first two nearest neighbors of each test sample, m = 2.

[0044] This invention employs a combined KNN algorithm and logistic regression for load identification. After selecting the two nearest neighbors (classes with a higher risk of misclassification) in the KNN distance measurement stage, logistic regression is used for further discrimination. The log-likelihood function replaces the majority-subjects voting principle of KNN to calculate the class probability of similar load features. Furthermore, the sample data is smoothed, effectively addressing the problem of data overfitting and ensuring high accuracy in load identification. The KNN algorithm is only used for nearest neighbor selection, and the logistic regression algorithm is only used to classify the first two nearest neighbors (binary classification). The input to the training model is only a portion of the corresponding nearest neighbor samples in the overall feature library, thus resulting in high algorithm efficiency. Overall, this invention solves the problem of the incompatibility between high accuracy and high efficiency in identification algorithms.

[0045] Beneficial effects: Compared with existing technologies, this invention firstly addresses the impact of noise on load data through smoothing processing in the data processing stage, ensuring data reliability and optimizing the input of the identification algorithm; secondly, in the load identification stage, it selects the two nearest neighbors using the nearest neighbor matching principle of the KNN algorithm as the input of the logistic regression algorithm, improving the distinguishability between similar load data; finally, the identification algorithm combining the KNN algorithm and logistic regression improves the accuracy of load identification while simultaneously enhancing the algorithm's computational efficiency, solving the problem of the incompatibility between high accuracy and high efficiency in identification algorithms, and effectively improving the identification effect of non-intrusive loads. Attached Figure Description

[0046] Figure 1 This is an overall flowchart of the method of the present invention;

[0047] Figure 2 This is a flowchart of the data smoothing process in the method of the present invention;

[0048] Figure 3 Macro-F1 score plots for load identification of the two algorithms. Detailed Implementation

[0049] The present invention will be further illustrated below with reference to the accompanying drawings and specific embodiments. It should be understood that these embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. After reading this invention, any modifications of the invention in various equivalent forms by those skilled in the art will fall within the scope defined by the appended claims.

[0050] This invention provides a non-invasive load identification method based on KNN combined with logistic regression, such as... Figure 1 As shown, it includes the following steps:

[0051] S1: Collect raw load data such as current, voltage, phase, and harmonics of electrical appliances in a non-invasive manner to form the raw load dataset;

[0052] S2: Perform data smoothing on the collected raw load data to remove the impact of noise and other adverse factors on the data;

[0053] like Figure 2 As shown, the specific steps of data smoothing processing in this embodiment are as follows:

[0054] A1: Take steady-state current data from 30 consecutive points of load data, divide the data into segments of 5, and calculate the average value of each segment.

[0055] A2: Based on the average value The formula for calculating the data deviation from the threshold H is as follows:

[0056]

[0057] A3: For the original load current data, repeat step S1 to determine the difference between the mean of the current data segment and the mean of the adjacent data segment. If it is less than H, retain it; if it is greater than H, perform the following processing:

[0058]

[0059] S3: Perform bilateral accumulation and locate the load switching points on the data processed in step S2, and continuously accumulate the standard deviation X of continuous data points. n When the cumulative standard deviation exceeds the set threshold e, it is determined that a switching event has occurred (A=1).

[0060]

[0061] Among them, S n This represents the cumulative sum of standard deviations for the current data points;

[0062] Based on the location of the switching event, stable data segments before and after are extracted, and steady-state features such as steady-state current, third harmonic, active power, and 2nd-10th harmonic distortion rate are extracted and matched one by one with the appliance tags. Based on the preliminary screening, this embodiment selects single loads or load combinations such as lithium battery, air conditioner, refrigerator, rice cooker, air conditioner + lithium battery, refrigerator + air conditioner, and air conditioner + refrigerator + lithium battery as the primary feature library. Among them, air conditioner + lithium battery and refrigerator + air conditioner, rice cooker and air conditioner + refrigerator + lithium battery are similar loads.

[0063] S4: Collect load type data from step S3, via... Figure 1 The data processing flow was used as a test sample.

[0064] S5: The KNN algorithm is used to calculate and obtain the two nearest neighbors of the test sample, and the corresponding data is extracted from the feature library as a secondary feature library.

[0065] The specific method for constructing the secondary feature library is as follows:

[0066] B1: Calculate the Euclidean distance from the test sample to all data in the first steady-state feature library. The calculation formula is as follows:

[0067]

[0068] Where, x tj As a test sample, X t For its set; x ij For data in a feature library, j is the dimension, j=6, X i For its set; d(X) t ,X i ) is x tjCompared with data x in a feature library ij The set of distances between them;

[0069] B2: For the distance set d(X) obtained in step B1 t ,X i The data in the sample are combined in descending order, and the first two data points are taken as the nearest neighbors of the test sample. In this embodiment, the nearest neighbors of the test sample are k1 and k2.

[0070] B3: Based on the first two nearest neighbors k1 and k2 of the test sample, extract all data and labels corresponding to the nearest neighbors from the primary feature library to construct the secondary feature library.

[0071] S5: Using the logistic regression algorithm, based on the secondary feature library, the first two nearest neighbors are identified, and the category of the test sample is output. The specific process includes the following:

[0072] C1: Initialize the iterative learning rate α = 0.001, and the number of iterations c = 300;

[0073] C2: According to the sigmoid function formula f(y)=1 / (1+e y This yields the logistic regression classification model:

[0074]

[0075] Among them, ωx=ω0+ω1x1+…ω i x i And x1, x2, ... x i These are the load features in the quadratic feature library, ω0, ω1, ... ω i These are the regression parameters of the classification model;

[0076] C3: Solve for the regression parameters ω0, ω1, ... ω of the model. i The solution process is as follows:

[0077] Determine the log-likelihood function:

[0078]

[0079] Solve for the regression parameters using the log-likelihood function:

[0080]

[0081] in, Because the KNN algorithm only takes the first two nearest neighbors of each test sample, m = 2

[0082] C4: Update regression parameters ω j The formula is

[0083] C5: Determine if the number of iterations has reached the initial value c = 300. If not, continue the above steps to update the regression parameters. If the number of iterations has reached 300, input the final regression parameters into the classification model.

[0084] The classification probability P1 = g(ω) is calculated using the final sigmoid formula. T x),P2=1-g(ω T If the probability of x) is greater than 0.5, it is classified as that class and used as the final identification result.

[0085] The specific accuracy results of the identification in this embodiment are shown in Table 1 below.

[0086] Table 1: Recognition Results

[0087] Load type KNN (k=5) LG KNN+LG (k=5) lithium batteries 100% 90% 100% air conditioner 100% 100% 100% refrigerator 100% 100% 100% rice cooker 70% 0% 80% Air conditioner + lithium battery 100% 100% 100% Refrigerator + Air Conditioner 37.1% 0% 85.7% Air conditioner + refrigerator + lithium battery 100% 100% 100%

[0088] As shown in Table 1, the method of the present invention has a high accuracy rate in identifying similar loads (rice cooker, refrigerator + air conditioner) and also has a high accuracy rate in identifying other types of loads. It solves the problem of difficulty in identifying similar loads and improves the accuracy of load identification.

[0089] To further verify the effectiveness of the method of this invention, a sufficient amount of sample data was collected to compare the performance of four algorithms in load identification: SVM, Logistic Regression (LG), KNN algorithm, and KNN algorithm combined with Logistic Regression (KNN-LG). Accuracy, precision, and F1 score were used as evaluation indicators. The results are shown in Table 2, where the k value for KNN and KNN-LG is 5. The Macro-F1 scores of KNN and KNN-LG under different k values ​​are compared as follows: Figure 3 As shown in the figure. The comprehensive experimental results indicate that the KNN-LG algorithm outperforms other algorithms and achieves better recognition results.

[0090] Table 2: Performance Comparison of Four Algorithms

[0091] Evaluation indicators SVM LG KNN KNN-LG accuracy 71.2% 75% 92.9% 95.3% accuracy 53.6% 58.9% 94.2% 95.4% F1 score 0.603 0.652 0.923 0.952

Claims

1. A non-intrusive load identification method based on KNN combined with logistic regression, characterized in that, Includes the following steps: S1: The load data of electrical appliances is collected in a non-intrusive manner as the raw load dataset; S2: Perform data smoothing on the load data; S3: Utilize bilateral cumulative sums to locate load switching points, extract steady-state characteristics of load data, and construct a feature library; S4: The KNN algorithm is used to calculate and obtain the two nearest neighbors of the test sample, and the corresponding data is extracted from the feature library as a secondary feature library. S5: Using the logistic regression algorithm, based on the secondary feature library, the first two nearest neighbors are finally identified, and the category of the test sample is output. The specific method for constructing the secondary feature library in step S4 is as follows: B1: Calculate the Euclidean distance from the test sample to all data in the first steady-state feature library. The calculation formula is as follows: Where, x tj As a test sample, X t For its set; x ij Let j be the dimension of the data in the feature library, and X be the dimension of the data. i For its set; d(X) t ,X i ) is x tj Compared with data x in a feature library ij The set of distances between them; B2: For the distance set d(X) obtained in step B1 t ,X i The data in the sample are combined in descending order, and the first two data points are taken as the nearest neighbors of the test sample. B3: Based on the first two nearest neighbors of the test sample, extract all data and labels corresponding to the nearest neighbors from the primary feature library to construct the secondary feature library; Step S5 specifically includes the following process: C1: Sets the initial values ​​for the iterative learning rate α and the number of iterations c; C2: According to the sigmoid function formula f(y)=1 / (1+e y This yields the logistic regression classification model: Among them, ωx=ω0+ω1x1+…ω i x i And x1, x2, ... x i These are the load features in the quadratic feature library, ω0, ω1, ... ω i These are the regression parameters of the classification model; C3: Solve for the regression parameters ω0, ω1, ... ω of the model. i ; C4: Update regression parameters ω j The formula is C5: If the number of iterations is less than the initial value c, repeat step C4; use the final sigmoid formula to calculate the classification probability P1 = g(ω). T x),P2=1-g(ω T x), and determine the category of the test sample based on the classification probability; In step C3, the regression parameters ω0, ω1, ... ω i The solution process is as follows: Determine the log-likelihood function: Solve for the regression parameters using the log-likelihood function: in, Because the KNN algorithm only takes the first two nearest neighbors of each test sample, m = 2.

2. The non-intrusive load identification method based on KNN combined with logistic regression according to claim 1, characterized in that, The data smoothing process in step S2 includes: taking N consecutive data points in the load data as a segment, calculating the mean of each segment, determining a threshold H based on the difference in mean between adjacent data segments, calculating the difference in mean between adjacent data segments, replacing data segments with a value greater than the threshold H with the mean of the preceding and following 2N data points; and retaining data segments with a value less than the threshold H.

3. The non-intrusive load identification method based on KNN combined with logistic regression according to claim 2, characterized in that, The specific steps of data smoothing in step S2 are as follows: A1: Take steady-state current data from M consecutive points of load data, and divide the N data points into a small segment. Calculate the average value of each segment. A2: Based on the average value The formula for calculating the data deviation from the threshold H is as follows: A3: For the original load current data, repeat step S1 to determine the difference between the mean of the current data segment and the mean of the adjacent data segment. If it is less than H, retain it; if it is greater than H, perform the following processing:

4. The non-intrusive load identification method based on KNN combined with logistic regression according to claim 1, characterized in that, Step S3 specifically involves: By using bilateral cumulative calculations and location-based load switching points, the standard deviation X of continuous data points is continuously accumulated. n When the cumulative standard deviation exceeds the set threshold e, it is determined that a switching event has occurred. Among them, S n This represents the sum of the cumulative standard deviations of the current data points; Based on the location of the switching event, extract the stable data segments before and after the event, extract the steady-state features, match them one-to-one with the appliance tags, and store them in the primary steady-state feature library.

Citation Information

Patent Citations

  • Load identification method based on non-intrusive intelligent terminal

    CN114186631A