Building electrical fault diagnosis method based on pca and sparrow optimization random forest
By combining PCA and sparrow algorithm-optimized random forest (SSA-RF), a building electrical fault diagnosis framework was constructed, which solved the time-consuming and labor-intensive problems and subjective influences of traditional methods and achieved fast and accurate fault identification and type differentiation.
Patent Information
- Application Number
- CN202211659561.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-22
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2042-12-22
AI Technical Summary
Traditional building electrical fault diagnosis methods are time-consuming, labor-intensive, and easily influenced by subjective experience. Existing intelligent diagnostic technologies have not formed an effective system, making it difficult to quickly and accurately identify faults in complex building electrical systems.
A method combining PCA and sparrow algorithm optimized random forest (SSA-RF) is adopted to construct a building electrical fault diagnosis framework through fault data collection, feature extraction, dimensionality reduction and classification, including time domain and frequency domain feature extraction, PCA dimensionality reduction and SSA-RF classifier optimization.
It achieves rapid detection of building electrical faults, accurate identification of fault types, improves fault diagnosis efficiency and accuracy, and reduces manpower consumption and safety hazards.
Smart Images

Figure CN116087647B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of fault diagnosis, and in particular relates to a building electrical fault diagnosis method based on PCA and sparrow algorithm optimized random forest. Background Art
[0002] With rapid economic development and accelerated modernization, building facilities are increasing in number, and building electrical systems are becoming increasingly complex. To ensure the safe and reliable operation of electrical systems and reduce the occurrence of safety accidents, fault detection and diagnosis of building electrical systems is crucial. Traditional fault diagnosis methods rely on manual fault detection by maintenance workers, which is time-consuming and labor-intensive, and easily influenced by subjective experience. Intelligent diagnostic technology has emerged to improve the efficiency and accuracy of fault diagnosis. Although intelligent fault diagnosis technology for building electrical systems has developed in recent years, a scientific and effective diagnostic system has yet to be established. Therefore, research on new methods and technologies is crucial. Building electrical systems are extensive, encompassing multiple subsystems such as lighting and power distribution systems. Their complexity presents numerous challenges for fault diagnosis. To this end, we propose a building electrical fault diagnosis method based on PCA and a sparrow algorithm-optimized random forest. This method facilitates timely fault detection, reduces labor consumption, mitigates safety hazards, and improves fault diagnosis accuracy. Summary of the Invention
[0003] The purpose of the present invention is to provide a building electrical fault diagnosis method based on PCA and sparrow algorithm optimized random forest to solve the problems raised in the above background technology.
[0004] To achieve the above objectives, the present invention provides the following technical solution: a building electrical fault diagnosis method based on PCA and sparrow algorithm optimized random forest, first collecting raw resistance signals of n different faults on an experimental platform, then selecting time domain and frequency domain correlation formulas commonly used in statistical analysis to extract features from the signals, after extracting the fault features, PCA is used to reduce the feature dimension, and finally, the n faults are classified using a RF classifier optimized by SSA, including the following steps:
[0005] Step 1: Fault data acquisition: The fault data acquisition module is connected to the electrical comprehensive tester Eurotest61557 to collect n kinds of fault original signals of the building electrical system;
[0006] Step 2: Fault feature extraction: The fault feature extraction module establishes a connection with the fault data acquisition module to extract the time domain features and frequency domain features from the collected fault original signal and obtain the original feature matrix for subsequent fault diagnosis;
[0007] Step 3: Feature PCA dimensionality reduction: The feature PCA dimensionality reduction module is connected to the fault feature extraction module to reduce the dimensionality of multi-dimensional features and reduce the number of features;
[0008] Step 4: SSA-RF fault classification: The SSA-RF fault classification module is connected to the feature PCA dimension reduction module for feature classification to obtain the diagnosis results.
[0009] In the fault data collection step S1, n types of building electrical faults are collected, 30 groups of fault samples are collected for each fault, each group of samples is composed of 50 sampling points, and the sampling frequency is 256 Hz.
[0010] After the fault data is collected in step S1, the time domain characteristic index and the frequency domain characteristic index are calculated for each group of samples using a statistical analysis formula.
[0011] The time domain characteristic indicators are: maximum value, minimum value, peak-to-peak value, average value, root mean square, variance, standard deviation, kurtosis, skewness, form factor, peak factor, pulse factor, and margin factor; the frequency domain characteristic indicators are: average index, center of gravity frequency, mean square frequency, root mean square frequency, frequency variance, and frequency standard deviation.
[0012] Before calculating the frequency domain feature index, it is necessary to calculate the power spectral density of the sample first. After the time domain feature index and frequency domain feature index are calculated, the p-dimensional original feature matrix is obtained.
[0013] To address the problem of excessive feature dimensions, PCA is used to reduce the p-dimensional original feature matrix to obtain a q-dimensional reduced feature matrix.
[0014] The samples in the feature matrix after q-dimensionality reduction are divided into training set and test set according to 7:3, and SSA-RF is used for fault classification.
[0015] SSA is used to optimize two parameters of RF: the number of trees and the minimum number of leaf nodes.
[0016] The RF model is trained with the parameters optimized by SSA. The RF contains several weak classifiers, which vote on the results and select the category with the most votes as the output of the classifier.
[0017] Compared with the prior art, the beneficial effects of the present invention are as follows: the present invention provides a building electrical fault diagnosis method based on PCA and sparrow algorithm optimized random forest. The present invention proposes for the first time a new method for diagnosing building electrical faults, which has the advantages of rapid detection of building electrical faults and accurate identification of fault types. The present invention combines the statistical analysis of time-frequency domain indicators, the PCA linear dimensionality reduction method and the SSA-RF classifier for the first time, integrates the relevant theories of machine learning and swarm intelligence technology, and applies them to the field of building electrical fault diagnosis, constructing a new building electrical fault diagnosis framework. Compared with traditional machine learning methods and newly published methods, the diagnostic model of the present invention has better performance. In summary, the present invention can provide a new fault detection method for practitioners in the building electrical industry, help practitioners identify fault types, enhance practitioners' safety awareness, and ensure the safe and reliable operation of electrical systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 Schematic diagram of the flow of the building electrical fault diagnosis method based on PCA and sparrow algorithm optimization random forest of the present invention;
[0019] Figure 2 This is the time domain waveform of the original resistance signal of fault 1 of the present invention;
[0020] Figure 3 This is the time domain waveform of the original resistance signal of fault 2 of the present invention;
[0021] Figure 4 This is the time domain waveform of the original resistance signal of fault 3 of the present invention;
[0022] Figure 5 This is the time domain waveform of the original resistance signal of fault 4 of the present invention;
[0023] Figure 6 This is the time domain waveform of the original resistance signal of fault 5 of the present invention;
[0024] Figure 7 This is the time domain waveform diagram of the original resistance signal of fault 6 of the present invention. DETAILED DESCRIPTION
[0025] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0026] The present invention provides Figure 1-7A building electrical fault diagnosis method based on PCA and Sparrow algorithm optimized random forest, where PCA is principal component analysis and Sparrow algorithm optimized random forest is SSA-RF, including the following steps:
[0027] Step 1: Fault data acquisition: The fault data acquisition module is connected to the electrical comprehensive tester Eurotest61557 to collect n kinds of fault original signals of the building electrical system;
[0028] Step 2: Fault feature extraction: The fault feature extraction module establishes a connection with the fault data acquisition module to extract the time domain features and frequency domain features from the collected fault original signal and obtain the original feature matrix for subsequent fault diagnosis;
[0029] Step 3: Feature PCA dimensionality reduction: The feature PCA dimensionality reduction module is connected to the fault feature extraction module to reduce the dimensionality of multi-dimensional features and reduce the number of features;
[0030] Step 4: SSA-RF fault classification: The SSA-RF fault classification module is connected to the feature PCA dimension reduction module for feature classification to obtain the diagnosis results.
[0031] In the fault data collection step S1, n types of building electrical faults are collected, 30 groups of fault samples are collected for each fault, each group of samples is composed of 50 sampling points, and the sampling frequency is 256 Hz.
[0032] After the fault data is collected in step S1, the time domain characteristic index and the frequency domain characteristic index are calculated for each group of samples using a statistical analysis formula.
[0033] The time domain characteristic indicators are: maximum value, minimum value, peak-to-peak value, average value, root mean square, variance, standard deviation, kurtosis, skewness, form factor, peak factor, pulse factor, and margin factor; the frequency domain characteristic indicators are: average index, center of gravity frequency, mean square frequency, root mean square frequency, frequency variance, and frequency standard deviation.
[0034] Before calculating the frequency domain feature index, it is necessary to calculate the power spectral density of the sample first. After the time domain feature index and frequency domain feature index are calculated, the p-dimensional original feature matrix is obtained.
[0035] To address the problem of excessive feature dimensions, PCA is used to reduce the p-dimensional original feature matrix to obtain a q-dimensional reduced feature matrix.
[0036] The samples in the feature matrix after q-dimensionality reduction are divided into training set and test set according to 7:3, and SSA-RF is used for fault classification.
[0037] SSA is used to optimize two parameters of RF: the number of trees and the minimum number of leaf nodes.
[0038] The RF model is trained with the parameters optimized by SSA. The RF contains several weak classifiers, which vote on the results and select the category with the most votes as the output of the classifier.
[0039] Figure 1 The flowchart of the present invention includes 4 parts, corresponding to steps 1 to 4. Step 1 is fault data collection, step 2 is fault feature extraction, step 3 is feature PCA dimensionality reduction, and step 4 is SSA-RF fault classification.
[0040] In the fault data collection (step 1) of the present invention, the data acquisition platform is an electrical comprehensive experimental instrument Eurotest61557. Since parameters such as current, voltage, and resistance may change when the electrical system fails, n types of fault states are simulated on the experimental platform, and their resistance signals are collected for subsequent processing and analysis. For each fault type, the present invention collects 30 groups of sample data, each group of data has 50 sampling points, a total sample number of N groups, and a sampling frequency of 256 Hz.
[0041] In order to intuitively display the changes in resistance data of different faults, the present invention selects one sample of each fault for visualization, see Figure 2-7 , shows the time domain waveforms of n types of faults. The horizontal axis corresponds to the sampling point and the vertical axis corresponds to the amplitude value. Different types of fault waveforms have different characteristics.
[0042] In the fault feature extraction (step 2) of the present invention, a connection is established with the fault data acquisition, and the various features of the fault original resistance signal are extracted. Since it is difficult to distinguish the fault with the naked eye from the waveform alone, a set of fault diagnosis schemes is needed to determine the fault type. In the fault diagnosis scheme of the present invention, feature extraction is a very critical step, and the quality of the feature will directly affect the result of the fault diagnosis. Time domain analysis can reflect the situation of signal amplitude changing over time, while frequency domain analysis can reflect the situation of signal frequency changing over time. In order to more comprehensively extract the features of the fault signal, the present invention combines time domain analysis with frequency domain analysis, selects the time domain indicators (maximum value, minimum value, peak-to-peak value, average value, root mean square, variance, standard deviation, kurtosis, skewness, form factor, peak factor, pulse factor, margin factor) and frequency domain indicators (average index, center of gravity frequency, mean square frequency, root mean square frequency, frequency variance, frequency standard deviation) in the statistical analysis to extract features of the original signal, and combines the extracted time domain and frequency domain indicators into a p-dimensional feature matrix.
[0043] Before extracting the frequency domain features, the power spectral density (PSD) of the sample needs to be calculated first, and the periodic graph method is used to estimate the PSD value of the original fault signal. The periodic graph estimation method obtains the PSD estimation value of the original signal through discrete Fourier transform, and can reflect the distribution of the fault signal power in the frequency domain. The calculated PSD value is used in the frequency domain index formula to further extract the frequency domain features of the original fault signal. The p-dimensional feature matrix composed of the time domain features and the frequency domain features, each column corresponds to a feature, and the matrix size is N*p.
[0044] In the feature dimension reduction (step 3) of the present application, the PCA dimension reduction method is connected with the fault feature extraction. Although it is more convenient to directly extract the features of the signal by formula, too many types of features will increase the running time. In addition, there may be some redundant features. Therefore, the present application uses PCA to reduce the dimension of the extracted features. PCA is a linear dimension reduction method, which can map the features from high-dimensional space to low-dimensional space, extract the main feature components of the data under a new set of bases, and the transformed features are mutually independent. PCA has two decomposition methods: SVD decomposition and eigenvalue decomposition, and the present application uses the eigenvalue decomposition method.
[0045] When using PCA to reduce the dimension of the feature matrix, it is necessary to first center each dimension of the feature, that is, to subtract the mean value of the elements in the matrix, then to calculate the covariance matrix of the centered feature matrix, and then to solve the eigenvalues and eigenvectors of the covariance matrix. Multiply the eigenvector matrix by the centered feature matrix to transform the original feature matrix to a new space. For the PCA transformed matrix, each column is a principal component, and the principal components are arranged in descending order according to the variance contribution rate. The variance contribution rate is the standard (q value) for measuring how many dimensions the features are reduced to in the present application.
[0046] In order to retain most of the features, the present application selects the principal components with a variance contribution rate of 99.9% as the feature matrix after dimension reduction. Through the descending order arrangement of the contribution rate of the principal component 1 to the principal component q after PCA transformation, the joint variance contribution rate of the first two principal components can reach 99.9%, so the present application determines that the dimension after dimension reduction is 2 (i.e. q=2), and the size of the feature matrix after dimension reduction is N*q.
[0047] In the SSA-RF fault classification (step 4) of the present invention, RF is selected as the classifier. RF is a type of ensemble learning algorithm that integrates multiple binary trees internally. Each binary tree is a weak classifier with classification capabilities. RF has two random properties: sampling randomness and randomness in the selection of node classification attributes. These two random properties can reduce the risk of model overfitting. In addition, to reduce the impact of RF parameters on classification results and improve classification accuracy, the SSA algorithm in the swarm intelligence algorithm was selected to optimize two RF parameters: the number of trees and the minimum number of leaf nodes. SSA optimizes parameters by simulating the foraging behavior of a sparrow population.
[0048] Before classifying the feature sample dataset, it is necessary to label the samples and divide them into training and test sets. The 30 groups of samples for fault 1 are assigned label 1, the 30 groups of samples for fault 2 are assigned label 2, and so on, and the 30 groups of samples for fault n are assigned label n. The training and test sets are divided in a 7:3 ratio. When optimizing the SSA parameters, the optimization dimension is set to 2. The fitness function uses the sum of 70% of the training set error and 30% of the test set error. Since the initial position of the SSA population is random, the optimal parameters obtained are also random. The RF is trained using the two optimized parameters. Multiple binary tree weak classifiers in the RF vote, and the fault category is output based on the principle of majority rule.
[0049] The first 70% of the 30 samples for each fault type are selected for training, i.e., the first 21 groups of samples. The last 30% of the 30 samples for each fault type are selected for testing, i.e., the last 9 groups of samples. The total number of samples is N groups, with the total training set samples being 70%*N groups and the total test set samples being 30%*N groups. Due to the random nature of parameter optimization, the present invention randomly selects a set of optimized parameters for model training. The number of trees for this set of parameters is 11, with a minimum number of leaf nodes of 8.
[0050] After SSA-RF classification, the accuracy of the training set reached 100%, and the accuracy of the test set reached 98.15%. In the test set classification results, only one sample in Fault 1 was misclassified as Fault 2. This is because the original resistance signal of Fault 1 is highly similar to the original resistance signal of Fault 2. The classification accuracy of the other four faults, Fault 3, Fault 4, Fault 5, and Fault 6, all reached 100%. In addition, compared with other methods such as RF, support vector machine (SVM), K-nearest neighbor (KNN) that do not perform parameter optimization, the classification accuracy of the present invention is also the highest. Therefore, the present invention can accurately detect the fault type of the building electrical fault system and has a good fault diagnosis effect.
[0051] In summary, compared with existing technologies, this invention proposes a novel fault diagnosis solution that combines statistical analysis of time-domain and frequency-domain indicators, linear dimensionality reduction, and swarm intelligence algorithms to optimize machine learning classifiers. This approach is applied to building electrical fault detection, constructing a new system-wide fault diagnosis framework for building electrical faults that can rapidly identify and accurately classify them. Compared to other methods that don't optimize parameters, such as RF, SVM, and KNN, this invention offers a new approach to intelligent fault diagnosis, enriching building electrical fault diagnosis methods and reducing the various safety hazards caused by electrical faults.
[0052] Finally, it should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A building electrical fault diagnosis method based on PCA and sparrow algorithm optimized random forest, characterized by: The steps include: Step 1: Fault data acquisition: The fault data acquisition module is connected to the electrical comprehensive tester Eurotest61557 to collect n kinds of fault original signals of the building electrical system; Step 2: Fault feature extraction: The fault feature extraction module is connected to the fault data acquisition module to extract the time domain features and frequency domain features from the collected original fault signal and obtain the original feature matrix for subsequent fault diagnosis; Step 3: Feature PCA dimensionality reduction: The feature PCA dimensionality reduction module is connected to the fault feature extraction module to reduce the dimensionality of multi-dimensional features and reduce the number of features; Step 4: SSA-RF fault classification: The SSA-RF fault classification module is connected to the feature PCA dimension reduction module for feature classification to obtain the diagnosis results.
2. The method for diagnosing building electrical faults based on PCA and sparrow algorithm optimized random forest according to claim 1, characterized in that: In the fault data collection step S1, n types of building electrical faults are collected, 30 groups of fault samples are collected for each fault, each group of samples is composed of 50 sampling points, and the sampling frequency is 256 Hz.
3. The method for diagnosing building electrical faults based on PCA and sparrow algorithm optimized random forest according to claim 1, characterized in that: After the fault data is collected in step S1, the time domain characteristic index and the frequency domain characteristic index are calculated for each group of samples using a statistical analysis formula.
4. The method for diagnosing building electrical faults based on PCA and sparrow algorithm optimized random forest according to claim 3, characterized in that: The time domain characteristic indicators are: maximum value, minimum value, peak-to-peak value, average value, root mean square, variance, standard deviation, kurtosis, skewness, form factor, peak factor, pulse factor, and margin factor; the frequency domain characteristic indicators are: average index, center of gravity frequency, mean square frequency, root mean square frequency, frequency variance, and frequency standard deviation.
5. The method for diagnosing building electrical faults based on PCA and sparrow algorithm optimized random forest according to claim 4, characterized in that: Before calculating the frequency domain feature index, it is necessary to calculate the power spectral density of the sample first. After the time domain feature index and frequency domain feature index are calculated, the p-dimensional original feature matrix is obtained.
6. The method for diagnosing building electrical faults based on PCA and sparrow algorithm optimized random forest according to claim 5, characterized in that: To address the problem of excessive feature dimensions, PCA is used to reduce the p-dimensional original feature matrix to obtain a q-dimensional reduced feature matrix.
7. The method for diagnosing building electrical faults based on PCA and sparrow algorithm optimized random forest according to claim 6, characterized in that: The samples in the feature matrix after q-dimensionality reduction are divided into training set and test set according to 7:3, and SSA-RF is used for fault classification.
8. The method for diagnosing building electrical faults based on PCA and sparrow algorithm optimized random forest according to claim 7, characterized in that: SSA is used to optimize two parameters of RF: the number of trees and the minimum number of leaf nodes.
9. The method for diagnosing building electrical faults based on PCA and sparrow algorithm optimized random forest according to claim 8, characterized in that: The RF model is trained with the parameters optimized by SSA. The RF contains several weak classifiers, which vote on the results and select the category with the most votes as the output of the classifier.
Citation Information
Patent Citations
Transformer fault diagnosis method
CN114113868A
Fault diagnosis method for optimizing relevance vector machine through wavelet packet analysis and sparrow algorithm
CN114997332A