Method for predicting outlet water quality of rural sewage treatment facility based on multi-path data source
By collecting water samples in rural sewage treatment facilities and using a multi-layer perceptron artificial neural network combined with the Lasso algorithm to establish an absorption spectrum simulation water quality model, the problem of low accuracy of traditional detection methods for the effluent quality of rural sewage treatment facilities is solved, and a rapid , accurate water quality testing and operation management assistance.
Patent Information
- Application Number
- CN202410828808.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-10-11
AI Technical Summary
Traditional online water quality detection is difficult to fully cover rural domestic sewage treatment facilities, and due to the complex components of sewage, existing detection devices have low accuracy in predicting the spectra of different components of water, making it difficult to effectively identify the quality of effluent from rural sewage treatment facilities.
By collecting water samples from the outlet wells of rural sewage treatment facilities, constructing a data frame, using a multi-layer perceptron artificial neural network combined with the Lasso algorithm to establish an absorption spectrum simulation water quality model, optimizing the model parameters, and using the gradient descent optimization algorithm for training, the rural sewage Rapid testing of effluent quality from treatment facilities.
It achieves rapid and accurate detection of effluent quality from rural sewage treatment facilities, provides effective assistance to the operation and management of sewage treatment facilities, and improves detection accuracy and efficiency.
Smart Images

Figure CN118760979A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of environmental protection technology, and in particular relates to a method for predicting effluent quality of rural sewage treatment facilities based on multi-channel data sources. Background Art
[0002] In recent years, more and more rural domestic sewage treatment facilities have been put into operation. It is necessary to strengthen the evaluation of the operation status of sewage treatment facilities, especially water quality testing. How to conveniently and accurately identify and monitor the effluent quality of rural domestic sewage treatment facilities has become an important issue. However, due to the large number of rural domestic sewage treatment facilities and their scattered distribution, traditional water quality online testing methods are difficult to fully cover every sewage treatment facility due to funding and technical requirements, and it costs a lot to collect water quality for manual testing.
[0003] Scanning the water body with an ultraviolet visible spectrometer and establishing a prediction model can effectively determine the current water quality of the water body, providing a fast and efficient monitoring method for water quality identification. For example, Chinese patent CN117451640A discloses a multi-band fitting full-spectrum water quality detection system, which mainly includes a light source component, an optical pool, a control component, a photoelectric detection component, and a signal processing component. By customizing the integrated packaging of multi-wavelength LEDs, it can effectively improve the miniaturization level and controllability of the light source, and collect signals at key wavelength points, and then fit them into a full-spectrum curve, and use machine learning methods for modeling and testing. Chinese patent CN116297251A discloses a multi-sensor combined water quality detection system and its detection probe, including a water quality monitoring module for obtaining detection parameters; a water body identification module for obtaining the type of the water body under inspection; a model building module for establishing corresponding composite neural network models for different types of water bodies, which has a good recognition function for water bodies and is very practical in the direction of tracing the source of water pollution.
[0004] In actual production, although the villagers' water usage habits are basically the same, due to the complex components of rural domestic sewage and the band-specific absorbance of different pollutants, previous detection devices have the problem of low accuracy in spectral prediction of water bodies with different components. To solve the above problem, the present invention provides a method for predicting the effluent water quality of rural sewage treatment facilities based on absorbance spectroscopy. Summary of the invention
[0005] The main purpose of the present invention is to predict the effluent quality of rural sewage treatment facilities based on multi-channel data sources, collect water samples from the effluent sampling wells of rural domestic sewage treatment facilities, complete sample water quality detection, organize the detection results into a data frame, and then carry out absorption spectrum simulation water quality model training based on a multi-layer perceptron artificial neural network, and finally evaluate the model effect through test samples. The prediction model obtained by this detection method can effectively judge the sewage treatment effect of rural domestic sewage treatment facilities and provide effective assistance for the operation and management of sewage treatment facilities. The technical solution of the present invention is as follows: A method for predicting effluent quality of rural sewage treatment facilities based on multi-channel data sources, the method comprising the following steps: Step 1, water sample collection and determination: Collect water samples from the outlet wells of rural sewage treatment facilities, preserve the water samples according to routine requirements and conduct water quality testing; Step 2, sample construction: construct a data frame with the water quality test results in step 1, and construct training samples and test samples; Step 3, construct Lasso + multi-layer perceptron artificial neural network to establish a prediction model: use the constructed training samples to train the neural network model to optimize the model parameters and improve the accuracy of the model; Step 4, model training: use the constructed training samples to train the multi-layer perceptron artificial neural network model to optimize the model parameters and improve the accuracy of the model; use the gradient descent optimization algorithm to train the model until the performance of the model reaches the optimal level; Step 5, effect evaluation: Use the test samples to test the trained model to evaluate the performance and accuracy of the model; Complete runoff probability prediction based on rolling decomposition and deep learning.
[0006] Preferably, in step 1, the water quality detection indicators include chemical oxygen demand (CODcr), ammonia nitrogen (NH3), total nitrogen (TN), total phosphorus (TP), ultraviolet visible absorption spectrum (UV-Vis), conductivity, temperature, pH, and oxidation-reduction potential (ORP). Further preferably, in step 1, the conductivity refers to the resistance between two opposite sides of a cube with a side length of 1 cm, and the reciprocal of the resistance is the conductivity, and the unit is μs / cm. Preferably, in step 2, the chemical oxygen demand (CODcr), ammonia nitrogen (NH3), total nitrogen (TN), and total phosphorus (TP) in step 2 are respectively combined with the corresponding ultraviolet-visible absorption spectrum (UV-Vis), conductivity, temperature, pH, and oxidation-reduction potential (ORP) to construct four data frames, and each data frame is divided into training samples and test samples for separate model training, wherein the ratio of training samples to test samples is 7:3. Preferably, in step 3, a least absolute shrinkage and selection operator (Lasso) algorithm and a multilayer perceptron artificial neural network (MLP) model are constructed, which specifically includes the following steps: Step 3.1, use the minimum absolute value convergence and selection operator algorithm (Lasso) to screen the non-zero coefficient characteristic wavelength; Step 3.2, constructing training samples and test samples of non-zero coefficient characteristic wavelength bands; Step 3.3, model training based on multi-layer perceptron artificial neural network; Step 3.4: Use the test samples to evaluate the model’s effectiveness.
[0007] Further preferably, in step 3.1, the minimum absolute value convergence and selection operator algorithm (Lasso) is used to screen the non-zero coefficient characteristic wavelength; In Lasso, the L1-norm of the w vector with the penalty coefficient λ is expressed as a penalty term: , when Cost(T) is the smallest, it needs to satisfy: , the larger λ is, the fewer features are selected. Where: N is the total sample size, x i is the i-th sample data, y i is the i-th output value, where A is a set of basis function matrices, and λ is a regularization parameter used to balance the accuracy of the system and the sparsity of the solution. The larger λ is, the fewer features are selected. Further preferably, in the step 3.2, training samples and test samples of the non-zero coefficient characteristic wavelength band are constructed, and the ratio of training samples to test samples is 7:3. 8. According to the method for predicting the effluent quality of rural sewage treatment facilities based on multi-channel data sources according to claim 1, it is characterized in that in the step 3.3, the multi-layer perceptron artificial neural network includes an input layer, an intermediate hidden layer, and an output layer; the features determined by the above-mentioned Lasso algorithm are used for neural network construction of a prediction model, wherein the feature group X=x1,x2,x3,...xm and label y, wherein x1,x2,x3,...xm are data samples, and y is the output value; For a set of training samples, it is divided into forward propagation weighted sum h, ,in For the corresponding Sum the output results, is the weight coefficient of the i-th data in the j-th layer; The output value of the middle hidden layer neuron is a, , g() represents the activation function, is the weight coefficient corresponding to the i-th eigenvalue of the j-th layer, x ij is the ith eigenvalue of the jth layer input, a j Represents the output value of the jth layer, which is equal to the input value of the next layer of neurons.
[0008] The final output value y of the output layer, , represents the weighted sum of the inputs of the k-layer neurons in the output layer, g() is the activation function, and y=a k is the output value of the kth layer, The activation function g() is described as , where g(h) i Represents the corresponding output value of the i-th element of the activation function input, z i represents the i-th element input to g(), g(h) i is the i-th output, K represents the number of classes, z l represents the input value of the lth category, is a normalization term, expressed as the sum of all output values of K categories;.
[0009] Further preferably, in step 3.3, in the multilayer perceptron, the loss function is used to measure the gap between the predicted result of the model and the actual result. By calculating the gradient and updating the parameters along the gradient direction, the multilayer perceptron can gradually approach the optimal solution, wherein the loss function , In the formula: In the formula: is the predicted value, y is the true output value, W is the sample data, and α is the regularization parameter used to balance the accuracy of the system and the sparsity of the solution.
[0010] By continuously updating the multi-layer perception weights to minimize the loss function, after calculating the loss, the back propagation propagates it from the output layer to the previous layer, providing an update value for each weight parameter to reduce the loss, and finally stops when the improvement in the loss is lower than a small number.
[0011] Preferably, in step 4, constructing a multi-layer perceptron artificial neural network, and establishing a prediction model comprises the following steps: The artificial neural network model was trained using the constructed CODcr and four training samples of UV-Vis, conductivity, temperature, pH, and ORP to optimize the model's iteration times, component size, and loss function termination condition parameters to improve the model's accuracy; the model was trained using the gradient descent optimization algorithm until the model's performance reached the optimal level. The present invention has the following beneficial effects: 1. Through water sampling, the effluent water quality and ultraviolet-visible spectroscopic spectrum of the collected samples are measured, and a method for predicting the effluent water quality of rural sewage treatment facilities based on multi-channel data sources is further constructed according to the above data, so as to realize the rapid detection of the effluent water quality of rural sewage treatment facilities. The components of rural domestic sewage are complex, and the previous detection methods have the problem of low accuracy in spectral prediction of water bodies with different components. The present invention is to detect the effluent water quality of rural domestic sewage treatment facilities, match it with ultraviolet-visible spectrum, conductivity, water temperature, pH, ORP to build a training model, and realize the weight adjustment of multi-feature indicators, which is actually a correlation prediction of rural domestic sewage components.
[0012] 2. The prediction model obtained by the present invention can effectively determine the effluent quality of sewage from rural domestic sewage treatment facilities, and provide assistance for the effluent quality detection of sewage treatment facilities. BRIEF DESCRIPTION OF THE DRAWINGS Figure 1 It is a training process diagram of the present invention; Figure 2 The test results of CODcr, UV-Vis, conductivity, water temperature, pH and ORP of the method of the present invention are shown in FIG. Figure 3 This is a training loss function diagram of CODcr, UV-Vis, conductivity, water temperature, pH, and ORP according to the method of the present invention. DETAILED DESCRIPTION
[0013] The present invention will be further described below in conjunction with embodiments and drawings.
[0014] Embodiment 1 A method for predicting the effluent quality of rural sewage treatment facilities based on multiple data sources comprises the following steps: Step 1, collection of water samples from sewage treatment facilities and testing of water quality; Water samples were collected from 840 rural sewage treatment facilities with a treatment capacity of more than 20 tons per day. Each site was tested four times at different times, totaling 3,360 sets of data. The collected water samples were tested for water quality, CODcr, NH3, TN, TP, and UV-Vis spectra, conductivity, water temperature, pH, and ORP of the collected water samples; Step 2, sample construction; The water quality test results CODcr, NH3, TN, TP and the corresponding UV-Vis, conductivity, water temperature, pH, ORP form a data frame; Table 1 CODcr and absorption spectrum, conductivity, temperature, pH, ORP (partial)
[0015] Step 3, construct a multi-layer perceptron artificial neural network; Step 3.1, prioritize the use of the minimum absolute value convergence and selection operator algorithm (Lasso) to screen the non-zero coefficient characteristic wavelength. The L1-norm of the w vector with the penalty coefficient λ of Lasso is expressed as the penalty term: , when Cost(w) is minimum, it needs to satisfy: , Where: N is the total number of samples, xi is the i-th sample data, yi is the i-th output value, A is a set of basis function matrices, λ is a regularization parameter used to balance the accuracy of the system and the sparsity of the solution, where the larger the λ, the fewer features are selected; Step 3.2, based on step 3.1, complete the construction of non-zero coefficient characteristic wavelength band training samples and test samples, where the ratio of training samples to test samples is 7:3; Step 3.3, performing model training based on a multi-layer perceptron artificial neural network, wherein the multi-layer perceptron artificial neural network includes an input layer, an intermediate hidden layer, and an output layer; The above function determines the features used by the neural network to build a prediction model, where the feature set X=x1,x2,x3,...xm and the label y, where x1,x2,x3,...xm are data samples and y is the output value. A set of training samples is divided into forward propagation weighted sum h, , where h j For the corresponding x j Sum the output results, w ij is the weight of the i-th data in the j-th layer.
[0016] The output value of the hidden layer neuron is a, , g() represents the activation function, w ij is the weight coefficient corresponding to the i-th eigenvalue of the j-th layer, x ij is the ith eigenvalue of the jth layer input, a j The output value of the jth layer is equal to the input value of the next layer of neurons.
[0017] The final output value y of the output layer, , represents the weighted sum of the inputs of the k-layer neurons in the output layer, g() is the activation function, and y=a k is the output value of the kth layer.
[0018] For multi-feature neural networks, a softmax activation function is used, represented by g(h), which is described as , where g(h) i Represents the corresponding output value of the i-th element of the activation function input, z irepresents the i-th element input to g(), g(h) i is the i-th output, K represents the number of classes, z l represents the input value of the lth category, is a normalized term, which is expressed as the sum of all output values of K categories.
[0019] In a multi-layer perceptron, the loss function is used to measure the gap between the model's predicted results and the actual results. By calculating the gradient and updating the parameters along the gradient direction, the multi-layer perceptron can gradually approach the optimal solution. The loss function , where: is the predicted value, y is the true output value, W is the sample data, and α is the regularization parameter used to balance the accuracy of the system and the sparsity of the solution.
[0020] The accuracy of the model is improved by continuously optimizing the model's parameters such as the number of iterations, batch size, and learning rate, and the multi-layer perception weights are updated to minimize the loss function. After calculating the loss, the back propagation propagates it from the output layer to the previous layer, providing an updated value for each weight parameter to reduce the loss, and finally stops when the improvement in the loss is lower than a very small number.
[0021] Step 4: Model training; The constructed training samples are used to train the multilayer perceptron artificial neural network model. The data set is used to train this artificial neural network, where batch_size=128, epochs=100, and lr=0.001. When the training parameters of the network tend to be stable, that is, the loss begins to level off and no longer decreases, it is considered that the current model has converged. The training process diagram is shown in Figure 2.
[0022] Step 5, effect evaluation; In this step, the trained model is tested with test samples to evaluate the performance and accuracy of the model. The prediction is successful if the difference between the predicted data and the true value is within 10%. The accuracy of the final model CODcr and UV-Vis, conductivity, water temperature, pH, ORP is equal to 93.83% ( Figure 2 ), the accuracy of NH3 with UV-Vis, conductivity, water temperature, pH, and ORP is 92.16%, the accuracy of TN with UV-Vis, conductivity, water temperature, pH, and ORP is 96.27%, and the accuracy of TP with UV-Vis, conductivity, water temperature, pH, and ORP is 90.11%, which has reached the standard for industrial application.
[0023] Embodiment 2: The model training steps are the same as steps 1-5 of Example 1.
[0024] Step 6: Take water samples from the outlet well of the Zhangjiaqiao rural sewage treatment station in Jinxing Village, Zhenze, and measure CODcr, NH3, TN, TP, UV-Vis, conductivity, water temperature, pH, and ORP.
[0025] Step 7, input the UV-Vis wavelength band detected in step 6 into the trained model to obtain the predicted effluent water quality, which is CODcr 31, NH3 10.7, TN 34.5, TP 2.71, while the actual CODcr is 30, NH3 9.9, TN 35.1, TP 2.83. The error range of the prediction result is controlled within 10%, and the prediction result is reliable.
[0026] The above embodiments are only preferred technical solutions of the present invention and should not be regarded as limitations of the present invention. The embodiments and features in the embodiments of the present application can be arbitrarily combined with each other without conflict. The protection scope of the present invention shall be the technical solutions recorded in the claims, including the equivalent replacement solutions of the technical features in the technical solutions recorded in the claims. That is, equivalent replacement improvements within this scope are also within the protection scope of the present invention.
Claims
1. A method for predicting the effluent quality of rural sewage treatment facilities based on multiple data sources, It is characterized in that The method comprises the following steps: Step 1, water sample collection and determination: Collect water samples from the outlet wells of rural sewage treatment facilities, preserve the water samples according to routine requirements and conduct water quality testing; Step 2, sample construction: construct a data frame with the water quality test results in step 1, and construct training samples and test samples; Step 3: Construct Lasso+ multi-layer perceptron artificial neural network to establish a prediction model: Use the constructed training samples to train the neural network model; Step 4, model training: Use the constructed training samples to train the multi-layer perceptron artificial neural network model until the performance of the model reaches the optimal level; Step 5, effect evaluation: Use the test samples to test the trained model to evaluate the performance and accuracy of the model; Complete runoff probability prediction based on rolling decomposition and deep learning.
2. According to claim 1, the method for predicting the effluent quality of rural sewage treatment facilities based on multiple data sources, It is characterized in that In step 1, the water quality detection indicators include chemical oxygen demand, ammonia nitrogen, total nitrogen, total phosphorus, ultraviolet visible absorption spectrum, conductivity, temperature, pH, and redox potential.
3. According to claim 2, the method for predicting the effluent quality of rural sewage treatment facilities based on multiple data sources, It is characterized in that In step 1, the conductivity refers to the resistance between two opposite sides of a cube with a side length of 1 cm, and the reciprocal of the resistance is the conductivity.
4. According to claim 2, the method for predicting the effluent quality of rural sewage treatment facilities based on multiple data sources, It is characterized in that In step 2, the chemical oxygen demand, ammonia nitrogen, total nitrogen, and total phosphorus in step 2 are respectively used to construct four data frames with the corresponding ultraviolet-visible absorption spectra, conductivity, temperature, pH, and redox potential. Each data frame is divided into training samples and test samples for separate model training, wherein the ratio of training samples to test samples is 7:
3.
5. According to claim 1, the method for predicting the effluent quality of rural sewage treatment facilities based on multiple data sources, It is characterized in that In step 3, constructing a Lasso+ multi-layer perceptron artificial neural network to establish a prediction model specifically includes the following steps: Step 3.1, use the minimum absolute value convergence and selection operator algorithm Lasso to screen the non-zero coefficient characteristic wavelength; Step 3.2, constructing training samples and test samples of non-zero coefficient characteristic wavelength bands; Step 3.3, model training based on multi-layer perceptron artificial neural network; Step 3.4: Use the test samples to evaluate the model’s effectiveness.
6. The method for predicting the effluent quality of rural sewage treatment facilities based on multiple data sources according to claim 5, It is characterized in that In step 3.1, the minimum absolute value convergence and selection operator algorithm Lasso is used to screen the non-zero coefficient characteristic wavelength; In Lasso, L with penalty coefficient λ 1 The -norm is expressed as a penalty term: , when Cost(T) is the smallest, it needs to satisfy: , Where: N is the total sample size, x i is the i-th sample data, y i is the ith output value, where A is a set of basis function matrices and λ is a regularization parameter used to balance the accuracy of the system and the sparsity of the solution.
7. The method for predicting the effluent quality of rural sewage treatment facilities based on multiple data sources according to claim 5, It is characterized in that In step 3.2, non-zero coefficient characteristic wavelength band training samples and test samples are constructed.
8. The method for predicting the effluent quality of rural sewage treatment facilities based on multiple data sources according to claim 1, It is characterized in that In step 3.3, the multilayer perceptron artificial neural network includes an input layer, an intermediate hidden layer, and an output layer; the features determined by the above Lasso algorithm are used to construct a prediction model using the neural network, wherein the feature group X=x1,x2,x3,...xm and label y, where x1,x2,x3,...xm are data samples and y is the output value; For a set of training samples, it is divided into forward propagation weighted sum h, ,in For the corresponding Sum the output results, is the weight coefficient of the i-th data in the j-th layer; The output value of the middle hidden layer neuron is a, , g() represents the activation function, is the weight coefficient corresponding to the i-th eigenvalue of the j-th layer, is the ith eigenvalue of the jth layer input, a j Indicates the output value of the jth layer, which is equal to the input value of the next layer of neurons; The final output value y of the output layer, , represents the weighted sum of the inputs of the k-layer neurons in the output layer, g() is the activation function, and y=a k is the output value of the kth layer; The activation function g() is described as , where g(h) i Represents the corresponding output value of the i-th element of the activation function input, z i represents the i-th element input to g(), g(h) i is the i-th output, K represents the number of classes, z l represents the input value of the lth category, is a normalized term, which is expressed as the sum of all output values of K categories.
9. The method for predicting the effluent quality of rural sewage treatment facilities based on multiple data sources according to claim 5, It is characterized in that In step 3.3, in the multi-layer perceptron, the loss function , In the formula: In the formula: is the predicted value, y is the true output value, W is the sample data, and α is the regularization parameter used to balance the accuracy of the system and the sparsity of the solution.
10. The method for predicting the effluent quality of rural sewage treatment facilities based on multiple data sources according to claim 1, It is characterized in that In step 4, constructing a multi-layer perceptron artificial neural network, and establishing a prediction model includes the following steps: The artificial neural network model was trained using four training samples of constructed chemical oxygen demand and UV-visible absorption spectrum, conductivity, temperature, pH, and redox potential; the model was trained using the gradient descent optimization algorithm.
Citation Information
Patent Citations
Water quality on-line monitoring system and method combining full spectrum with quick and easily-measured indexes
CN110057761A
Soft measurement method and device for ammonia nitrogen in effluent of agricultural sewage treatment facilities with different process types
CN112784476A
Multi-process type agricultural pollution facility TN treatment effect prediction method and device, and medium
CN112786119A
Method for detecting chemical oxygen demand in water sample
CN116793979A
Water body COD (Chemical Oxygen Demand) detection method based on spectrum technology
CN117033938A
Cited By
Method and equipment for measuring total nitrogen flux in water in real time
CN120468385A
Underground water quality risk identification method and system for environmental safety
CN120911954A
