Fault diagnosis of building electrical system based on compressed perception theory

Building electrical systems in modern buildings are increasingly playing a pivotal role in bringing people the convenience of life, at the same time, the building electrical system will inevitably fail. And the research of intelligent fault diagnosis algorithms for this field is still in its infancy. At this stage, the accuracy and reliability of fault monitoring and diagnosis of most building electrical systems are yet to be improved. Aiming at the current lack of effective diagnosis of faults in the building electrical system, this paper takes the fault situation of the electrical system in the building as the main object of research, and simulates the common building electrical faults through the comprehensive experimental platform of the building electrical, taking into account the problem of low diagnostic efficiency of the building electrical system. This paper puts forward a fault diagnostic algorithm based on the combination of compressed perception and the K-nearest neighbor algorithm, which is aimed at improving the diagnostic efficiency of building electrical system faults. The results show that the proposed fault diagnosis algorithm can not only improve the accuracy of fault classification but also shorten the time of fault classification, which greatly improves the fault diagnosis efficiency.


Introduction
The building electrical system is an important facility to ensure the normal operation of electrical equipment in the building space, which mainly includes the needs of building power supply and distribution, daily office, and mechanical equipment electricity.However, with the increase in the type and number of electrical facilities, the size of the electrical system is growing and the connection between the structures is becoming more complex.Fault diagnosis and analysis, and fault repair are important parts of the operation and management of the building electrical engineering.Building electrical fault diagnosis technology has been mature in the field of machinery, electric power systems, and other areas of development, but the development of building electrical systems and the application of intelligent detection systems are still in the embryonic stage.In the traditional fault diagnosis algorithm, the faults of the building electrical system can be effectively categorized.But there are certain drawbacks, for example, the training time of the algorithm is too long, and it can not diagnose the faults in a very timely manner.The advent of automation and intelligence solves such problems.The fault diagnosis process can be simplified, and diagnostic efficiency can be improved, so as to develop a set of practical solutions to ensure its accuracy and enhance the stability and reliability of the entire building electrical system.In the field of building electrical intelligence, and how to use modern information technology to ensure the stability and reliability of the electrical system, higher requirements are put forward.In order to adapt to the current situation of rapid development in the field of construction engineering, it is necessary to propose a targeted scientific and efficient diagnostic model to improve the diagnostic effect.
In view of the inefficiency of building electrical fault diagnosis, this paper studies how to reduce the redundancy of data.Firstly, the compressed perception algorithm is used to downsize the original signal, which can be very good at removing the redundant information in the signal under the premise of retaining the original features, so as to achieve the purpose of reducing the amount of sample data.Then, for fault classification, the K-nearest neighbor algorithm is used, combining the ideas of the above two algorithms.The building electrical fault diagnosis algorithm based on the combination of compressed perception and K-nearest neighbor algorithm is proposed to achieve the purpose of improving the diagnostic efficiency of the faults of the building electrical system as well as the accuracy.

Building electrical system overview
Building electrical systems can be categorized into two groups according to the strength of electrical energy, respectively, "strong power system" and "weak power system".Figure 1 shows the composition of the categorized building electrical system.In particular, "strong system" generally refers to an electrical system with a voltage greater than 36 V but less than 380 V, and "weak system" refers to a system with a voltage less than 36 V.The building electrical system contains a wide variety of subsystems.Therefore, to build an electrical system for close protection, we need to research and analyze the operating conditions and fault characteristics of the building electrical system, in order to make targeted troubleshooting programs.
Common faults in building electrical systems can be divided into four main categories: line impedance faults, continuity resistance faults, grounding system faults, and insulation faults.

Compression sensing overview
The core of the theory of compressed perception is the use of sparse features of the signal to transform the captured signal into the original signal [1] .

Principles of compressed sensing
Assuming that the length of the original signal x is n, after sparsification, the signal x can be represented by Equation (3): where is called the sparse matrix, which is an orthogonal matrix; Ψi denotes the ith transform basis vector; s is the sparse vector, which represents the transform coefficients of the signal x on the sparse matrix Ψ.If the original signal x is sparsely representable, then there should be only a finite number of nonzero values in the sparse vector s.(2) Equation ( 2) represents the linear projection of the original signal x under the transformation of the observation matrix φ, with the resultant y representing an observation vector.
The processing of the signal using CS mainly includes three processes: sparse representation of the signal, observation of the signal, and reconstruction of the signal [2] .These three aspects will be elaborated on accordingly next.

Sparse representation of signals
If the observed signal x of the electrical state of a building has only a few non-zero values along the time axis, when all other values are close to or equal to zero, then this signal x can be compressed, i.e., sparsely represented [3] .This sparse representation is not possible on the normal signal domain, and it is necessary to process the signal or observation data to transform it into other expression domains for sparse observation [4] .In this study, the Fourier transform is used to sparsely represent the signal.

Observation signal
Observing the signal is seeking a deterministic observation matrix to compress and sample the signal.To ensure that the projection measurement matrix has a good compressed observation performance for the whole signal, and at the same time meets the requirements of the accuracy of the next signal reconstruction, the selection of the observation matrix needs to satisfy the two major conditions of the Restricted Isometry Property and the non-correlation with the sparse matrix.The Restricted Isometry Property (RIP) is defined as follows: if there exists a constant αk∈(0,1) that satisfies Equation (3): , then the measurement matrix is said to satisfy the K-constrained isometric property.

Reconstruction of signals
CS theory transforms the reconstruction of signals into a convex optimization solving process for lowdimensional to high-dimensional signal recovery.Considering the reconstruction of the original number x from the observed signal y, the reconstruction can be realized by solving the optimal l0 paradigm of the measured signal y to obtain the exact or approximate solution of x, as shown in Equation ( 4): There are infinitely many solutions to Equation (3.4).Considering that s is a sparse vector, Equation (4) can usually be converted into an optimal problem for solving the l1-parameter as shown in Equation ( 5) by reasonably choosing the observation matrix φ and the sparse matrix ψ: where x represents the signals of the building electrical system after the sparse representation.Then, after data processing using the Orthogonal Matching Tracking algorithm, the information contained in the signal can be preserved basically intact, which provides a good foundation for the subsequent fault diagnosis algorithm based on compressed sensing and the K-Nearest Neighbor algorithm (CS-KNN) [5] .

Fault diagnosis method based on CS-KNN
The K-Nearest Neighbor (KNN) algorithm is a widely used classification and regression method, which mainly relies on the surrounding K neighboring known samples to determine the class to which the samples to be tested belong, thus it is more suitable for those sample sets with more intersection or overlap.The three basic elements of the KNN algorithm are the distance metric, the selection of the number of k values of the nearest neighbors, and the categorization decision rule, respectively.

Distance metric
Euclidean distance, Manhattan distance, and Mars distance are the distance metrics with more applications.European distances are applicable to the troubleshooting of building electrical systems to be addressed in this paper.The calculation equation is: where a represents the reconstructed signal value; b represents the fault criterion value; ai represents the ith dimension coordinate of the reconstructed signal value in the Euclidean space; bi represents the ith dimension coordinate of the fault criterion value in the Euclidean space; d (a, b) represents the Euclidean distance between the reconstructed signal value and the fault criterion value.

Selection of the value of the number of nearest neighbors K
Different k-values will have a significant impact on the classification results.If the number of nearest neighbors k is too small, the number of domain samples for training the model is too small and leads to low prediction accuracy of the model.When the k value is too large, it is easy to produce the phenomenon of underfitting.To select the optimal value of k, the method of cross-validation is usually used for selection [6] .There are K nearest sample points around the input to-be-tested samples, given a classification task with the classification function shown in Equation ( 7): where a denotes the sample to be tested and ci denotes the category of the training sample.a discriminant function is constructed and defined as shown in Equation ( 8): (8) where ci denotes the true category of the sample to be tested; a. K denotes the number of nearest neighbors of the KNN algorithm.

Categorical decision-making rules
The samples to be tested and the nearest neighbor samples are grouped with the highest percentage of the category to which they belong according to the law of majority voting [7] .The classification operation is performed on the sample to be tested by using the majority voting classification mechanism, and the final category of the sample to be tested is

Troubleshooting experiments on building electrical systems
This paper constructs the CS compression method and CS-KNN fault diagnosis method for building electrical system signals.The optimal K value is selected by using the cross-validation method, and the test data set accounts for 1/5 of the sample data set.When the value of K is 11, the accuracy of the corresponding training dataset and the accuracy of the test dataset reach the maximum at the same time, so the value of K selected in this range is considered to be optimal.
To verify the effectiveness of the CS-KNN diagnostic algorithm, two classification algorithms, BP neural network, and KNN, are selected to compare the classification effect.confusion matrix is used as an evaluation metric to comprehensively analyze the fault classification capabilities of individual diagnostic algorithms in building electrical systems.The basic confusion matrix is shown in Table 1.It has four evaluation parameters, which are: (1) True positives (TP): results indicate that both the true and predicted values of the sample are positive; False positives (FP): results indicate that the true value of the sample is negative, but the predicted value is positive; False negatives (FN): results indicate that the true value of the sample is positive, but the predicted value is negative;(4) True Negative (TN): the result indicates that both the true value and the predicted value of the sample are negative.
From the four parameters, the following four evaluation indicators are extended: (1) Accuracy (ACC): The proportion of total observations for which all judgments of the classification algorithm are correct; (2) Precision (PPV): The proportion of all outcomes for which the algorithm is predicted to be positive that the algorithm predicts correctly.( 3) Sensitivity (TPR): The proportion of all outcomes where the true value is positive that the algorithm predicts correctly.( 4) Specificity (TNR): The proportion of all outcomes where the true value is negative that the algorithm predicts correctly.The formulas for calculating these evaluation indicators are shown in Table 2.The comparison of the experiments in this chapter selects 24,000 sample data, in which the training set accounts for 4/5 of the sample data, and the test set accounts for 1/5 of the sample data.There are a total of 22 fault test points for the four types of faults, and the data from 10 fault test points are randomly selected during the experiment.There are different test points for the same type of fault, so there may be a misjudgment between different faults.When the true category is A1, it will be misclassified as C5 and C6 in prediction; when the true category is C5, it will be misclassified as C1 and C6; when the true category is C6, it will be misclassified as C1 and C5, and C2, C4, C7, C3, C10, C8, and C9 are also different test points of the same kind of faults so that misclassification may occur between them.The accuracy of the three methods for diagnosing various types of faults is shown in Table 3.The accuracy of the BP neural network is 86.85%, the accuracy of the KNN algorithm is 87.21%, and the diagnostic algorithm of CS-KNN proposed in this paper has the highest accuracy among these three algorithms, 87.35%, which indicates that the diagnostic algorithm proposed in this paper is better in terms of accuracy.To be able to better analyze the classification performance of these three classification algorithms for 10 fault test points, the results are evaluated by evaluating the time consumed for training.In terms of the consumption of time in training, the BP neural network consumes 306.5 s, the KNN algorithm consumes 321.6 s, and CS-KNN effectively shortens the training consumption time to only 189.4 s due to the dimension reduction of CS.BP neural network consumes 308.4 s, the KNN algorithm consumes 321.6 s, and CS-KNN effectively shortens the training consumption time to only 189.3 s due to the dimensionality reduction of CS.Therefore, it can be concluded that, in the case of a large amount of sample data, the CS-KNN algorithm proposed in this paper can improve the accuracy rate and at the same time, effectively shorten the time of fault diagnosis.

Conclusion
In this study, the CS-KNN fault diagnosis algorithm is proposed to improve the traditional fault diagnosis algorithms to solve the problem of time-consuming training for the classification of building electrical system faults.The algorithm largely improves the efficiency of fault diagnosis in building electrical systems.
At present, the fault diagnosis of building systems is still in its infancy, and there are problems such as the difficulty of constructing accurate mathematical models, the difficulty of collecting data on building electrical faults, and the immaturity of research methods.With the increasing importance attached by all sectors of society to the development of building electrical system fault diagnosis technology, China's research on building electrical system fault diagnosis technology has also entered a new stage.However, due to the high degree of complexity of the building electrical system, the fault detection personnel must detect and analyze faults through the construction of a simulation platform based on in-depth analysis and study of the fault state, in order to promote the overall improvement of the accuracy of the diagnosis results of the building electrical system faults.

Figure 1 .
Figure 1.Classification of building electrical system.

Table 2 .
Evaluation Metrics for Confusion Matrices.

Table 3 .
Comparison of the Accuracy of Three Methods for Diagnosing Different Faults.