Water quality pollutant prediction method based on water transmission spectrum

The BP neural network is trained by water transmission spectrum combined with nuclear principal component analysis and improved particle swarm optimization algorithm, which solves the rapid accuracy of nitrite and BOD concentration detection in water, and achieves simplified operation and efficient detection.

CN117079735BActive Publication Date: 2025-09-05XI'AN PETROLEUM UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311036754.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-17
Publication Date
2025-09-05
Estimated Expiration
2043-08-17

AI Technical Summary

Technical Problem

The prior art is difficult to achieve rapid and accurate detection of nitrite and biochemical oxygen demand (BOD) concentrations in water, and the operation is cumbersome and susceptible to environmental factors.

Method used

The BP neural network model is trained based on water transmission spectrum, combined with nuclear principal component analysis and improved particle swarm optimization algorithm, and nitrite and BOD concentration prediction are carried out, and the optimization model parameters are dynamically updated through adaptive learning factor and inertial weight update, particle diversity guidance strategy and learning rate dynamic update.

Benefits of technology

It realizes rapid and accurate detection of water quality pollutants, simplifies operation, reduces sample quantity, reduces the influence of environmental factors, and improves detection efficiency and feasibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117079735B_ABST
    Figure CN117079735B_ABST
Patent Text Reader

Abstract

The method for predicting water quality pollutants based on water body transmission spectrum includes the following steps: S1: preparing measurement solution: collecting water samples to obtain a total sample volume; S2: acquiring raw transmission spectrum data: scanning the pollutant standard solution in the total sample volume in S1 using a spectrometer to obtain raw transmission spectrum data; S3: preprocessing the spectrum data: performing preprocessing operations on the raw transmission spectrum data in S2; S4: selecting the number of principal components: performing data dimension reduction on the preprocessed spectrum data and selecting an appropriate number of principal components; S5: establishing a concentration prediction model; S6: verifying the concentration prediction model: importing nitrite and BOD concentration data into the established prediction model to verify the stability and prediction performance of the model; S7: predicting the nitrite and BOD concentrations in the solution sample. The present invention can quickly and accurately predict water quality pollutants and improve the efficiency and feasibility of water environment 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 nitrite and biochemical oxygen demand (BOD) content prediction in water bodies, and in particular to a water quality pollutant prediction method based on water body transmission spectrum. Background Art

[0002] Nitrite and BOD are two common pollutants in water bodies. The concentrations of nitrite and BOD can directly reflect the health of the water body.

[0003] At present, spectrophotometry, chemical power generation, electrochemiluminescence and chromatography are mainly used to detect the concentration of nitrite in water. Spectrophotometry is a method that uses nitrite to react with a certain reagent to generate a compound with a specific color, and then the absorbance of the solution is measured by a photometer to determine the concentration of nitrite. Five-day biochemical oxygen demand (BOD5), supplementary biochemical oxygen demand (BODs) and respiration are mainly used to detect the concentration of BOD in water. BOD5 is calculated by placing a water sample with an appropriate amount of microbial inoculum in a sealed container at a certain temperature, and then measuring the difference in dissolved oxygen concentration at the beginning and end of 5 days to calculate the BOD value. However, these detection methods have problems such as being unsuitable for online monitoring, high technical requirements, long operation time, being easily affected by other factors in the measurement environment, and cumbersome operation. They are difficult to meet the needs of accurately and quickly detecting the concentrations of nitrite and BOD in pollutants in water. Summary of the Invention

[0004] In order to overcome the defects of the above-mentioned prior art, the purpose of the present invention is to provide a water quality pollutant prediction method based on water body transmission spectrum, which is simple, real-time, efficient and green, can quickly and accurately predict water quality pollutants, and improve the efficiency and feasibility of water environment monitoring.

[0005] In order to achieve the above object, the technical solution adopted by the present invention is:

[0006] The method for predicting water pollutants based on water body transmission spectrum includes the following steps:

[0007] S1: Prepare the measurement solution: measure samples with different nitrate concentrations and different BOD concentrations to obtain the total sample volume;

[0008] S2: Raw transmission spectrum data acquisition: Use a spectrometer to scan the pollutant standard solution in the total sample volume in S1 to obtain raw transmission spectrum data;

[0009] S3: Spectral data preprocessing: preprocessing the original transmission spectrum data in S2;

[0010] S4: Selection of the number of principal components: Perform data dimension reduction on the preprocessed spectral data and select the appropriate number of principal components;

[0011] S5: Establish a concentration prediction model:

[0012] An improved particle swarm optimization algorithm is used to optimize the weight and bias combinations required for BP neural network model training on the spectral data after spectral preprocessing and kernel principal component analysis. The improved BP neural network model is used as a single hidden layer neural network prediction model for nitrite and BOD concentrations in water.

[0013] S6: Concentration prediction model verification: Import nitrite and BOD concentration data into the established prediction model to verify the stability and prediction performance of the model;

[0014] S7: Use the constructed BP neural network model under the improved particle swarm optimization algorithm to predict the concentration of nitrite and BOD in the solution sample.

[0015] In S1, the nitrite concentrations are 0.02, 0.04, 0.06, 0.08, 0.10, 0.12, 0.14, 0.16, 0.18 and 0.20 mg·L -1 , the BOD concentrations are 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9 and 1.0 mg·L -1 of the standard solution.

[0016] In S2, within the total sample volume, a micro-fiber spectrometer is used to collect spectral data of the prepared solution, and each sample is scanned repeatedly multiple times. The slits of the spectrometer are 10, 25, 50, 100, and 200 μm, and 10 μm is selected as the slit value of the present invention. The scanning spectrum range is 181.1 to 1002.4 nm, and the spectral data obtained by the scan is converted into corresponding spectral transmittance values ​​using whiteboard correction. The whiteboard correction calculation formula is shown in formula (1):

[0017] M C =M0 / M w (1)

[0018] Where M0 is the original projection spectrum data; M w This is whiteboard data.

[0019] In the step S3, first, the collected spectral data is normalized by maximum and minimum normalization, and then the normalized data is subjected to mean centering to eliminate data deviation.

[0020] Unify the original transmission spectrum data to the same dimension and center point position;

[0021] The calculation of the maximum and minimum normalization is shown in formula (2):

[0022]

[0023] Where x′ represents the value of a single data after maximum and minimum normalization, x is the original value of the data, and x min Indicates the minimum value of the column where the data is located, x max Indicates the maximum value of the column where the data is located;

[0024] The calculation of mean centering is shown in formula (3):

[0025]

[0026] x″ represents the value of a single data after mean centering, x r is the original value of the data, x mean Indicates the average value of the column where the data is located, x mean Indicates the average value of the column where the data is located, x std Indicates the standard deviation of the column where the data is located.

[0027] In S4, the kernel principal component analysis (KPCA) method is used to achieve data dimensionality reduction. The KPCA method includes the following steps:

[0028] (1) Data preparation: KPCA operation is performed on the transmission spectrum data after maximum and minimum normalization and mean centering.

[0029] (2) Kernel function selection: Select an appropriate kernel function and choose a linear kernel function to perform inner product calculation in the original feature space to map the original transmission spectrum data into a higher-dimensional feature space;

[0030] (3) KPCA calculation: KPCA calculation is performed on the transmission spectrum data using a kernel function; KPCA maps the data to a higher-dimensional space and calculates the eigenvectors of the covariance matrix, i.e., the number of principal components;

[0031] (4) Eigenvalue analysis: Calculate the variance influence rate of the principal components by the size of the eigenvalue to determine which principal components contain the most informative features;

[0032] (5) Principal component selection: Select the appropriate number of principal components based on the set threshold or variance influence rate. Usually, principal components with higher variance influence rates are selected to retain more information while achieving data dimensionality reduction.

[0033] In S5, the adaptive learning factor and inertia weight update formula and the particle swarm optimization algorithm under the particle diversity guidance strategy optimization are used to optimize the weight and bias combination required for BP neural network model training; the improved BP neural network model is used as the prediction model for nitrite and BOD concentration in water;

[0034] (1) Adaptive learning factor and inertia weight update formula method:

[0035] The individual learning factor c1, social learning factor c2 and inertia weight ω in the particle swarm optimization algorithm are changed from fixed constants to adaptively adjust and update their own sizes according to the gap between the fitness value of the particle and the average fitness value of all particles. In different situations, the global search ability of the particles is enhanced or the convergence speed of the particles is accelerated, making the particle swarm optimization algorithm more stable and efficient when searching for the best parameter combination. The update formulas of ω, c1 and c2 are shown in Equations (4), (5), (6) and (7).

[0036]

[0037]

[0038]

[0039]

[0040] Among them, ω max 、ω min 、 and represents the maximum and minimum values ​​of the inertia weight ω, the individual learning factor c1, and the social learning factor c2, f i Indicates the function fitness value of the current particle, f min Represents the minimum function fitness value in the particle swarm, which is equivalent to the global optimal particle in the particle swarm at this time, f avg represents the average function fitness of all particles in the particle swarm, k1, k2 and k3 are random numbers in the range of 0 to 1;

[0041] (2) Particle diversity guidance strategy method:

[0042] When the particle swarm algorithm is searching for the best parameter combination, it is easy to fall into the local optimal solution. In order to make the particles better search for the best parameter combination in the search space, the particle diversity guidance strategy is introduced. When updating the speed of each particle in the particle swarm algorithm, the adaptive learning factor and inertia weight are first updated according to the relationship between the minimum function fitness value, the average function fitness value and the current particle fitness value in the entire particle swarm. Then, the diversity value of the particle swarm is calculated and the dispersion degree of the particles is judged according to the value. Different particle speed updates are selected under different dispersion degrees to avoid the situation of local optimal solution. Among them, formula (8) is the calculation formula of the size of the particle swarm diversity value, and formula (9) is the speed update formula of the particles under different conditions.

[0043]

[0044] Where N is the number of particles in the population, d is the diagonal length of the search space, representing the size of the search area, is the average position of all particles;

[0045]

[0046] where d high is the upper bound of diversity value, d low is the lower bound of the diversity value, r1 and r2 are random numbers in the range of 0 to 1;

[0047] (3) Evaluation index of the combination quality of particle swarm optimization algorithm:

[0048] The mean square error (MSE) is used as the loss function to evaluate the quality of the output results of the weight and bias combination in the BP neural network using the improved particle swarm optimization algorithm under the adaptive learning factor and inertia weight update formula combined with the particle diversity guidance strategy. The weight and bias combination of the BP neural network refers to the set of weight and bias parameters of each neuron connection in the neural network. In the BP neural network, the connection between neurons is represented by weights. Each connection has a corresponding weight, which is used to adjust the importance of the input signal. The weight determines the degree of transmission and processing of the input signal in the neural network. The larger the weight, the greater the influence of the input signal of the connection on the neuron output. The bias is an additional parameter of the neuron, which is used to adjust the activation threshold of the neuron. By adjusting the bias value, the activation state and output of the neuron can be changed. The calculation formula of MSE is shown in formula (10).

[0049]

[0050] where y i Indicates the true value of nitrite and BOD concentration, Indicates the predicted value generated by BP neural network concentration prediction using the optimal weight and bias combination currently output by the particle swarm algorithm;

[0051] The closer the mean square error MSE is to 0, the better the algorithm effect is;

[0052] (4) Dynamic update strategy of learning rate;

[0053] After optimizing the weight and bias combination of the BP neural network model by using the adaptive learning factor and inertia weight update formula and the particle swarm algorithm under the particle diversity guidance strategy, the optimal value of the output is used as the initial weight and bias value of the BP neural network to train the concentration prediction model; in order to improve the efficiency of BP neural network training, a dynamic update strategy of the learning rate is introduced; the learning rate is an important parameter for controlling the adjustment amplitude of the weight, and too large or too small learning rate may lead to poor training effect; this strategy is introduced into the BP neural network model, so that the learning rate dynamically updates itself according to the change value of the loss function at the current moment and the change value of the loss function at the previous moment, avoiding deviation of the model training result due to too large or too small learning rate, thereby making the neural network model more efficient and accurate. The dynamic update formula of the learning rate is shown in Equation (11) and Equation (12).

[0054] r=r·(1.5-sigmoid(f t -f t-1 )) (11)

[0055]

[0056] Among them, r is the learning rate, f t -f t-1 Represents the change in the loss function between time t and the previous time;

[0057] (5) Evaluation indicators of the quality of BP neural network model prediction results:

[0058] The BP neural network model was used as the prediction model for nitrite and BOD concentration in water bodies. The single hidden layer neural network was trained using the leave-one-out cross-validation method to construct the BP-ANN model. The coefficient of determination (R 2 ), root mean square error (RMSE) and mean absolute error (MAE) values ​​are used to judge the performance of the BP neural network model in predicting the sample; 2 The calculation formulas of RMSE and MAE are shown in formula (13), formula (14) and formula (15);

[0059]

[0060] where y irepresents the true value, represents the predicted value, represents the average value of the true observation value, SSR is the regression sum of squares, SSE is the residual sum of squares; SST is the total deviation sum of squares;

[0061]

[0062] Where n represents the number of samples, y i represents the true value, represents the predicted value;

[0063]

[0064] Where n represents the number of samples, y i represents the true value, represents the predicted value;

[0065] The closer the root mean square error RMSE and mean absolute error MAE are to 0, the better the model fitting effect is and the higher the prediction accuracy of the data; the determination coefficient R 2 The closer it is to 1, the better the model fits the observed data.

[0066] Beneficial effects of the present invention:

[0067] 1. The present invention uses water body transmission spectrum to establish a water quality pollutant prediction model. Based on the preprocessing of the original transmission spectrum data of water quality pollutants and the kernel principal component analysis operation, the concentration content of pollutants is predicted by combining the adaptive learning factor and inertia weight update formula and the particle swarm optimization algorithm under the particle diversity guidance strategy optimization and the BP neural network model under the learning rate dynamic update strategy optimization. It has the advantages of no sample loss, simple operation, short time consumption, high stability and no pollution.

[0068] 2. The method of detecting the concentration of pollutants in water bodies of the present invention can establish a prediction model by analyzing the transmission spectrum, thereby making the detection more accurate, rapid, simple, efficient, requiring fewer samples, and less susceptible to environmental factors. BRIEF DESCRIPTION OF THE DRAWINGS

[0069] Figure 1 It is an operation flow chart of the present invention.

[0070] Figure 2 This is the original transmission spectrum of nitrite.

[0071] Figure 3 This is the original transmission spectrum of BOD.

[0072] Figure 4 This is the spectral data after nitrite pretreatment operation.

[0073] Figure 5 This is the spectral data diagram after BOD pretreatment operation.

[0074] Figure 6 Schematic diagram of the variance influence rate curve of the main components of nitrite and BOD.

[0075] Figure 7 Schematic diagram of the nitrite and BOD fitness change curve.

[0076] Figure 8 Schematic diagram of the prediction results of nitrite concentration in water bodies.

[0077] Figure 9 Schematic diagram of water BOD concentration prediction results. DETAILED DESCRIPTION

[0078] The present invention will be described in further detail below with reference to the accompanying drawings.

[0079] Example 1

[0080] like Figure 1 As shown in FIG, the water quality pollutant prediction method based on water body transmission spectrum includes the following steps:

[0081] S1. Prepare the measuring solution: Collect water samples to obtain the total sample volume and collect different concentrations of nitrite (0.02, 0.04, 0.06, 0.08, 0.10, 0.12, 0.14, 0.16, 0.18 and 0.20 mg·L -1 ) and BOD (0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9 and 1.0 mg·L -1 ) standard solution.

[0082] S2. Collection of original transmission spectrum data: Use a micro-fiber optic spectrometer to scan the pollutant standard solution within the total sample volume in S1 to obtain original transmission spectrum data; within the total sample volume, use a spectrometer to collect spectral data of the prepared solution, repeatedly scan each sample 10 times, with a spectrometer slit of 10 μm and a scanning spectral range of 181.1 to 1002.4 nm. Use a whiteboard correction to convert the scanned spectral data into corresponding spectral transmittance values.

[0083] By repeatedly scanning each sample 10 times, the impact of random noise caused by measuring equipment or environmental factors on the results can be reduced; selecting a slit of 10μm can improve the spectral resolution, making the analysis of the sample's spectral characteristics more accurate and detailed; the scanning spectral range is 181.1~1002.4nm, covering a wide wavelength range, ensuring comprehensive measurement of the sample's absorption or transmission across the entire visible light and near-ultraviolet spectrum; using whiteboard correction can eliminate fluctuations in light source intensity and background noise in the optical path during the measurement process, thereby improving the accuracy and reliability of the measurement results.

[0084] The calculation formula for whiteboard correction is shown in formula (1):

[0085] M C =M0 / M w (1)

[0086] Where M0 is the original spectral data; M w This is whiteboard data.

[0087] Figure 2 、 Figure 3 They are the original transmission spectrum data of nitrite and BOD respectively.

[0088] S3, spectral data preprocessing: preprocessing operations are performed on the original transmission spectrum data in S2; spectral data preprocessing is performed by combining maximum and minimum normalization and mean centering to unify the spectral data to the same dimension and center point position. Figure 4 、 Figure 5 Spectra of nitrite and BOD raw spectral data after preprocessing.

[0089] The calculation of maximum and minimum normalization is shown in formula (2):

[0090]

[0091] Where x′ represents the value of a single data after maximum and minimum normalization, x is the original value of the data, and x min Indicates the minimum value of the column where the data is located, x max Indicates the maximum value of the column where the data is located.

[0092] The calculation of mean centering is shown in formula (3):

[0093]

[0094] Where x′ represents the value of a single data after mean centering, x is the original value of the data, and x mean Indicates the average value of the column where the data is located, x std Indicates the standard deviation of the column where the data is located.

[0095] S4. Principal Component Number Selection: Perform data dimensionality reduction on the spectral data and select an appropriate number of principal components. Use kernel principal component analysis (KPCA) to map the data into a higher-dimensional feature space. Then, perform data dimensionality reduction by solving for the principal components in the higher-dimensional space. By calculating the variance influence of the principal components, select an appropriate number of principal components for model training. Table 6 shows the contribution rate of each principal component after KPCA dimensionality reduction of nitrite and BOD spectral data.

[0096] S5. Establish a concentration prediction model:

[0097] An improved particle swarm optimization algorithm is used to optimize the weight and bias combinations required for BP neural network model training on the spectral data after spectral preprocessing and kernel principal component analysis. The improved BP neural network model is used as a single hidden layer neural network prediction model for nitrite and BOD concentrations in water.

[0098] (1) Adaptive learning factor and inertia weight update formula method:

[0099] This method introduces a new approach that changes the individual learning factor c1, social learning factor c2, and inertia weight ω in the particle swarm optimization algorithm from fixed constants to adaptively adjust and update their own sizes based on the gap between the particle's fitness value and the average fitness value of all particles. This method enhances the particle's global search capability or accelerates its convergence speed in different situations, making the particle swarm optimization algorithm more stable and efficient when searching for the optimal parameter combination. The update formulas for ω, c1, and c2 are shown in Equations (4), (5), (6), and (7).

[0100]

[0101]

[0102]

[0103]

[0104] Among them, ω max 、ω min 、 and represents the maximum and minimum values ​​of the inertia weight ω, the individual learning factor c1, and the social learning factor c2, f i Indicates the function fitness value of the current particle, f min Represents the minimum function fitness value in the particle swarm, which is equivalent to the global optimal particle in the particle swarm at this time, f avgrepresents the average fitness value of all particles in the particle swarm, and k1, k2, and k3 are random numbers in the range of 0 to 1.

[0105] (2) Particle diversity guidance strategy method:

[0106] When searching for the best parameter combination, the particle swarm algorithm is prone to falling into the local optimal solution. In order to allow particles to better find the optimal parameter combination in the search space, a particle diversity guidance strategy is introduced. By calculating the diversity value of the particle swarm and judging the dispersion of the particles based on this value, different particle speed updates are selected under different dispersion levels to avoid the local optimal solution. Among them, formula (8) is the calculation formula for the size of the particle swarm diversity value, and formula (9) is the speed update formula for particles under different conditions.

[0107]

[0108] Where N is the number of particles in the population, d is the diagonal length of the search space, representing the size of the search area, is the average position of all particles.

[0109]

[0110] where d high is the upper bound of diversity value, d low is the lower bound of the diversity value, r1 and r2 are random numbers in the range of 0 to 1.

[0111] (3) Evaluation index of the combination quality of particle swarm optimization algorithm:

[0112] The mean square error (MSE) is used as the loss function to evaluate the quality of the improved particle swarm optimization algorithm for the weight and bias combination in the BP neural network. The calculation formula of MSE is shown in formula (10).

[0113]

[0114] where y i represents the true value, Represents the predicted value.

[0115] The closer the mean square error MSE is to 0, the better the algorithm effect is;

[0116] (4) Learning rate dynamic update strategy

[0117] This strategy is introduced into the BP neural network model, so that the learning rate can be dynamically updated according to the change value of the loss function at the current moment and the change value of the loss function at the previous moment, avoiding the deviation of the model training results due to the learning rate being too large or too small, thereby making the neural network model more efficient and accurate. The dynamic update formulas of the learning rate are shown in Equation (11) and Equation (12).

[0118] r=r·(1.5-sigmoid(f t -f t-1 )) (11)

[0119]

[0120] Among them, r is the learning rate, f t -f t-1 Represents the change in the loss function between time t and the previous time.

[0121] (5) Evaluation index of the quality of BP neural network model prediction results:

[0122] The BP neural network model was used as the prediction model for nitrite and BOD concentration in water bodies. The single hidden layer neural network was trained using the leave-one-out cross-validation method to construct the BP-ANN model. The coefficient of determination (R 2 ), root mean square error (RMSE) and mean absolute error (MAE) values ​​are used to judge the performance of the BP neural network model in predicting the sample. 2 The calculation formulas of , RMSE, and MAE are shown in Equations (13), (14), and (15).

[0123]

[0124] where y i represents the true value, represents the predicted value, represents the mean of the true observations, SSR is the regression sum of squares, SSE is the residual sum of squares, and SST is the total sum of squares.

[0125]

[0126] Where n represents the number of samples, y i represents the true value, Represents the predicted value.

[0127]

[0128] Where n represents the number of samples, y i represents the true value, Represents the predicted value.

[0129] The closer the root mean square error RMSE and mean absolute error MAE are to 0, the better the model fitting effect is and the higher the prediction accuracy of the data; the determination coefficient R 2 The closer it is to 1, the better the model fits the observed data.

[0130] The parameter settings for optimizing the weight and bias combination required for BP neural network model training using the improved particle swarm optimization algorithm are shown in Table 1.

[0131] Table 1 Parameter settings of improved particle swarm optimization algorithm

[0132]

[0133] Different settings of the number of particles and the number of iterations will have a significant impact on the experimental results. Therefore, the present invention selects different numbers of particles for different numbers of iterations and then selects the appropriate number of particles and iterations according to the accuracy of the fitness function value output of the final result to optimize the optimal weight and bias combination. The comparison of the output results of the loss function value of the number of particles and the number of iterations is shown in Table 2.

[0134] Table 2 Comparison of loss function output results for number of particles and number of iterations

[0135]

[0136] As shown in Table 2, when the improved particle swarm optimization algorithm selects 100 particles for 30 iterations to optimize the weight and bias combination required for BP neural network model training, the nitrite loss function value is 0.000034400 and the BOD loss function value is 0.001307748. According to the principle that the smaller the loss function value, the better the effect, the model has the best effect at this time. When 100 particles are selected for 30 iterations, the change curves of the loss functions of nitrite and BOD are as follows: Figure 7 shown.

[0137] The parameter settings when using the improved BP neural network model as the prediction model for nitrite and BOD concentrations in water bodies are shown in Table 3.

[0138] Table 3 Improved BP neural network parameter settings

[0139]

[0140] S6. Concentration prediction model verification: Import the data into the established prediction model to verify the model's stability and prediction performance. Import the spectral data sets of nitrite and COD into the established prediction model to verify the model's stability and prediction performance. Figure 8 、 Figure 9The following table shows the prediction effect of the prediction model on the concentration of nitrite and BOD in water pollutants. Table 4 shows the determination coefficient R of the prediction model for the prediction results of the two substances. 2 , RMSE and MAE. The closer the RMSE and MAE are to 0, the greater the coefficient of determination R 2 The closer it is to 1, the better the model fits the observed data. The results show that it is effective to use the BP neural network (IPSO-BPNN) model under the improved particle swarm optimization algorithm to establish a model for analyzing the nitrite and BOD concentrations in water based on water transmittance spectrum data.

[0141] Table 4 Determination coefficient R of predicted data 2 , root mean square error RMSE and mean absolute error MAE values

[0142]

[0143] This method uses a modified particle swarm optimization algorithm combined with a neural network model to detect water pollutant concentrations using water transmission spectrum data. The model first optimizes the original particle swarm optimization algorithm using an adaptive learning factor, an inertia weight update formula, and a particle diversity guidance strategy. The optimized particle swarm algorithm is then used to optimize the network weight and bias combinations required for BP neural network training. Finally, a BP neural network algorithm using a dynamic learning rate update strategy is used to construct a concentration prediction model.

[0144] The above embodiments are only for illustrating the technical idea of ​​the present invention and cannot be used to limit the protection scope of the present invention. Any changes made on the basis of the technical solution in accordance with the technical idea proposed by the present invention shall fall within the protection scope of the present invention.

Claims

1. A water pollutant prediction method based on water body transmission spectrum, characterized in that: The following steps are included: S1: Prepare the measurement solution: measure samples with different nitrate concentrations and different BOD concentrations to obtain the total sample volume; S2: Raw transmission spectrum data acquisition: Use a spectrometer to scan the pollutant standard solution in the total sample volume in S1 to obtain raw transmission spectrum data; S3: Spectral data preprocessing: preprocessing the original transmission spectrum data in S2; S4: Selection of the number of principal components: Perform data dimension reduction on the preprocessed spectral data and select the number of principal components; S5: Establish a concentration prediction model: An improved particle swarm optimization algorithm is used to optimize the weight and bias combinations required for BP neural network model training on the spectral data after spectral preprocessing and kernel principal component analysis. The improved BP neural network model is used as a single hidden layer neural network prediction model for nitrite and BOD concentrations in water. The improved particle swarm optimization algorithm includes: The individual learning factor c1, social learning factor c2 and inertia weight ω in the particle swarm algorithm are changed from fixed constants to adaptively adjust and update their own sizes according to the gap between the fitness value of the particle and the average fitness value of all particles. In different situations, the global search ability of the particles is enhanced or the convergence speed of the particles is accelerated, making the particle swarm optimization algorithm more stable and efficient when searching for the best parameter combination. The update formulas of ω, c1 and c2 are shown in Equations (4), (5), (6) and (7). Among them, ω max 、ω min 、 and represents the maximum and minimum values ​​of the inertia weight ω, the individual learning factor c1, and the social learning factor c2, f i Indicates the function fitness value of the current particle, f min Represents the minimum function fitness value in the particle swarm, which is equivalent to the global optimal particle in the particle swarm at this time, f avg represents the average function fitness of all particles in the particle swarm, k1, k2 and k3 are random numbers in the range of 0 to 1; When updating the speed of each particle in the particle swarm algorithm, the adaptive learning factor and inertia weight are first updated according to the relationship between the minimum function fitness value, the average function fitness value and the current particle fitness value in the entire particle swarm. Then, the diversity value of the particle swarm is calculated and the dispersion degree of the particles is judged according to the value. Different particle speed updates are selected under different dispersion degrees to avoid the occurrence of local optimal solutions. Among them, formula (8) is the calculation formula for the size of the particle swarm diversity value, and formula (9) is the speed update formula for particles under different conditions. Where N is the number of particles in the population, d is the diagonal length of the search space, representing the size of the search area, is the average position of all particles; where d high is the upper bound of diversity value, d low is the lower bound of the diversity value, r1 and r2 are random numbers in the range of 0 to 1; The improved BP neural network model includes: After optimizing the weight and bias combination of the BP neural network model by using the adaptive learning factor and inertia weight update formula and the particle swarm algorithm under the particle diversity guidance strategy, the optimal value of the output is used as the initial weight and bias value of the BP neural network to train the concentration prediction model; this strategy is introduced into the BP neural network model, so that the learning rate is dynamically updated according to the change value of the loss function at the current moment and the change value of the loss function at the previous moment. The dynamic update formula of the learning rate is shown in Equation (11) and Equation (12); r=r·(1.5-sigmoid(f t -f t-1 )) (11) Among them, r is the learning rate, f t -f t-1 Represents the change in the loss function between time t and the previous time; S6: Concentration prediction model verification: Import nitrite and BOD concentration data into the established prediction model to verify the stability and prediction performance of the model; S7: Use the constructed BP neural network model under the improved particle swarm optimization algorithm to predict the concentration of nitrite and BOD in the solution sample.

2. The method for predicting water pollutants based on water transmission spectrum according to claim 1, characterized in that: In S1, the nitrite concentrations are 0.02, 0.04, 0.06, 0.08, 0.10, 0.12, 0.14, 0.16, 0.18 and 0.20 mg·L -1 , the BOD concentrations are 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9 and 1 mg·L -1 of the standard solution.

3. The method for predicting water pollutants based on water transmission spectrum according to claim 1, characterized in that: In S2, within the total sample volume, a micro-fiber spectrometer is used to collect spectral data of the prepared solution, and each sample is scanned repeatedly multiple times. The spectrometer slits are 10, 25, 50, 100, and 200 μm, and 10 μm is selected as the slit value. The scanning spectrum range is 181.1 to 1002.4 nm, and whiteboard correction is used to convert the scanned spectral data into corresponding spectral transmittance values. The whiteboard correction calculation formula is shown in formula (1): M C =M0 / M w (1) Where M0 is the original projection spectrum data; M w This is whiteboard data.

4. The method for predicting water pollutants based on water transmission spectrum according to claim 1, characterized in that: In the step S3, first, the collected spectral data is normalized by maximum and minimum normalization, and then the normalized data is subjected to mean centering to eliminate data deviation. Unify the original transmission spectrum data to the same dimension and center point position; The calculation of the maximum and minimum normalization is shown in formula (2): Where x′ represents the value of a single data after maximum and minimum normalization, x is the original value of the data, and x min Indicates the minimum value of the column where the data is located, x max Indicates the maximum value of the column where the data is located; The calculation of mean centering is shown in formula (3): x″′ represents the value of a single data after mean centering, x r is the original value of the data, x mean Indicates the average value of the column where the data is located, x mean Indicates the average value of the column where the data is located, x std Indicates the standard deviation of the column where the data is located.

5. The method for predicting water pollutants based on water transmission spectrum according to claim 1, characterized in that: In S4, the kernel principal component analysis (KPCA) method is used to achieve data dimensionality reduction, and the KPCA method includes the following steps: (1) Data preparation: KPCA operation is performed on the transmission spectrum data after maximum and minimum normalization and mean centering. (2) Kernel function selection: a linear kernel function is selected to perform inner product calculation in the original feature space to map the original transmission spectrum data into a higher-dimensional feature space; (3) KPCA calculation: KPCA calculation is performed on the transmission spectrum data using a kernel function; KPCA maps the data to a higher-dimensional space and calculates the eigenvectors of the covariance matrix, i.e., the number of principal components; (4) Eigenvalue analysis: Calculate the variance influence rate of the principal components by the size of the eigenvalue to determine which principal components contain the most informative features; (5) Principal component selection: Select the number of principal components based on the set threshold or the size of the variance influence rate.

6. The method for predicting water pollutants based on water transmission spectrum according to claim 1, characterized in that: The S5 also includes: The mean square error (MSE) is used as the loss function to evaluate the quality of the output results of the weight and bias combination in the BP neural network using the improved particle swarm optimization algorithm under the adaptive learning factor and inertia weight update formula combined with the particle diversity guidance strategy. The weight and bias combination of the BP neural network refers to the set of weight and bias parameters of each neuron connection in the neural network. In the BP neural network, the connection between neurons is represented by weights, and each connection has a corresponding weight to adjust the importance of the input signal; the bias is an additional parameter of the neuron, which is used to adjust the activation threshold of the neuron. By adjusting the bias value, the activation state and output of the neuron are changed; the calculation formula of MSE is shown in formula (10); where y i Indicates the true value of nitrite and BOD concentration, Indicates the predicted value generated by BP neural network concentration prediction using the optimal weight and bias combination currently output by the particle swarm algorithm; The BP neural network model was used as the prediction model for nitrite and BOD concentration in water bodies. The single hidden layer neural network was trained using the leave-one-out cross-validation method to construct the BP-ANN model. The coefficient of determination (R 2 ), root mean square error (RMSE) and mean absolute error (MAE) values ​​are used to judge the performance of the BP neural network model in predicting the sample; 2 The calculation formulas of RMSE and MAE are shown in formula (13), formula (14) and formula (15); where y i represents the true value, represents the predicted value, represents the average value of the true observation value, SSR is the regression sum of squares, SSE is the residual sum of squares; SST is the total deviation sum of squares; Where n represents the number of samples, y i represents the true value, represents the predicted value; Where n represents the number of samples, y i represents the true value, Represents the predicted value.