Water quality sensor fault detection method based on PCA-FA-SVM

By applying the PCA-FA-SVM method and firefly algorithm to optimize SVM parameters in water quality sensor fault detection, the problems of missed detection, false detection and lack of early warning in traditional fault detection methods are solved, and more efficient and reliable fault diagnosis is achieved.

CN119513704AInactive Publication Date: 2025-02-25南京三万物联网科技有限公司

Patent Information

Application Number
CN202411547028.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2025-02-25
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional water quality sensor fault detection methods rely on experience and observation, and are prone to missed detection and missed detection, and cannot achieve early warning of sensor faults.

Method used

Using PCA-FA-SVM-based method, the multi-dimensional monitoring data of water quality sensors is dimensionally reduced and feature extraction is performed, and the parameters of the SVM model are optimized by using the firefly algorithm to achieve accurate diagnosis of sensor failures.

Benefits of technology

It improves the accuracy and reliability of fault detection, can identify sensor failures faster, reduces the risk of missed and missed detection, and provides the ability to early warning of faults.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119513704A_ABST
    Figure CN119513704A_ABST
Patent Text Reader

Abstract

The invention relates to a PCA-FA-SVM-based water quality sensor fault detection method. The method comprises the following steps: firstly, acquiring multi-dimensional key water quality data including pH value, dissolved oxygen, conductivity, turbidity and the like, carrying out standardization processing on normal and fault data, and dividing sensor faults into four types of complete failure, fixed deviation, drift deviation and precision reduction; thirdly, performing dimension reduction on the multi-dimensional data by using a PCA method, extracting a principal component, calculating statistics of a main space change T and a residual space change Q, and selecting first several feature vectors with relatively large feature values to form the principal component; and then, in SVM model training, a parameter optimization step is introduced, values of a penalty factor C and a kernel parameter g are optimized by using FA, and the extracted feature vectors are classified and judged, so that fault diagnosis of the sensor is realized. According to the method, the PCA-FA-SVM method is utilized to perform accurate and rapid fault diagnosis on the water quality sensor, so that the detection efficiency and accuracy are improved, and a powerful guarantee is provided for the reliability of water quality monitoring.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of machine learning, and in particular to a water quality sensor fault detection method based on PCA-FA-SVM. Background Art

[0002] Water quality monitoring is an indispensable part of ensuring water safety and water pollution control. Water quality detection parameters provide technical support for water safety and water pollution control. At present, water quality mainly monitors five conventional water quality parameters such as pH, dissolved oxygen, conductivity, turbidity and temperature, as well as ORP, ammonia nitrogen, residual chlorine, COD, BOD, heavy metals, nitrite-nitrate index, total phosphorus and chlorophyll, which have a great impact on the natural environment of water. Water quality sensors are often used in water quality monitoring. However, due to the long-term operation of sensors or the influence of environmental factors, sensors often fail, making the monitoring data inaccurate or invalid, which brings certain risks and uncertainties to water quality monitoring. Traditional fault detection methods mainly rely on the experience and observation of equipment maintenance personnel, which are prone to problems such as missed detection and false detection, and cannot achieve early warning of sensor failures. In view of this, we propose a water quality sensor fault detection method based on PCA-RA-SVM. The PCA method is used to reduce the dimension and extract features of the data. The SVM model optimized by RA is used to diagnose the fault of water quality sensors, which improves the diagnosis speed and accuracy.

[0003] Technical comparison with patent CN116451142 A: a method for water quality sensor fault detection based on machine learning algorithm

[0004] Accuracy and efficiency: The present invention uses PCA for feature extraction and dimension reduction, which improves the efficiency of data processing and the accuracy of fault detection. CN 116451142 A mainly depends on the accuracy of the machine learning model, may require a large amount of data training, and has low efficiency.

[0005] Parameter optimization: The present invention uses the firefly algorithm to optimize the SVM parameters, which improves the classification performance of the model. In contrast, CN116451142 A may not have a dedicated parameter optimization step, and the model performance may be limited.

[0006] Flexibility and adaptability: The method of the present invention can adapt to data sets of different types and sizes, and has better flexibility and adaptability. CN116451142 A may need to retrain the model for different data sets, and has poor flexibility.

[0007] In summary, the water quality sensor fault detection method based on PCA-RA-SVM proposed in the present invention is superior to CN 116451142A in terms of accuracy, efficiency, parameter optimization, flexibility and adaptability, and can more effectively improve the accuracy and reliability of water quality sensor fault detection. Summary of the invention

[0008] In order to solve the above technical problems, the present invention proposes a water quality sensor fault detection method based on PCA-FA-SVM, which uses the PCA-RA-SVM method to accurately and quickly diagnose the faults of water quality sensors.

[0009] To achieve the above object, the technical solution adopted by the present invention is:

[0010] A water quality sensor fault detection method based on PCA-FA-SVM, characterized by comprising:

[0011] S1: Obtain multi-dimensional monitoring data of water quality sensors and standardize normal data and fault data; classify sensor faults into four types: complete failure, fixed deviation failure, drift deviation failure and accuracy degradation;

[0012] S2: Use the principal component analysis method to reduce the dimensionality of the multi-dimensional monitoring data in S1, extract the principal components, reduce the data dimension while retaining key information, and calculate the main space change T 2 and Q statistics describing the spatial variation of residuals, and selecting the first few eigenvectors with larger eigenvalues ​​to form the principal components;

[0013] S3: During the training process of the support vector machine model, a parameter optimization step is introduced. The firefly algorithm is used to optimize the penalty factor C and the kernel parameter g to find the optimal combination, and the extracted feature vectors are classified and judged to perform fault diagnosis on the sensor.

[0014] As a further improvement of the present invention, the specific steps of step S1 are as follows:

[0015] Collect historical measurement data of the normal operation and fault status of water quality sensors, which cover key water quality parameters related to pH, dissolved oxygen, conductivity and turbidity. Use the normal distribution characteristics of sensor data to remove outliers in the data and reconstruct them. The corrected normal historical data of the sensor is normalized with zero mean and unit variance to obtain a standardized matrix. The formula is as follows:

[0016]

[0017] Where E(x) is the mean value of X, σ is the variance of X, is the estimate of X, and E is the residual space.

[0018] As a further improvement of the present invention, the specific steps of step S2 are as follows:

[0019] The covariance matrix of the standardized matrix composed of the normal historical data and fault data of the water quality sensor in S2 is characteristically decomposed, and the number of principal components of the model is selected. After the number of principal components is determined, the principal component and residual subspace projection matrix are obtained through the eigenvector matrix, that is, the principal component model of normal working conditions is established, and the PCA analysis is completed through singular value decomposition. The formula is as follows:

[0020] The standardized covariance matrix is:

[0021]

[0022] Finally, the load matrix P is composed of the eigenvectors. After the load matrix mapping, the sample X can be reduced to a new space. The obtained matrix Y is the principal component score matrix as shown below:

[0023] Y=XP.

[0024] As a further improvement of the present invention, the specific steps of step S3 are as follows:

[0025] Based on S2: After the normal working condition model is built, four types of fault data are introduced. First, T describing the change of the main space is calculated according to the formula 2 And the Q statistic and confidence limit describing the variation of residual space, then standardize the test data X, bring the standardized test data into the PCA model, and calculate T describing the variation of the main space according to the formula 2 and Q statistics and confidence limits describing the spatial variation of the residuals. If the statistics are higher than the confidence limits, find T 2 and Q statistic contribution rate;

[0026] Through PCA feature extraction, the dimensionality reduction effect of the data is achieved. Then, the firefly algorithm is used to optimize the c and g parameters, and a set of initial penalty factor C and kernel parameter g values ​​are randomly generated as the position of the firefly. Then, an objective function is defined to calculate the performance index of the SVM based on the given C and g parameters and training data. Then, the brightness of each firefly is calculated. The brightness is proportional to the performance of the SVM under the corresponding parameters. Fireflies will be attracted and move to brighter fireflies. The distance and direction of movement depend on the brightness difference between the fireflies and the distance between them. The position of the firefly is continuously updated. After multiple iterations, the C and g parameter combination that makes the SVM performance best is found.

[0027] The beneficial effects of the present invention are:

[0028] 1. The present invention combines the PCA-RA-SVM algorithm for water quality sensor fault diagnosis, comprehensively considering the impact of various factors on water quality sensor faults, rather than relying solely on a single variable, thereby improving the accuracy and reliability of fault detection.

[0029] 2. The SVM model optimized by the firefly algorithm has good generalization ability and can adapt to different water quality monitoring environments and data sets. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 This is a fault detection flow chart of the present invention;

[0031] Figure 2 Flowchart for SVM parameter optimization based on the firefly algorithm. DETAILED DESCRIPTION

[0032] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments:

[0033] like Figure 1 As shown in the figure, this case discloses a water quality sensor fault detection method based on PCA-RA-SVM. The specific implementation steps are as follows:

[0034] Step 1: Obtain multi-dimensional monitoring data from water quality sensors, including pH, dissolved oxygen DO, conductivity EC, turbidity T and other multi-dimensional key water quality data, and perform standard processing on normal data and fault data:

[0035]

[0036] The normalized matrix looks like this:

[0037]

[0038] Where E(x) is the mean of X, σ is the variance of X, m is the number of samples, and n is the number of variables. is the estimate of X, and E is the residual space.

[0039] Step 2: Based on the covariance matrix of the standardized matrix composed of the normal historical data and fault data of the water quality sensor in step 1, the characteristic decomposition is performed, and the number of principal components of the model is selected. After the number of principal components is determined, the principal component and residual subspace projection matrix are obtained through the eigenvector matrix, that is, the principal component model of normal working conditions is established, and the PCA analysis is completed through singular value decomposition.

[0040] Let the covariance between the data in columns U and V of matrix X be cov(X U ,X V ), then:

[0041]

[0042] The standardized covariance matrix is:

[0043]

[0044] The covariance matrix eigenvalues ​​and eigenvectors are given below:

[0045] |λI-cosX|=0

[0046] Where λ is the eigenvalue of the covariance matrix and I is the identity matrix.

[0047]

[0048] Among them, λi is the eigenvalue and k is the dimension of the sample after dimensionality reduction.

[0049] Y=XP

[0050]

[0051] where F z,m-1,a represents the value of an F distribution with confidence level z and a and m-1 degrees of freedom, where a is the number of degrees of freedom in the F distribution.

[0052]

[0053] Among them C b is the normal distribution value with confidence level b, λ j is the jth eigenvalue, θ i is the sum of the i-th powers of the j-th to n-th eigenvalues.

[0054] Step 3: After building the normal working condition model, introduce four types of fault data and first calculate T that describes the change of the main space according to the formula 2 And the Q statistic and confidence limit describing the variation of residual space, then standardize the test data X, bring the standardized test data into the PCA model, and calculate T describing the variation of the main space according to the formula 2 and Q statistics and confidence limits describing the spatial variation of the residuals. If the statistic is above the confidence limit, find T 2 And Q statistic contribution rate, find out the faulty sensor. The formula is as follows:

[0055]

[0056] S=diag(λ1,…,λ k )

[0057] Q=X(I-PP T )X T

[0058] Among them, k is the dimension after dimensionality reduction of the initial sample.

[0059] The ath principal component y a To T 2 The contribution rates are as follows:

[0060]

[0061] VARIABLE X j The contribution rate of the ath principal component is as follows:

[0062]

[0063] The firefly algorithm is a heuristic optimization algorithm based on the luminous behavior of fireflies in nature. In the firefly algorithm, each firefly represents a potential solution in the solution space, and the brightness of the firefly is proportional to the quality of its solution. The algorithm updates the position of the solution by simulating the mutual attraction between fireflies. Fireflies with higher brightness will attract fireflies with lower brightness to move toward them. The attraction usually decreases as the distance between fireflies increases, which can be simulated by a decay function. The algorithm continuously updates the position of fireflies through an iterative process. In each iteration, the firefly adjusts its position according to the brightness and attraction of other fireflies. The position update problem of multiple fireflies can be handled at the same time. Therefore, the firefly algorithm is used to optimize the c and g parameters.

[0064] Step 4: If Figure 2 Shown is the SVM parameter optimization flowchart based on the firefly algorithm.

[0065] Step 4.1: The position and brightness of the firefly are represented by the corresponding parameter group, including the penalty factor C and the kernel function parameter g. The objective function is established with the maximum accuracy as the optimization goal. The optimization formula is:

[0066] I i =f(X i ),X i =[x i1 ,x i2 ,…,x in ]

[0067] n=1,2…,n

[0068] Where: I i is the absolute brightness of individual i; f(X i ) is the objective function value of individual i; X i To optimize the variable set, x i1 ,x i2 ,…,x in For X i Each variable in , n is the number of variables.

[0069] Step 4.2: Initialize the firefly population and randomly generate a set of firefly positions. Each firefly position represents a set of penalty factors C and kernel function parameter g. Given the training data set, train the SVM model using the current parameter combination and calculate its accuracy on the validation set.

[0070] The expression for the brightness of the firefly is:

[0071]

[0072] Where: I i,j is the relative brightness of individual i and individual j, I0 is the maximum brightness of the firefly, r i,j is the Euclidean distance between individual i and individual j, x i and x j is the spatial position of fireflies i, j, γ is the light intensity attraction coefficient, which usually takes a value in the range of (0, 1), d is the spatial position dimension, x i,k represents the kth component of firefly i in the d-dimensional space.

[0073] Step 4.3 If the fitness meets the expected value or the number of iterations reaches the maximum value, the individual with the highest fitness in the population, that is, the highest accuracy, is the optimal parameter combination. The attractiveness formula of the firefly algorithm is:

[0074]

[0075] In the formula, β i,j is the relative attraction between individuals i and j, β0 is the maximum attraction, γ is the light intensity attraction coefficient, r i,j is the Euclidean distance between individual i and individual j. The formula for updating the firefly position is as follows:

[0076] x i =x j +β·(x j -x i )+α·rand

[0077] In the formula, α is the step size factor, with a value range of [0,1], and rand is a Gaussian distribution, a uniformly distributed random number variable. That is, adjust the parameters C and g of the SVM. Through the continuous changes in the position and brightness of the fireflies, the optimal combination of the c parameter and the g parameter can be obtained, and the SVM model is trained using the optimized c and g values. For new data, inputting it into the trained SVM model can achieve rapid diagnosis and classification of water quality sensor faults.

[0078] The above description is only a preferred embodiment of the present invention and does not constitute any other form of limitation to the present invention. Any modification or equivalent change made based on the technical essence of the present invention still falls within the scope of protection required by the present invention.

Claims

1. A water quality sensor fault detection method based on PCA-FA-SVM, characterized by: include; S1: Obtain multi-dimensional monitoring data from water quality sensors and standardize normal data and fault data; Sensor failures are divided into four categories: complete failure, fixed deviation failure, drift deviation failure, and accuracy degradation. S2: Use the principal component analysis method to reduce the dimensionality of the multi-dimensional monitoring data in S1, extract the principal components, reduce the data dimension while retaining key information, and calculate the main space change T 2 and Q statistics describing the spatial variation of residuals, and selecting the first few eigenvectors with larger eigenvalues ​​to form the principal components; S3: During the training process of the support vector machine model, a parameter optimization step is introduced. The firefly algorithm is used to optimize the penalty factor C and the kernel parameter g to find the optimal combination, and the extracted feature vectors are classified and judged to perform fault diagnosis on the sensor.

2. The water quality sensor fault detection method based on PCA-FA-SVM according to claim 1 is characterized in that: The specific steps of step S1 are as follows: Collect historical measurement data of the normal operation and fault status of water quality sensors, which cover key water quality parameters related to pH, dissolved oxygen, conductivity and turbidity. Use the normal distribution characteristics of sensor data to remove outliers in the data and reconstruct them. The corrected normal historical data of the sensor is normalized with zero mean and unit variance to obtain a standardized matrix. The formula is as follows: Where E(x) is the mean value of X, σ is the variance of X, is the estimate of X, and E is the residual space.

3. The water quality sensor fault detection method based on PCA-FA-SVM according to claim 1 is characterized in that: The specific steps of step S2 are as follows: The covariance matrix of the standardized matrix composed of the normal historical data and fault data of the water quality sensor in S2 is characteristically decomposed, and the number of principal components of the model is selected. After the number of principal components is determined, the principal component and residual subspace projection matrix are obtained through the eigenvector matrix, that is, the principal component model of normal working conditions is established, and the PCA analysis is completed through singular value decomposition. The formula is as follows: The standardized covariance matrix is: Finally, the load matrix P is composed of the eigenvectors. After the load matrix mapping, the sample X can be reduced to a new space. The obtained matrix Y is the principal component score matrix as shown below: Y=XP.

4. The water quality sensor fault detection method based on PCA-FA-SVM according to claim 1 is characterized in that: The specific steps of step S3 are as follows: Based on S2: After the normal working condition model is built, four types of fault data are introduced. First, T describing the change of the main space is calculated according to the formula 2 And the Q statistic and confidence limit describing the variation of residual space, then standardize the test data X, bring the standardized test data into the PCA model, and calculate T describing the variation of the main space according to the formula 2 and Q statistics and confidence limits describing the spatial variation of the residuals. If the statistics are higher than the confidence limits, find T 2 and Q statistic contribution rate; Through PCA feature extraction, the dimensionality reduction effect of the data is achieved. Then, the firefly algorithm is used to optimize the c and g parameters, and a set of initial penalty factor C and kernel parameter g values ​​are randomly generated as the position of the firefly. Then, an objective function is defined to calculate the performance index of the SVM based on the given C and g parameters and training data. Then, the brightness of each firefly is calculated. The brightness is proportional to the performance of the SVM under the corresponding parameters. Fireflies will be attracted and move to brighter fireflies. The distance and direction of movement depend on the brightness difference between the fireflies and the distance between them. The position of the firefly is continuously updated. After multiple iterations, the C and g parameter combination that makes the SVM performance best is found.

Citation Information

Patent Citations

  • Water quality sensor fault detection method based on machine learning algorithm

    CN116451142A

  • IGWO-SVM transformer fault diagnosis method based on PCA feature extraction

    CN117131429A

Cited By

  • Thermal power equipment fault diagnosis method based on artificial intelligence

    CN120337058A

  • Fault intelligent diagnosis and real-time alarm control method for direct drinking water equipment

    CN120408342A