Intelligent wastewater monitoring method based on machine learning algorithm and automatic optimization algorithm

By using a combination of machine learning algorithms and automatic optimization algorithms in wastewater treatment, the hyperparameters are automatically adjusted, and the problem of low prediction accuracy of existing models in wastewater treatment is solved, and the accurate prediction of wastewater water quality and the improvement of model accuracy are achieved.

CN119539128APending Publication Date: 2025-02-28JIANGMEN PUBLIC ENERGY ENVIRONMENTAL PROTECTION CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411322816.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-23
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

Existing machine learning models are difficult to automatically adjust hyperparameters in wastewater treatment, resulting in low prediction accuracy and manual adjustment of hyperparameters is time-consuming and labor-intensive.

Method used

Using the intelligent wastewater monitoring method based on machine learning algorithms and automatic optimization algorithms, the tree structure Parzen estimation method TPE automatically optimizes hyperparameters, trains the optimal model of each machine learning model, and combines multiple models to predict wastewater.

Benefits of technology

It realizes accurate prediction of wastewater water quality, saves the cost of manual measurement, has good credibility in the output results, and improves the model prediction accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119539128A_ABST
    Figure CN119539128A_ABST
Patent Text Reader

Abstract

The invention provides an intelligent wastewater monitoring method based on a machine learning algorithm and an automatic optimization algorithm, and the method comprises the steps: selecting monitoring data of a wastewater treatment unit of a wastewater treatment plant in a preset time period, and taking the monitoring data as a data set of machine learning; dividing the data set into a training set and a test set, and preprocessing the training set; based on the training set, multiple machine learning models are trained, and in the training process, based on the automatic optimization TPE, the optimal model of each machine learning model is trained; determining a point prediction result of an optimal model of each machine learning model based on the test set; determining a wastewater prediction model based on the point prediction result of the optimal model of the different machine learning models; and performing wastewater prediction on the wastewater treatment unit based on the wastewater prediction model. According to the intelligent wastewater monitoring method based on the machine learning algorithm and the automatic optimization algorithm, the technical problem that an existing machine learning model cannot automatically adjust hyper-parameters is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer data processing, and in particular to a wastewater intelligent monitoring method based on a machine learning algorithm and an automatic optimization algorithm. Background Art

[0002] With the increase of urban population and the progress of industrialization, the problem of eutrophication of water bodies has intensified, and the problem of wastewater has become increasingly prominent. Ammonia nitrogen is an important pollutant in eutrophication of water bodies. Anaerobic ammonia oxidation is usually used to separate and remove ammonia nitrogen from wastewater. Free ammonia (FA) and free nitrite (FNA) in wastewater will change the composition of microbial communities in sewage treatment plants, affecting the treatment effect of microorganisms on water quality. Therefore, accurate measurement of free ammonia and free nitrite in wastewater has practical significance. The concentrations of the two are usually measured manually by measuring the concentrations of ammonia nitrogen and nitrite nitrogen in the effluent, and then calculated by formulas, which takes a long time and is costly; operators usually measure the inlet and outlet water quality indicators at regular intervals, and the measurement process is relatively long. The monitoring data has a certain lag, and it is difficult to predict or discover the system abnormalities caused by it in a timely manner; and water quality is affected by many factors, resulting in water quality showing highly nonlinear, volatile and uncertain characteristics, making it difficult to predict system abnormalities.

[0003] In recent years, machine learning has been continuously developing and improving. The technology of using machine learning algorithms to predict the inlet and outlet water quality of sewage treatment plants has attracted the attention of many scientific researchers. Machine learning algorithms have high point prediction accuracy when solving prediction problems such as wastewater treatment water quality, but manually adjusting model hyperparameters is very time-consuming and laborious. Therefore, how to make machine learning models overcome the shortcomings of manually adjusting hyperparameters is a theoretical and practical engineering problem that needs to be solved urgently. Summary of the invention

[0004] One of the purposes of the present invention is to provide a wastewater intelligent monitoring method based on machine learning algorithm and automatic optimization algorithm, aiming to solve the technical problem that the existing machine learning model cannot automatically adjust hyperparameters.

[0005] The wastewater intelligent monitoring method based on machine learning algorithm and automatic optimization algorithm provided by the embodiment of the present invention includes:

[0006] Select monitoring data of the wastewater treatment unit of the wastewater treatment plant within a preset period of time and use it as a data set for machine learning;

[0007] Divide the data set into training set and test set, and preprocess the training set;

[0008] Based on the preprocessed training set, multiple machine learning models are trained. During the training process, the optimal model of each machine learning model is trained based on the automatic optimization TPE.

[0009] Determine the point prediction results of the optimal model for each machine learning model based on the test set;

[0010] Determine the wastewater prediction model based on the point prediction results of the optimal model of different machine learning models;

[0011] Based on the wastewater prediction model, wastewater prediction is performed on the wastewater treatment unit.

[0012] Optionally, dividing the data set into a training set and a test set includes:

[0013] The data set is divided into training set and test set in a ratio of 8:2.

[0014] Optionally, the preprocessing of the training set includes:

[0015] Normalize the training set.

[0016] Optionally, the multiple machine learning models include: XGBoost model, random forest model, support vector machine model and artificial neural network model.

[0017] Optionally, the method of training multiple machine learning models based on the preprocessed training set, and during the training process, training the optimal model of each machine learning model based on automatic optimization TPE, includes:

[0018] Setting multiple hyperparameters of the machine learning model and the optimization range of various hyperparameters; wherein the multiple hyperparameters include: maximum depth D, learning rate L, subsampling S, and regularization control term λ;

[0019] Set the weak learner of the machine learning model to gbtree, and the loss function of the machine learning model to mean square error RMSE;

[0020] Training machine learning model: For the preprocessed training set D = {(x i ,y i )}(|D|=n,x i ∈R m ,y i ∈R), predict the output through K additive functions:

[0021]

[0022] in, is the regression tree space, i.e., CART tree; q represents the structure of each tree that maps examples to corresponding leaf indices; T is the number of leaf nodes in the tree; each f k Corresponds to an independent tree structure q and leaf weight w; wi represents the score on the i-th leaf;

[0023] Add a regularization objective to the tree model:

[0024]

[0025] Among them, l is used to predict and target y i The difference between them, the second term Ω limits the complexity of the model, that is, the regression tree function; by minimizing the objective function, a better XGBoost prediction model is trained;

[0026] The training is completed by iterating the above process until the loss converges;

[0027] After completing a training session, TPE will adjust the hyperparameters based on the output results and output accuracy until the set number of training times is reached, and then automatically optimize the model and output the optimal model.

[0028] Optionally, determining the point prediction result of the optimal model of each machine learning model based on the test set includes:

[0029] The point prediction results of the optimal model for each machine learning model are calculated using the following formula:

[0030]

[0031] Among them, R 2 is the coefficient of determination, RMSE is the root mean square error, MAPE is the mean absolute percentage error, y i is the ith observation value, is the mean value of the ith observation, is the i-th predicted value, and n is the number of predicted samples.

[0032] Optionally, the input variables of the wastewater prediction model include influent pH value, oxidation-reduction potential ORP, total nitrogen load NLR, reflux ratio R, effluent ammonia nitrogen NH 4 + -N and NH 3 - -N; output variables include effluent free ammonia concentration FA and free nitrite concentration FNA.

[0033] The present invention provides a computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, any of the above-mentioned methods is implemented.

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

[0035] The present invention provides an intelligent monitoring method for wastewater treatment based on machine learning algorithm and automatic optimization algorithm, which can realize accurate prediction of wastewater quality. According to the changes of various indicators in the wastewater treatment process, free ammonia and free nitrite in the water are accurately predicted, which saves the cost of manual measurement for operators, and gives point prediction results at the same time, and the output results have good credibility.

[0036] In order to solve the problem that researchers need to manually adjust machine learning hyperparameters, this paper introduces the tree structure Parzen estimation method TPE to automatically optimize machine learning hyperparameters and make the machine learning model reach the optimal state. This method not only saves researchers the time of manually adjusting hyperparameters, but also effectively improves the prediction accuracy of the model.

[0037] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description and the accompanying drawings.

[0038] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:

[0040] Figure 1 Schematic diagram of an intelligent monitoring method for wastewater treatment based on a machine learning algorithm and an automatic optimization algorithm in an embodiment of the present invention;

[0041] Figure 2 is a schematic diagram of a tree model structure in an embodiment of the present invention;

[0042] Figure 3 This is a point prediction result diagram of the output variable being free ammonia FA in an embodiment of the present invention;

[0043] Figure 4 This is a point prediction result diagram of the output variable of the embodiment of the present invention, which is free nitrite FNA. DETAILED DESCRIPTION

[0044] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.

[0045] The embodiment of the present invention provides a wastewater intelligent monitoring method based on machine learning algorithm and automatic optimization algorithm, such as Figure 1 As shown, including:

[0046] S1. Select monitoring data of the wastewater treatment unit of the wastewater treatment plant within a preset period of time and use it as a data set for machine learning;

[0047] S2, divide the data set into a training set and a test set, and preprocess the training set;

[0048] S3. Based on the preprocessed training set, multiple machine learning models are trained. During the training process, the optimal model of each machine learning model is trained based on the automatic optimization TPE.

[0049] S4. Determine the point prediction result of the optimal model of each machine learning model based on the test set;

[0050] S5. Determine the wastewater prediction model based on the point prediction results of the optimal model of different machine learning models;

[0051] S6. Based on the wastewater prediction model, perform wastewater prediction on the wastewater treatment unit.

[0052] The step of dividing the data set into a training set and a test set includes:

[0053] The data set is divided into training set and test set in a ratio of 8:2.

[0054] The preprocessing of the training set includes:

[0055] Normalize the training set.

[0056] The multiple machine learning models include: XGBoost model, random forest model, support vector machine model and artificial neural network model.

[0057] The method of training a plurality of machine learning models based on the preprocessed training set, and training the optimal model of each machine learning model based on the automatic optimization TPE during the training process, includes:

[0058] Setting multiple hyperparameters of the machine learning model and the optimization range of various hyperparameters; wherein the multiple hyperparameters include: maximum depth D, learning rate L, subsampling S, and regularization control term λ;

[0059] Set the weak learner of the machine learning model to gbtree, and the loss function of the machine learning model to mean square error RMSE;

[0060] Training machine learning model: For the preprocessed training set D = {(x i ,y i )}(|D|=n,x i ∈Rm ,y i ∈R), predict the output through K additive functions:

[0061]

[0062] Among them, x i and i are the input vector and output vector of the training data set respectively; F = {f(x) = w q(x)}(q:R m →T,w∈R T ) is the regression tree space, i.e., CART tree; q represents the structure of each tree that maps examples to corresponding leaf indices; T is the number of leaf nodes in the tree; each f k Corresponds to an independent tree structure q and leaf weight w; w i represents the score on the i-th leaf;

[0063] Add a regularization objective to the tree model:

[0064]

[0065] Among them, l is used to predict and target y i The difference between them, the second term Ω limits the complexity of the model, that is, the regression tree function; by minimizing the objective function, a better XGBoost prediction model is trained;

[0066] The training is completed by iterating the above process until the loss converges;

[0067] After completing a training session, TPE will adjust the hyperparameters based on the output results and output accuracy until the set number of training times is reached, and then automatically optimize the model and output the optimal model.

[0068] The point prediction result of the optimal model of each machine learning model is determined based on the test set, including:

[0069] The point prediction results of the optimal model for each machine learning model are calculated using the following formula:

[0070]

[0071] Among them, R 2 is the coefficient of determination, RMSE is the root mean square error, MAPE is the mean absolute percentage error, y i is the ith observation value, is the mean value of the ith observation, is the i-th predicted value, and n is the number of predicted samples.

[0072] The input variables of the wastewater prediction model include influent pH value, oxidation-reduction potential (ORP), total nitrogen load (NLR), reflux ratio (R), effluent ammonia nitrogen (NH 4 + -N and NH 3 - -N; output variables include effluent free ammonia concentration FA and free nitrite concentration FNA.

[0073] The traditional machine learning algorithm construction process inevitably goes through the step of manually adjusting hyperparameters. R&D personnel need to manually adjust the hyperparameters of machine learning based on the prediction accuracy after one machine learning training. This is not only time-consuming and labor-intensive, but may also fall into the local optimal dilemma and fail to obtain the global optimal model. Random search and grid search are also methods for automatic optimization of hyperparameters, but their combined randomness and global traversal properties determine that they have the disadvantage of being time-consuming. The tree-structured Parzen estimation method TPE is an automatic hyperparameter optimization method based on Bayesian optimization. Compared with random search and grid search, it uses heuristic search with strategy to find the optimal hyperparameters in a shorter time. Therefore, how to apply TPE to the hyperparameter adjustment process of machine learning models is one of the research issues.

[0074] XGBoost is the abbreviation of Exterme Gradient Boosting. It is an integrated machine learning algorithm based on decision trees. It uses gradient boost as the framework, adds regularization terms to control complexity and prevent overfitting, and uses first and second order derivative information during optimization. The application of this model can improve prediction accuracy. Specifically, see Figure 1 , taking the XGBoost model as an example, this implementation specifically includes the following steps:

[0075] S1. Select the monitoring data of the sewage treatment plant for a certain period of time as the data set for machine learning, determine the input variables and output variables, and divide the training set and test set according to a certain ratio.

[0076] More specifically, S1 includes the following steps:

[0077] S101. Select monitoring data of a certain period of time in the anaerobic treatment unit of the sewage treatment plant as a machine learning data set. According to the data, the input variables are determined to include influent pH value, redox potential ORP, total nitrogen load NLR, reflux ratio R, effluent ammonia nitrogen NH 4 + -N and NH 3 - -N, the output variables include the effluent free ammonia concentration FA and the free nitrite concentration FNA.

[0078] S102. Reorganize the data set in the form of a matrix to prepare for data preprocessing:

[0079]

[0080] Wherein, the column vectors of the data set matrix represent wastewater index data of different categories, the row vectors represent wastewater index data of the same category at different times, k is the data length of wastewater index data of each category in the data set, and m is the number of wastewater indicators;

[0081] S103, the data set is divided into a training set and a test set according to a ratio of 8:2, where the input variables of the training set are The output variable is Y 1 Tr , the input variables of the test set are The output variable is Y 1 Te The training set is used to train the XGBoost model, and the test set is used to test the accuracy of the model's predictions.

[0082] S104, normalizing the training set using the following formula:

[0083]

[0084] Where i is the dimension of the input variable, X 1i,0 is the original data value of the i-th dimension in the input variable, minX 1i,0 is the minimum value of the original data of the i-th dimension in the input variable, maxX 1i,0 is the maximum value of the original data of the i-th dimension in the input variable, X 1i is the normalized data value of the i-th dimension in the input variable.

[0085] S2. Build an XGBoost model, input the training set data into XGBoost for training, use TPE to automatically select the next set of hyperparameters after each round of training, and continue training until the set number of training times is reached to obtain the optimal hyperparameters and the optimal model.

[0086] More specifically, S2 contains the following steps:

[0087] S201, build a machine learning model, set machine learning related hyperparameters, the maximum depth D, learning rate L, subsampling S, and regularization control term λ of the machine learning model. D, L, S, and λ are designated as TPE hyperparameters to be optimized, and their optimization ranges are set before training;

[0088] S202, set the XGBoost weak learner to gbtree, and the loss function to mean square error RMSE;

[0089] S203, training XGBoost. For a given dataset D = {(x i ,y i )}(|D|=n,x i ∈R m ,y i ∈R), the tree ensemble model predicts the output through K additive functions.

[0090]

[0091] Where F = {f(x) = w q(x)}(q:R m →T,w∈R T ) is the regression tree space, i.e., CART tree. Here q represents the structure of each tree that maps examples to corresponding leaf indices. T is the number of leaf nodes in the tree. k Represents an independent tree corresponding to q (tree structure) and w (leaf node weight). i represents the score on the i-th leaf, and m is the sample feature dimension.

[0092]

[0093] Add a regularization target to the tree model, where l is used to predict and target y i The difference between the two, the second term Ω limits the complexity of the model, that is, the regression tree function. By minimizing this objective function, a better XGBoost prediction model can be trained.

[0094] The training is completed by iterating the above process until the loss converges.

[0095] S204. After completing a training, TPE will adjust the hyperparameters according to the output results and output accuracy until the set number of training times is reached, and then the automatic optimization ends and the optimal model is output. The working principle of TPE is as follows:

[0096] (1) According to the hyperparameters to be optimized and the corresponding hyperparameter space set by the user, at the beginning N init In each training, TPE uses random search to combine hyperparameters in the hyperparameter space and creates a set of error observations {x (i) ,y (i) ,i=1,2,...,N init}, where x (i) represents the hyperparameter combination to be optimized, y (i) Represents the error value of training using the corresponding hyperparameter combination;

[0097] (2) Based on the previous N training results and training accuracy, TPE sets an error quantile value y * , which can be understood as init A quantile value γ is set in the error value y, usually set to 15%. TPE divides the error observation set into two parts and calculates their probability values:

[0098]

[0099] l(x) and g(x) represent the probability density functions of the hyperparameter sets with error values ​​less than y* and greater than y*, respectively. More intuitively, l(x) and g(x) represent the probability density functions of the hyperparameter sets with good and poor effects, respectively.

[0100] (3) Calculate the EI value:

[0101]

[0102] In order to simplify the calculation, we usually calculate value.

[0103] (4) Select the next set of hyperparameter values ​​by maximizing the EI value;

[0104] (5) Repeat steps (2) to (4) until the set number of training times is reached.

[0105] S205, will and Input the above optimal model and output and

[0106] S301, calculation point prediction index:

[0107] (1) Coefficient of determination R 2 : It is used to measure the degree of deviation between the predicted value and the true value, between 0 and 1. The closer it is to 1, the closer the predicted value is to the true value.

[0108] (2) Root mean square error (RMSE): It is used to calculate the square root of the ratio of the sum of squares of the deviations between the predicted value and the observed value to the number of observations. The larger the RMSE, the greater the error in the predicted value.

[0109] (3) Mean absolute percentage error (MAPE): It is used to calculate the percentage of the mean absolute error between the predicted value and the observed value. The smaller the MAPE, the more perfect the prediction model is. A value greater than 1 indicates that the prediction model is a poor quality model.

[0110] The calculation formula of the point forecast indicator is as follows:

[0111]

[0112] Among them, y i is the ith observation value, is the mean value of the ith observation, is the i-th predicted value, and n is the number of predicted samples.

[0113] S4. Compare the point prediction of XGBoost with RF, SVM and ANN respectively, and obtain the better model through the comparison results. The point prediction results are shown in Table 1 and Figure 4 , the interval prediction results are shown in Table 2 and Figure 4 .

[0114] Table 1 Comparison of point prediction results of three models

[0115]

[0116] For the prediction of FA and FNA of the outlet water, the prediction accuracy of XGBoost is very high, the prediction effect of ANN is slightly worse, and RF lags behind the two, while the prediction accuracy of the SVM model is not ideal enough, which shows that the machine learning method using TPE automatic optimization not only saves the complexity of manually adjusting hyperparameters, but also can obtain high prediction accuracy. Among them, the three indicators of XGBoost are better than other models, indicating that the point prediction results obtained by the method proposed in the present invention are the most accurate.

[0117] An embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

[0118] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A wastewater intelligent monitoring method based on machine learning algorithm and automatic optimization algorithm, characterized in that: include: Select monitoring data of the wastewater treatment unit of the wastewater treatment plant within a preset period of time and use it as a data set for machine learning; Divide the data set into training set and test set, and preprocess the training set; Based on the preprocessed training set, multiple machine learning models are trained. During the training process, the optimal model of each machine learning model is trained based on the automatic optimization TPE. Determine the point prediction results of the optimal model for each machine learning model based on the test set; Determine the wastewater prediction model based on the point prediction results of the optimal model of different machine learning models; Based on the wastewater prediction model, wastewater prediction is performed on the wastewater treatment unit.

2. The wastewater intelligent monitoring method based on machine learning algorithm and automatic optimization algorithm as claimed in claim 1, characterized in that: The step of dividing the data set into a training set and a test set includes: The data set is divided into training set and test set in a ratio of 8:

2.

3. The wastewater intelligent monitoring method based on machine learning algorithm and automatic optimization algorithm as claimed in claim 1, characterized in that: The preprocessing of the training set includes: Normalize the training set.

4. The wastewater intelligent monitoring method based on machine learning algorithm and automatic optimization algorithm as claimed in claim 1, characterized in that: The multiple machine learning models include: XGBoost model, random forest model, support vector machine model and artificial neural network model.

5. The wastewater intelligent monitoring method based on machine learning algorithm and automatic optimization algorithm as claimed in claim 1, characterized in that: The method of training a plurality of machine learning models based on the preprocessed training set, and training the optimal model of each machine learning model based on the automatic optimization TPE during the training process, includes: Setting multiple hyperparameters of the machine learning model and the optimization range of various hyperparameters; wherein the multiple hyperparameters include: maximum depth D, learning rate L, subsampling S, and regularization control term λ; Set the weak learner of the machine learning model to gbtree, and the loss function of the machine learning model to mean square error RMSE; Training machine learning model: For the preprocessed training set D = {(x i ,y i )}(|D|=n,x i ∈R m ,y i ∈R), predict the output through K additive functions: in, is the regression tree space, i.e., CART tree; q represents the structure of each tree that maps examples to corresponding leaf indices; T is the number of leaf nodes in the tree; each f k Corresponds to an independent tree structure q and leaf weight w; w i represents the score on the i-th leaf; Add a regularization objective to the tree model: Among them, l is used to predict and target y i The difference between them, the second term Ω limits the complexity of the model, that is, the regression tree function; by minimizing the objective function, a better XGBoost prediction model is trained; The training is completed by iterating the above process until the loss converges; After completing a training session, TPE will adjust the hyperparameters based on the output results and output accuracy until the set number of training times is reached, and then automatically optimize the model and output the optimal model.

6. The wastewater intelligent monitoring method based on machine learning algorithm and automatic optimization algorithm as claimed in claim 1, characterized in that: The point prediction result of the optimal model of each machine learning model is determined based on the test set, including: The point prediction results of the optimal model for each machine learning model are calculated using the following formula: Among them, R 2 is the coefficient of determination, RMSE is the root mean square error, MAPE is the mean absolute percentage error, y i is the ith observation value, is the mean value of the ith observation, is the i-th predicted value, and n is the number of predicted samples.

7. The wastewater intelligent monitoring method based on machine learning algorithm and automatic optimization algorithm as claimed in claim 1, characterized in that: The input variables of the wastewater prediction model include influent pH value, oxidation-reduction potential ORP, total nitrogen load NLR, reflux ratio R, effluent ammonia nitrogen NH4 + -N and nitric nitrogen NH3 - -N; output variables include effluent free ammonia concentration FA and free nitrite concentration FNA.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.