Method for predicting water quality by combining model fusion algorithm with spectrophotometric method

The integration of a model fusion algorithm with spectrophotometry enhances water quality prediction accuracy by leveraging complex nonlinear relationships, addressing existing inefficiencies in single-algorithm methods.

CN119132444APending Publication Date: 2024-12-13HUAIYIN INSTITUTE OF TECHNOLOGY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311370635.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-20
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

Existing methods for predicting water quality, such as grey prediction, support vector machines, and neural networks, face challenges in accuracy and efficiency, particularly with large-scale training samples and sensitivity to parameter adjustments, making it difficult to effectively monitor and control water pollution.

Method used

A method combining a model fusion algorithm with spectrophotometry, involving data preprocessing, multi-parameter measurement, and integration of SVM, BP neural network, fuzzy neural network, and LSTM networks to predict water quality parameters, utilizing pH, COD, total phosphorus, total nitrogen, ammonia nitrogen, permanganate index, and temperature.

Benefits of technology

Improves prediction accuracy and efficiency by leveraging the complex nonlinear relationships between water quality factors, reducing prediction errors through model fusion, achieving high correlation coefficients and low relative errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119132444A_ABST
    Figure CN119132444A_ABST
Patent Text Reader

Abstract

The invention discloses a method for predicting water quality by combining a model fusion algorithm with a spectrophotometric method, which comprises the following steps of: measuring water quality parameters by using a multi-parameter water quality tester according to the principle of the spectrophotometric method, and measuring seven water quality parameters including COD (Chemical Oxygen Demand), total phosphorus, total nitrogen, ammonia nitrogen, permanganate index, temperature and pH (Potential of Hydrogen) of lake water quality by using the multi-parameter water quality tester and a portable temperature and pH tester. And preprocessing the data by using normalization, smoothing and abnormal value processing methods. Randomly dividing the obtained data set into training data and prediction data, and establishing a data fusion algorithm model; predicting seven water quality parameters of COD, total phosphorus, total nitrogen, ammonia nitrogen, permanganate index, temperature and pH of the training data set by using the trained model, comparing errors of predicted values and true values, and predicting the seven water quality parameters of COD, total phosphorus and the like of the data set by using the model; and comparing the error between the predicted value and the true value. The method can effectively predict water quality pollutants, and has wide application prospects and practical value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to water quality detection, and in particular to a method for predicting water quality by combining a model fusion algorithm with spectrophotometry. Background Art

[0002] With the rapid development of industrialization, agriculture and urbanization in my country, water pollution has become increasingly serious, and has to a certain extent endangered the development of society and people's daily life. Therefore, my country is currently committed to monitoring and treating water quality to alleviate the shortage of water resources and protect human health.

[0003] Due to the complexity and uncertainty of biochemical processes in natural water bodies, water quality change is a dynamic process with typical nonlinear and time-varying characteristics. Predicting water quality change is a challenging problem in environmental research. Artificial neural networks are a powerful tool for dealing with complex interactive problems and are considered to be standard nonlinear estimators. Using neural networks to establish models to predict water quality parameters can not only obtain high-precision prediction data, but also save maintenance and development costs, which is very important for timely monitoring and control of water pollution.

[0004] At present, the main methods for water quality prediction include grey prediction method, artificial neural network and support vector machine. Grey prediction model is mainly used for short-term water quality prediction problems with strong trend and small fluctuation. It can obtain relatively accurate prediction results when there is less data. However, SVM algorithm is difficult to implement for large-scale training samples and is sensitive to parameter adjustment and function selection. Neural network has the advantage of simulating dynamic and nonlinear systems, so it is particularly suitable for simulating complex physical, chemical and biological reaction systems that have not been fully mastered. Summary of the invention

[0005] Purpose of the invention: The purpose of the present invention is to provide a method for predicting water quality by combining a model fusion algorithm with spectrophotometry, thereby improving the prediction accuracy of water pollutants.

[0006] Technical solution: The method for predicting water quality by combining a model fusion algorithm with spectrophotometry described in the present invention comprises the following steps:

[0007] (1) Determine the sampling points and sampling frequency, and collect characteristic water sample information;

[0008] (2) Use a pH meter to measure the temperature and pH of the water sample. The multi-parameter water quality meter uses spectrophotometry to measure the parameters of the water sample in sequence, including COD, total phosphorus, total nitrogen, ammonia nitrogen, and permanganate index;

[0009] (3) In addition to the parameters to be predicted, the remaining six groups of measured parameters are directly used as prediction inputs, including the following situations:

[0010] (a) When COD content is used as output, the content of total phosphorus, total nitrogen, ammonia nitrogen, permanganate index, temperature, and pH are used as input;

[0011] (b) When the total phosphorus content is used as output, the COD, total nitrogen, ammonia nitrogen, permanganate index, temperature, and pH content are used as input;

[0012] (c) When the total nitrogen content is used as output, the COD, total phosphorus, ammonia nitrogen, permanganate index, temperature, and pH content are used as input;

[0013] (d) When the ammonia nitrogen content is used as output, the COD, total phosphorus, total nitrogen, permanganate index, temperature, and pH content are used as input;

[0014] (e) When the permanganate index is used as output, the contents of COD, total phosphorus, total nitrogen, ammonia nitrogen, temperature, and pH are used as input;

[0015] (f) When temperature is used as output, COD, total phosphorus, total nitrogen, permanganate index, ammonia nitrogen, and pH are used as input;

[0016] (g) When pH is used as output, COD, total phosphorus, total nitrogen, permanganate index, ammonia nitrogen, and temperature are used as input;

[0017] A total of seven predictions are required, and the six water quality parameters input each time are preprocessed;

[0018] (4) Establishing a water quality parameter prediction model, randomly selecting a part of the water quality parameters as the training part of the network, and another part as the prediction data of the network, using the six water quality parameters in step (3) as the input data of the network, and the remaining one water quality parameter content as the output data of the network to establish a network model training network;

[0019] (5) Use the trained network model to predict random training data, compare the true value and the predicted value, and output the water quality parameter prediction results;

[0020] (6) Use the trained data fusion model to predict the remaining prediction data multiple times, compare the true value and the predicted value, and output the water quality parameter prediction results.

[0021] The step (2) is specifically:

[0022] (2.1) Measure the COD content in the water quality by using the rapid digestion spectrophotometry method. Measure a certain amount of COD digestion reagent and mix it with the lake water sample. After mixing, put it into the digestion instrument for timed digestion. Put the digested solution into the multi-parameter water quality meter in turn to measure the COD content.

[0023] (2.2) Measure the total phosphorus content in the water quality by using ammonium molybdate spectrophotometry. Measure a certain amount of total phosphorus digestion reagent and mix it with the lake water sample. After mixing, put it into the digestion instrument for timed digestion. After the digestion is completed, put the solution into the multi-parameter water quality meter in turn to measure the total phosphorus content.

[0024] (2.3) Measure the total nitrogen content in the water quality. Use the chromotropic acid spectrophotometry method to accurately measure a certain amount of total phosphorus digestion reagent and mix it with the lake water sample. After mixing, place each reaction tube in turn into a digestion instrument for digestion; after digestion, add the prepared reagent to each reaction tube in turn and shake well; measure the prepared reagent and add it to the prepared sealed colorimetric tube, measure each treated water sample along the wall tube and add it to the colorimetric tube with the prepared reagent, mix well and place it in a water quality analyzer to measure the total nitrogen content;

[0025] (2.4) Measure the ammonia nitrogen content in the water quality by using Nessler's reagent spectrophotometry. Take a certain amount of ammonia nitrogen digestion reagent and mix it with the lake water sample. Shake it well and let it stand. Then put it into the multi-parameter water quality meter to measure the ammonia nitrogen content.

[0026] (2.5) To measure the permanganate index content in water quality, use the spectrophotometric method, measure a certain amount of permanganate index digestion reagent and mix it with the lake water sample, mix it evenly and put it into the digestion instrument for timed digestion; after digestion, add the prepared reagent to each reaction tube in turn, mix it evenly and let it stand, and then put it into the multi-parameter water quality meter in turn to measure the permanganate index content.

[0027] The preprocessing described in step (3) includes smoothing, normalization and outlier processing.

[0028] In the smoothing process, the Lowess smoothing method is used to smooth the data, and x i As variables, and assuming that the data is ordered from small to large, its expression is as follows:

[0029]

[0030] Where Δ=1.0001 max (x i+ -x i ,x i -x i_ ), x i is the variable to be calculated, x j is x i The number of adjacent points contained in the span, w j Yes X i and the weights of all neighboring points contained within the span.

[0031] In the normalization process, the normalization corresponding equation and the anti-normalization equation are respectively:

[0032]

[0033] Y=(Y max -Y min )·X' i +Y min

[0034] In the formula, Y is the normalized data, X is i is the data after smoothing in the previous step, X min and X max are the minimum and maximum values ​​of the data after smoothing, Y min and Y max It is a parameter that can be set by yourself. The default values ​​are -1 and 1.

[0035] The step (4) is specifically:

[0036] (4.1) Initialize the structural parameters of the SVM network;

[0037] (4.2) Take one-third of the water quality parameter values ​​and divide the six water quality parameter values ​​into training set and test set for input;

[0038] (4.3) Use the cross-validation method to determine the parameter penalty factor c and kernel function parameter g;

[0039] (4.4) Based on the optimal parameters, learn the training sample set data;

[0040] (4.5) Use the test sample data set to make predictions and denormalize to obtain the value of another water quality parameter other than the six input water quality parameters, which is the prediction result;

[0041] (4.6) Initialize the structural parameters of the BP neural network;

[0042] (4.7) The input layer receives the values ​​of six water quality parameters and then adjusts the weights;

[0043] (4.8) The input sample signal X i Producing results through the action of weights Subtracting the threshold θ can get the input g of the hidden layer j :

[0044]

[0045] Where W ij is the connection weight of the hidden layer;

[0046] (4.9) Using the input g of the hidden layer j Calling the S function can calculate the output h of the hidden layer j ,

[0047] h j =f(g i )

[0048] The network adaptation function S is

[0049]

[0050] (4.10) Calculate the input M of the nodes in the output layer t ;

[0051]

[0052] (4.11) The input M of the output layer t Call the function to get the output Y of each node in the output layer t ;

[0053] Y t =f(M t )

[0054] (4.12) According to the actual output vector Y of the output layer, Y = (y1, y2, ..., y q ) and the expected output vector O = (o1, o2, ... o q ) can get the error of each node in the output layer

[0055]

[0056] (4.13) Calculate the general error of each node in the hidden layer Use the connection weight V jt , the generalized error d of the output layer t and the output of the hidden layer h j ;

[0057]

[0058] (4.14) Using error And the output correction connection weights V of each node in the hidden layer jt ;

[0059]

[0060] (4.15) Using error And the output correction threshold γ of each node in the hidden layer;

[0061]

[0062] (4.16) Using the error of each node in the hidden layer and the input vector X = (x1, x2, ..., xp ) Correct the connection weight W ij ;

[0063]

[0064] (4.17) Using the error of each node in the hidden layer and the input vector X = (x1, x2, ..., x p ) Modify the connection weight value θ j ;

[0065]

[0066] (4.18) Repeat steps (4.7) to (4.17) until the error value reaches the specified range or the training reaches the specified number of times;

[0067] (4.19) According to the input and output dimensions of the sample, determine the network structure, determine the number of iterations, initialize the fuzzy neural network, and randomly initialize the fuzzy membership function center, width and parameters;

[0068] (4.20) Calculate the membership degree of each input variable xj according to the fuzzy rules;

[0069] (4.21) The membership degrees are fuzzily calculated to match the fuzzy rules;

[0070] (4.22) Calculating the output value of the fuzzy model according to the fuzzy calculation result;

[0071] (4.23) Calculation error;

[0072] (4.24) Correction of neural network coefficients;

[0073] (4.25) Modify the center and width of the membership function;

[0074] (4.26) The output results of the above three networks, namely SVM, BP, and fuzzy neural network, are arranged into a new data set corresponding to the original data;

[0075] (4.27) Input the last part of the original data;

[0076] (4.28) Divide the data into training set and test set;

[0077] (4.29) Initialize the LSTM network model;

[0078] (4.30) LSTM network training is completed;

[0079] (4.31) Training model updates network weight parameters;

[0080] (4.32) Using mean square error as the loss function, the formula is

[0081]

[0082] Where MSE is the mean square error, y i represents the test set output value, represents the output value of the training set, and n represents the total number of output values;

[0083] (4.33) Determine the loss value and iterate until the loss value stabilizes and the test is completed;

[0084] (4.34) Output the predicted value.

[0085] The step (5) specifically comprises: using the training set to predict the COD content in the training set, comparing the true value y of COD with the predicted value, and using the mean square error value, relative error value and correlation coefficient to compare the error between the actual value and the predicted value.

[0086] The step (6) specifically comprises: using the prediction set to predict COD, total phosphorus, total nitrogen, ammonia nitrogen, permanganate index content, pH, and temperature in the prediction set, predicting 7 times in total, comparing the actual value y and the predicted value of COD, total phosphorus, total nitrogen, ammonia nitrogen, permanganate index, pH, and temperature, and using the mean square error value, relative error value, and correlation coefficient to compare the error between the actual value and the predicted value.

[0087] A computer storage medium stores a computer program, which, when executed by a processor, implements the above-mentioned method of predicting water quality by combining a model fusion algorithm with spectrophotometry.

[0088] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for predicting water quality by combining a model fusion algorithm with spectrophotometry is implemented.

[0089] Beneficial effects: Compared with the prior art, the present invention has the following advantages:

[0090] 1. The present invention uses spectrophotometry to detect various parameters of lake water quality, which is more efficient and accurate;

[0091] 2. The present invention uses a machine learning method of a neural network to better reflect the complex nonlinear relationship between various factors and water quality;

[0092] 3. The fusion of four algorithm models reduces the prediction error of a single algorithm, making the prediction more accurate and more convincing;

[0093] 4. The COD, total phosphorus, total nitrogen, ammonia nitrogen, permanganate index content, pH, and temperature in the surface lake water quality will continue to fluctuate. The DBN neural network model used in the present invention can effectively obtain the complex relationship between the water qualities, thereby predicting the COD, total phosphorus, total nitrogen, ammonia nitrogen, permanganate index content, pH, and temperature of the lake with high accuracy and better prediction results. The correlation coefficient of the model for predicting the data is high and the relative error is small. BRIEF DESCRIPTION OF THE DRAWINGS

[0094] Figure 1 is a flowchart of the steps of the method of the present invention;

[0095] Figure 2 A flowchart of the steps of an embodiment of the method of the present invention;

[0096] Figure 3 This is a flow chart of the model fusion algorithm in the present invention. DETAILED DESCRIPTION

[0097] The technical solution of the present invention is further described below in conjunction with the accompanying drawings.

[0098] like Figure 1-2 As shown, a method for predicting water quality by combining a model fusion algorithm with spectrophotometry includes the following steps:

[0099] Step 1: Collect lake water samples, determine the appropriate sampling points and sampling frequency, and strive to obtain the most representative samples at the lowest sampling frequency, which must not only meet the requirements of reflecting water quality conditions, but also be practical. Collect lake water samples at five fixed locations in the lake at 8 am every day, store them in transparent plastic cups and label them separately, and the water samples should not be stored for more than 24 hours.

[0100] Step 2: First use a portable temperature and pH meter to measure the temperature and pH of the water sample, and then use a multi-parameter water quality meter to measure the COD, total phosphorus, total nitrogen, ammonia nitrogen and permanganate index content of the water sample in turn, to obtain 89 sets of data sets D.

[0101]

[0102] The equipment needed for the multi-parameter measurement in step 2 includes a multi-parameter water quality meter, an intelligent multi-parameter digestion instrument, a portable temperature and pH meter, a beaker, several 30mm cuvettes, several 10mm cuvettes, several 150mm sealed test tubes, several 100mm sealed test tubes, several open test tubes, two large and small pipettes, and supporting reagents. The experiment includes the following steps:

[0103] Step 2.1, measure the COD content in the water quality, use the rapid digestion spectrophotometry, and conduct a rapid oxidation-reduction reaction between the water sample and the supporting reagent in the digester. After the reaction, trivalent chromium ions are produced, and their concentration is determined by spectrophotometry. First, turn on the digester and water quality analyzer, select the COD digestion and COD low-range dish mode, prepare several open reaction tubes and place them on the empty cooling tank of the cooling rack. Accurately measure 2.5mL of distilled water and add it to the No. 0 reaction tube, measure 2.5mL of each water sample and add them to other reaction tubes in turn, add 0.7mL of potassium dichromate reagent to each reaction tube in turn, and then add 4.8mL of silver sulfate reagent to the reaction tube in turn, mix well, and put it into the digestion hole for digestion at 165 degrees Celsius for 10 minutes. After the digestion is completed, take it out and place it on the cooling tank for air cooling for 2 minutes, add 2.5mL of distilled water to each reaction tube in turn and mix well, and then water cool for 2 minutes. Pour the solution after water cooling into the corresponding numbered 30mm cuvettes in turn. Cuvette No. 0 is the blank solution. Put it into the colorimetric cell and cover it with a lid. Press the blank key, and then put the remaining solutions into the colorimetric cell in turn to measure the COD content.

[0104] Step 2.2, measure the total phosphorus content in the water quality, using ammonium molybdate spectrophotometry, the phosphorus compounds in the water are converted into orthophosphate under the action of potassium persulfate. Orthophosphate can react with ammonium molybdate and potassium antimony tartrate in an acidic medium to generate phosphomolybdic heteropoly acid. Phosphomolybdic acid can be reduced by ascorbic acid to generate dark phosphomolybdic blue. At a wavelength of 700nm, the absorbance of the sample is measured to obtain the sample concentration. First, turn on the digester switch to select the total phosphorus digestion mode, turn on the water quality analyzer to select the total phosphorus low-range dish mode, prepare several 150mm sealed reaction tubes and place them on the empty cooling tank of the cooling rack. Accurately measure 8mL of distilled water and other water samples and add them to the reaction tubes in turn, add 1mL of potassium persulfate reagent to each reaction tube in turn, tighten the bottle cap and shake the water sample, and place each reaction tube in the digester for digestion at 120 degrees Celsius for 30 minutes. After the digestion is completed, take it out and place it on the cooling tank for air cooling for 2 minutes, and then water cooling for 2 minutes. Then add 1 mL of ascorbic acid solution and 1 mL of molybdate solution reagent, mix well and let stand for 10 minutes. Pour solution No. 0 into a 30 mm cuvette and put it into the measuring instrument for measurement, place a blank sample, and then measure the remaining solutions in turn.

[0105] Step 2.3, measure the total nitrogen content in the water quality, using chromotropic acid spectrophotometry. Under alkaline conditions, potassium persulfate is used as an oxidant. After high temperature and high pressure digestion, all nitrogen-containing compounds are converted into nitrate nitrogen. The remaining potassium persulfate is eliminated by adding excess sodium pyrosulfite. Nitrate-nitrogen reacts with chromotropic acid under strong acidic conditions to form yellow compounds. The absorbance value of the color developing solution is proportional to the total nitrogen content in the water sample. First, turn on the digestion instrument switch to select the total nitrogen digestion mode, turn on the water quality analyzer to select the total nitrogen mode, prepare several 150mm sealed reaction tubes and place them on the empty cooling tank of the cooling rack. Accurately measure 5mL of distilled water and each water sample into the reaction tube, add 2mL of special reagent NTA to each reaction tube in turn, tighten the bottle cap and shake the water sample, and put each reaction tube into the digestion instrument in turn for digestion at 122 degrees Celsius for 40 minutes. After the digestion is completed, place the sample on the cooling rack to air cool for 2 minutes, and then water cool for 2 minutes. After cooling, add 1mL of NTB reagent to each reaction tube and shake well. Prepare several 100mm sealed colorimetric tubes and place them on the test tube rack. Accurately measure 4mL of NTC reagent and add it to the prepared sealed colorimetric tubes. Measure 1mL of each treated water sample and add it to the colorimetric tube with NTC reagent added along the wall. After adding the water sample, tighten the bottle cap immediately, flip and shake well 10 times, put it in the cooling tank, and cool it with water for 10 minutes. After the water cooling is completed, take out each reaction tube from the cooling tank, wipe the tube wall clean, and put it into the water quality analyzer to measure the total nitrogen content.

[0106] Step 2.4, measure the ammonia nitrogen content in the water quality, use Nessler's reagent spectrophotometry, ammonia nitrogen in the form of free ammonia or ammonium ions reacts with Nessler's reagent to form a light reddish brown complex, and the absorbance is measured at a wavelength of 420nm. First, turn on the water quality analyzer and select the ammonia nitrogen mode. Prepare several open reaction tubes and place them on the empty cooling tank of the cooling rack. Accurately measure 10mL of ammonia-free water and other water samples and add them to each reaction tube, add 1mL N3 reagent and 1mL N2 reagent to each reaction tube, shake well and let stand for 10 minutes. Then pour the solution into 10mm cuvettes in turn and put them into the water quality analyzer to measure the ammonia nitrogen concentration of each water sample.

[0107] Step 2.5, measure the permanganate index content in the water quality, use spectrophotometry, use excess potassium permanganate to oxidize the reducing substances in the water under acidic heating conditions, measure the amount of remaining potassium permanganate at a wavelength of 525nm and obtain the permanganate index concentration. First, turn on the digestion instrument and water quality analyzer, prepare several 150mm sealed reaction tubes and place them on the empty cooling tank of the cooling rack. Accurately measure 5mL of distilled water and each water sample into the reaction tube, add 1mL of CM1 reagent to each reaction tube in turn and mix, then add 1mL of CM2 reagent and mix. After tightening the bottle mouth of each reaction tube, place it in the digestion instrument in turn at 105 degrees Celsius for digestion for 32 minutes. After digestion, place each sample on the cooling rack for air cooling for 2 minutes, and then water cooling for 2 minutes. Add 1mL of CM3 reagent to each reaction tube in turn, mix it and let it stand for 2 minutes, then pour the solution into a 30mm cuvette and place it in the water quality analyzer to measure the permanganate index concentration.

[0108] Step 3: Select COD, total phosphorus, total nitrogen, ammonia nitrogen, and permanganate index as prediction inputs, and the prediction set is D p Then the five water quality parameters are preprocessed by smoothing and normalization, and the final data set is D p * .

[0109] The parameter preprocessing in step 3 includes the following methods: smoothing the data using the Lowess smoothing method, setting x i As variables, and assuming that the data is ordered from small to large, its expression is as follows:

[0110]

[0111] Where Δ=1.0001 max (x i+ -x i ,x i -x i_ ), x i is the variable to be calculated, x j is x i The number of adjacent points contained in the span, w j is x i and the weights of all neighboring points contained within the span.

[0112] The seven groups of measured parameters are directly used as prediction inputs, and the seven water quality parameters are preprocessed, that is, smoothing and normalization. The data are normalized to [0, 1]. The corresponding normalization equation and anti-normalization equation are:

[0113]

[0114] Y=(Y max -Ymin )·X' i +Y min

[0115] Where Y is the normalized data, X i is the data after smoothing in the previous step, X min and X max are the minimum and maximum values ​​of the data after smoothing, Y min and Y max It is a parameter that can be set by yourself. The default values ​​are -1 and 1.

[0116] Step 4: Figure 3 As shown, a suitable model fusion algorithm model is established, and the data set D is randomly p * It is divided into 75 training sets and 15 prediction sets. Six of the seven water quality parameters are selected as the input data of the network, and the remaining water quality parameter is predicted as the output data of the network to establish a model training network.

[0117] Step 4.1, initialize the structural parameters of the SVM network;

[0118] Step 4.2, take one-third of the water quality parameter values, and divide the six water quality parameter values ​​of this part into a training set and a test set for input;

[0119] Step 4.3, use the cross-validation method to determine the parameter penalty factor c and kernel function parameter g;

[0120] Step 4.4, learn the training sample set data according to the optimal parameters;

[0121] Step 4.5: Use the test sample data set to make predictions and denormalize to obtain the value of another water quality parameter other than the six input water quality parameters, i.e., the prediction result;

[0122] Step 4.6, initialize the structural parameters of the genetic neural network;

[0123] Step 4.7, the input layer receives the values ​​of six water quality parameters and then adjusts the weights;

[0124] Step 4.8: Input sample signal X i Producing results through the action of weights Subtracting the threshold θ can get the input g of the hidden layer j :

[0125]

[0126] Where W ij is the connection weight of the hidden layer;

[0127] Step 4.9: Using the input g of the hidden layer j Calling the S function can calculate the output h of the hidden layer j ;

[0128] h j =f(g i )

[0129] Step 4.10, calculate the input M of the nodes in the output layer;

[0130]

[0131] Step 4.11: Input M to the output layer t Call the function to get the output Y of each node in the output layer t ;

[0132] Y t =f(M t )

[0133] Step 4.12: According to the actual output vector Y=(y1,y2,…,y q ) and the expected output vector O = (o1, o2, ... o q ) can get the error of each node in the output layer

[0134]

[0135] Step 4.13: Calculate the general error of each node in the hidden layer Use the connection weight V jt , the generalized error d of the output layer t and the output of the hidden layer h j ;

[0136]

[0137] Step 4.14: Use error And the output correction connection weights V of each node in the hidden layer jt ;

[0138]

[0139] Step 4.15: Use error And the output correction threshold γ of each node in the hidden layer;

[0140]

[0141] Step 4.16: Use the error of each node in the hidden layer and the input vector X = (x1, x2, ..., x p) Correct the connection weight W ij ;

[0142]

[0143] Step 4.17: Use the error of each node in the hidden layer and the input vector X = (x1, x2, ..., x p ) Modify the connection weight value θ j ;

[0144]

[0145] Step 4.18: Repeat steps 4.7 to 4.17 until the error value reaches the specified range or the training reaches the specified number of times;

[0146] Step 4.19, determine the network structure of the network according to the input and output dimensions of the sample, determine the number of iterations, initialize the fuzzy neural network, and randomly initialize the center, width and parameters of the fuzzy membership function;

[0147] Step 4.20, calculate the membership degree of each input variable xj according to the fuzzy rule;

[0148] Step 4.21, perform fuzzy calculation on each membership degree to match the fuzzy rules;

[0149] Step 4.22, calculating the output value of the fuzzy model according to the fuzzy calculation result;

[0150] Step 4.23, calculate the error;

[0151] Step 4.24, correct the neural network coefficients;

[0152] Step 4.25, modify the center and width of the membership function;

[0153] Step 4.26, arrange the output results of the above three networks, namely SVM, BP, and fuzzy neural network, into a new data set corresponding to the original data;

[0154] Step 4.27, input the last part of the original data;

[0155] Step 4.28, divide the data into training set and test set;

[0156] Step 4.29, initialize the LSTM network model; Step 4.30 LSTM network completes training;

[0157] Step 4.31, training model updates network weight parameters;

[0158] Step 4.32, use mean square error as the loss function, the formula is

[0159]

[0160] Where MSE is the mean square error, y i represents the test set output value, represents the output value of the training set, and n represents the total number of output values;

[0161] Step 4.33, determine the loss value, iterate until the loss value is stable and the test is completed;

[0162] Step 4.34: Output the predicted value.

[0163] Step 5, use the trained network model to predict the random training data, use the training set to predict the COD, total phosphorus, total nitrogen, ammonia nitrogen, permanganate index content, pH, temperature in the training set, compare the true value y and predicted value of COD, total phosphorus, total nitrogen, ammonia nitrogen, permanganate index, pH, temperature, and use the mean square error value, relative error value and correlation coefficient to compare the error between the actual value and the predicted value. Use the model to predict the training set, and the relative error is controlled within 6%. The trained network has a very good fit to the training data itself, and there is no overfitting phenomenon. The mean square error value between the actual output of the network of the training set and the true value is 0.1050, and the correlation coefficient is 0.9669.

[0164] Step 6, use the trained model fusion algorithm model to predict the rest of the prediction data, use the prediction set to predict COD, total phosphorus, total nitrogen, ammonia nitrogen, permanganate index content, pH, temperature in the prediction set, a total of 7 predictions, compare the COD, total phosphorus, total nitrogen, ammonia nitrogen, permanganate index, pH, temperature real value y and predicted value, use the mean square error value, relative error value and correlation coefficient to compare the error between the actual value and the predicted value. Use the model to conduct 9 experiments on the prediction data. From the 9 experimental data, it can be seen that the correlation coefficient of the model is basically between 0.8-0.95, the relative error is almost controlled within 15% and there is no overfitting phenomenon.

Claims

1. A method for predicting water quality by combining a model fusion algorithm with spectrophotometry, characterized in that: The following steps are involved: (1) Determine the sampling points and sampling frequency, and collect characteristic water sample information; (2) Use a pH meter to measure the temperature and pH of the water sample. The multi-parameter water quality meter uses spectrophotometry to measure the parameters of the water sample in sequence, including COD, total phosphorus, total nitrogen, ammonia nitrogen, and permanganate index; (3) In addition to the parameters to be predicted, the remaining six groups of measured parameters are directly used as prediction inputs, including the following situations: (a) When COD content is used as output, the content of total phosphorus, total nitrogen, ammonia nitrogen, permanganate index, temperature, and pH are used as input; (b) When the total phosphorus content is used as output, the COD, total nitrogen, ammonia nitrogen, permanganate index, temperature, and pH content are used as input; (c) When the total nitrogen content is used as output, the COD, total phosphorus, ammonia nitrogen, permanganate index, temperature, and pH content are used as input; (d) When the ammonia nitrogen content is used as output, the COD, total phosphorus, total nitrogen, permanganate index, temperature, and pH content are used as input; (e) When the permanganate index is used as output, the contents of COD, total phosphorus, total nitrogen, ammonia nitrogen, temperature, and pH are used as input; (f) When temperature is used as output, COD, total phosphorus, total nitrogen, permanganate index, ammonia nitrogen, and pH are used as input; (g) When pH is used as output, COD, total phosphorus, total nitrogen, permanganate index, ammonia nitrogen, and temperature are used as input; A total of seven predictions are required, and the six water quality parameters input each time are preprocessed; (4) Establishing a water quality parameter prediction model, randomly selecting a part of the water quality parameters as the training part of the network, and another part as the prediction data of the network, using the six water quality parameters in step (3) as the input data of the network, and the remaining one water quality parameter content as the output data of the network to establish a network model training network; (5) Use the trained network model to predict random training data, compare the true value and the predicted value, and output the water quality parameter prediction results; (6) Use the trained data fusion model to predict the remaining prediction data multiple times, compare the true value and the predicted value, and output the water quality parameter prediction results.

2. The method for predicting water quality by combining a model fusion algorithm with spectrophotometry according to claim 1, characterized in that: The step (2) is specifically: (2.1) Measure the COD content in the water quality by using the rapid digestion spectrophotometry method. Measure a certain amount of COD digestion reagent and mix it with the lake water sample. After mixing, put it into the digestion instrument for timed digestion. Put the digested solution into the multi-parameter water quality meter in turn to measure the COD content. (2.2) Measure the total phosphorus content in the water quality by using ammonium molybdate spectrophotometry. Measure a certain amount of total phosphorus digestion reagent and mix it with the lake water sample. After mixing, put it into the digestion instrument for timed digestion. After the digestion is completed, put the solution into the multi-parameter water quality meter in turn to measure the total phosphorus content. (2.3) Measure the total nitrogen content in the water quality. Use the chromotropic acid spectrophotometry method to accurately measure a certain amount of total phosphorus digestion reagent and mix it with the lake water sample. After mixing, place each reaction tube in turn into a digestion instrument for digestion; after digestion, add the prepared reagent to each reaction tube in turn and shake well; measure the prepared reagent and add it to the prepared sealed colorimetric tube, measure each treated water sample along the wall tube and add it to the colorimetric tube with the prepared reagent, mix well and place it in a water quality analyzer to measure the total nitrogen content; (2.4) Measure the ammonia nitrogen content in the water quality by using Nessler's reagent spectrophotometry. Take a certain amount of ammonia nitrogen digestion reagent and mix it with the lake water sample. Shake it well and let it stand. Then put it into the multi-parameter water quality meter to measure the ammonia nitrogen content. (2.5) To measure the permanganate index content in water quality, use the spectrophotometric method, measure a certain amount of permanganate index digestion reagent and mix it with the lake water sample, mix it evenly and put it into the digestion instrument for timed digestion; after digestion, add the prepared reagent to each reaction tube in turn, mix it evenly and let it stand, and then put it into the multi-parameter water quality meter in turn to measure the permanganate index content.

3. The method for predicting water quality by combining a model fusion algorithm with spectrophotometry according to claim 1, characterized in that: The preprocessing described in step (3) includes smoothing, normalization and outlier processing.

4. The method for predicting water quality by combining a model fusion algorithm with spectrophotometry according to claim 3, characterized in that: In the smoothing process, the Lowess smoothing method is used to smooth the data, and x i As variables, and assuming that the data is ordered from small to large, its expression is as follows: Where Δ=1.0001 max (x i+ -x i ,x i -x i_ ), x i is the variable to be calculated, x j is x i The number of adjacent points contained in the span, w j is x i and the weights of all neighboring points contained within the span.

5. The method for predicting water quality by combining a model fusion algorithm with spectrophotometry according to claim 3, characterized in that: In the normalization process, the normalization corresponding equation and the anti-normalization equation are respectively: And=(And max -AND min )•X' i +Y min In the formula, Y is the normalized data, X is i is the data after smoothing in the previous step, X min and X max are the minimum and maximum values ​​of the data after smoothing, Y min and Y max It is a parameter that can be set by yourself. The default values ​​are -1 and 1.

6. The method for predicting water quality by combining a model fusion algorithm with spectrophotometry according to claim 1, characterized in that: The step (4) is specifically: (4.1) Initialize the structural parameters of the SVM network; (4.2) Take one-third of the water quality parameter values ​​and divide the six water quality parameter values ​​into training set and test set for input; (4.3) Use the cross-validation method to determine the parameter penalty factor c and kernel function parameter g; (4.4) Based on the optimal parameters, learn the training sample set data; (4.5) Use the test sample data set to make predictions and denormalize to obtain the value of another water quality parameter other than the six input water quality parameters, which is the prediction result; (4.6) Initialize the structural parameters of the BP neural network; (4.7) The input layer receives the values ​​of six water quality parameters and then adjusts the weights; (4.8) The input sample signal X i Producing results through the action of weights Subtracting the threshold θ can get the input g of the hidden layer j : Where W ij is the connection weight of the hidden layer; (4.9) Using the input g of the hidden layer j Calling the S function can calculate the output h of the hidden layer j , h j =f(g i ) The network adaptation function S is (4.10) Calculate the input M of the nodes in the output layer t ; (4.11) The input M of the output layer t Call the function to get the output Y of each node in the output layer t ; Y t =f(M t ) (4.12) According to the actual output vector Y of the output layer, Y = (y1, y2, ..., y q ) and the expected output vector O = (o1, o2, ... o q ) can get the error of each node in the output layer (4.13) Calculate the general error of each node in the hidden layer Use the connection weight V jt , the generalized error d of the output layer t and the output of the hidden layer h j ; (4.14) Using error And the output correction connection weights V of each node in the hidden layer jt ; (4.15) Using error And the output correction threshold γ of each node in the hidden layer; (4.16) Using the error of each node in the hidden layer and the input vector X = (x1, x2, ..., x p ) Correct the connection weight W ij ; (4.17) Using the error of each node in the hidden layer and the input vector X = (x1, x2, ..., x p ) Modify the connection weight value θ j ; (4.18) Repeat steps (4.7) to (4.17) until the error value reaches the specified range or the training reaches the specified number of times; (4.19) According to the input and output dimensions of the sample, determine the network structure, determine the number of iterations, initialize the fuzzy neural network, and randomly initialize the fuzzy membership function center, width and parameters; (4.20) Calculate the membership degree of each input variable xj according to the fuzzy rules; (4.21) The membership degrees are fuzzily calculated to match the fuzzy rules; (4.22) Calculating the output value of the fuzzy model according to the fuzzy calculation result; (4.23) Calculation error; (4.24) Correction of neural network coefficients; (4.25) Modify the center and width of the membership function; (4.26) The output results of the above three networks, namely SVM, BP, and fuzzy neural network, are arranged into a new data set corresponding to the original data; (4.27) Input the last part of the original data; (4.28) Divide the data into training set and test set; (4.29) Initialize the LSTM network model; (4.30) LSTM network training is completed; (4.31) Training model updates network weight parameters; (4.32) Using mean square error as the loss function, the formula is Where MSE is the mean square error, y i represents the test set output value, represents the output value of the training set, and n represents the total number of output values; (4.33) Determine the loss value and iterate until the loss value stabilizes and the test is completed; (4.34) Output the predicted value.

7. The method for predicting water quality by combining a model fusion algorithm with spectrophotometry according to claim 1, characterized in that: The step (5) specifically comprises: using the training set to predict the COD content in the training set, comparing the true value y of COD with the predicted value, and using the mean square error value, relative error value and correlation coefficient to compare the error between the actual value and the predicted value.

8. The method for predicting water quality by combining a model fusion algorithm with spectrophotometry according to claim 1, characterized in that: The step (6) specifically comprises: using the prediction set to predict COD, total phosphorus, total nitrogen, ammonia nitrogen, permanganate index content, pH, and temperature in the prediction set, predicting 7 times in total, comparing the actual value y and the predicted value of COD, total phosphorus, total nitrogen, ammonia nitrogen, permanganate index, pH, and temperature, and using the mean square error value, relative error value, and correlation coefficient to compare the error between the actual value and the predicted value.

9. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for predicting water quality by combining a model fusion algorithm with spectrophotometry as described in any one of claims 1 to 8 is implemented.

10. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, it implements a method for predicting water quality by combining a model fusion algorithm with spectrophotometry as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Method for predicting water quality COD (Chemical Oxygen Demand) by combining fuzzy neural network with spectrophotometric method

    CN113433086A

  • Method for predicting water quality through combination of DBN algorithm and spectrophotometric method

    CN116818692A