Intelligent dosing and effluent quality prediction method based on machine learning

By constructing a machine learning-based prediction model for PAC dosage and total phosphorus in sedimentation tank effluent, the problems of lag and multivariate coupling in chemical dosing control of wastewater treatment plants were solved, achieving precise control and chemical saving, and improving wastewater treatment efficiency and effluent quality stability.

CN121459970APending Publication Date: 2026-02-03NANJING GAOKE ENVIRONMENTAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511579865.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-31
Publication Date
2026-02-03

AI Technical Summary

Technical Problem

Wastewater treatment plants face challenges in controlling chemical dosage due to lag, lack of prediction and optimization capabilities, and multivariate coupling, leading to chemical waste and unstable effluent quality. Existing machine learning applications have failed to effectively achieve coordinated optimization and real-time feedback regulation of chemical dosage and effluent quality.

Method used

A machine learning-based approach was used to construct a predictive model for PAC dosage and total phosphorus in sedimentation tank effluent. By combining TimeSeriesSplit data partitioning, Optuna hyperparameter optimization, and multi-model integration, a forward-looking prediction and closed-loop feedback regulation were achieved, dynamically adjusting the dosage to ensure stable effluent quality.

Benefits of technology

It achieves precise control and chemical conservation, reduces operating costs through forward-looking prediction and feedback adjustment, improves wastewater treatment efficiency and effluent quality stability, and forms an intelligent adaptive smart decision-making system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121459970A_ABST
    Figure CN121459970A_ABST
Patent Text Reader

Abstract

The invention provides an intelligent dosing and effluent quality prediction method based on machine learning. The method comprises the following steps: collecting data; processing the data collected in the step (1); building a polyaluminum chloride (PAC) dosage prediction model and optimizing parameters; and constructing an effluent total phosphorus (ESP) prediction model and optimizing parameters. According to the method disclosed by the invention, by constructing a series-connected PAC dosage and effluent total phosphorus prediction model, the future dosage demand and effluent quality can be predicated prospectively based on the current working condition, so that the required dosage can be accurately calculated on the premise of ensuring that the effluent stably reaches the standard, the waste of chemicals is effectively avoided, and the operation cost is remarkably reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of sewage treatment, and particularly relates to an intelligent dosing and effluent water quality prediction method based on machine learning. BACKGROUND

[0002] In the sewage treatment process, chemical phosphorus removal is one of the key links to ensure that the total phosphorus in the effluent meets the discharge standard, and polyaluminum chloride (PAC) is widely used as a common coagulant. However, at present, most sewage treatment plants still mainly rely on manual experience or simple control strategies (such as PID control) based on fixed rules to determine the PAC dosage. This method has the following significant disadvantages:

[0003] Hysteresis and roughness: sewage treatment is a complex biochemical process, and water quality and water quantity have significant uncertainty and time-varying nature. Manual control or simple rule control cannot respond to fluctuations in the inflow load in real time, resulting in serious lag in dosing adjustment. In order to ensure that the effluent water quality meets the standard, operators tend to use a conservative strategy of "excessive dosing", which not only causes a large amount of waste of chemicals and increases the operating cost, but also may cause problems such as increased sludge volume and increased effluent salinity.

[0004] Lack of prediction and optimization capability: the traditional control method is a "post" reaction, that is, it adjusts according to the current or past effluent water quality data, and cannot accurately predict the effluent water quality (such as the total phosphorus ESP) at future time. Due to the lack of foresight, the system cannot make a judgment and take proactive measures before the risk of phosphorus exceeding the standard, and can only take remedial measures after the standard is exceeded, with poor control effect.

[0005] Challenge of multivariable coupling: the dosing effect of PAC is affected by multiple process parameters such as inflow, chemical oxygen demand (COD), ammonia nitrogen (NH3-N), total phosphorus (TP), sludge concentration (MLSS), and dissolved oxygen (DO), and there is a complex nonlinear relationship between these variables. Manual experience cannot accurately quantify these relationships, and traditional mathematical models also cannot accurately describe this highly nonlinear and time-varying dynamic process.

[0006] In recent years, with the development of smart water, machine learning technology provides a new solution to the above problems. Some studies attempt to apply machine learning models to water quality prediction or dosing amount estimation. However, these applications often have limitations: either only predicting the dosing amount or the effluent water quality, without optimizing the two as a whole system; or failing to fully consider the strong time series characteristics of sewage treatment data when building the model, resulting in poor model generalization ability; in addition, how to convert the prediction results of the model into an executable optimal control strategy on site and realize closed-loop linkage with real-time feedback data is still a challenge in current practice.

[0007] Therefore, developing an intelligent dosing method capable of accurately predicting key water quality parameters, self-adaptively dynamically optimizing dosing amount, and realizing closed-loop feedback regulation is of great significance for improving the operation efficiency and economic benefits of the sewage treatment plant. SUMMARY

[0008] Technical scheme: In order to solve the above technical problems, the application provides an intelligent dosing and effluent water quality prediction method based on machine learning, comprising the following steps:

[0009] (1) Collect data:

[0010] (2) Data processing of step (1) collected data: data cleaning is performed on the collected data; data interpolation is performed on the missing data; data points with PAC dosing amount and PAM dosing amount being 0 at the same time are filtered out; and feature engineering data is constructed;

[0011] (3) Polyaluminum chloride (PAC) dosing amount prediction model construction and parameter optimization:

[0012] (3.1) Time series cross-validation data division: using the TimeSeriesSplit(n_splits=5) method, the entire time series data is divided into 5 folds, and the last split is selected as the validation set and the others are used as the training set;

[0013] (3.2) Model training and optimization: set reasonable value range for the key hyperparameters of the model; for each group of hyperparameters proposed by Optuna, use the training set to train the model and make predictions on the validation set; calculate the root mean square error between the predicted value and the true value as the evaluation index; Optuna framework automatically adjusts the next group of hyperparameters to be tried according to the root mean square error, gradually approaching the optimal solution, and when the optimal solution meets the early stopping condition, the polyaluminum chloride (PAC) dosing amount prediction model is obtained;

[0014] The root mean square error RMSE is calculated by the following formula:

[0015]

[0016] Wherein, y i is the true value, is the predicted value, and n is the number of validation set samples;

[0017] (4) Sediment tank effluent total phosphorus (ESP t ) prediction model construction:

[0018] (4.1) Constructing input features: taking the output value of the polyaluminum chloride (PAC) dosage prediction model in step (3) and the feature engineering data obtained in step (2) and part of the data in the original data in step (1) (process variables related to the total phosphorus of the sedimentation tank effluent) as the input features of the total phosphorus of the sedimentation tank effluent (ESP t ) prediction model;

[0019] (4.2) Model training and optimization: set reasonable value ranges for the key hyperparameters of the model; for each set of hyperparameters proposed by Optuna, use the training set to train the model and make predictions on the validation set; calculate the root mean square error between the predicted value and the true value as the evaluation index; the Optuna framework automatically adjusts the next set of hyperparameters to be tried according to the root mean square error, gradually approaching the optimal solution, and when the optimal solution meets the early stopping condition, the total phosphorus of the sedimentation tank effluent (ESP t ) prediction model is obtained;

[0020] The root mean square error RMSE is calculated using the following formula:

[0021]

[0022] Where y i is the true value, is the predicted value, and n is the number of validation set samples;

[0023] (5) Feedback adjustment: dynamically adjusting the polyaluminum chloride (PAC) dosage according to the predicted value of the total phosphorus of the sedimentation tank effluent (ESP t ) prediction model and the measured value of the total phosphorus of the sedimentation tank effluent OUT t , constructing the total phosphorus process value, i.e., the predicted value of the total phosphorus of the sedimentation tank effluent (ESP t ), and calculating the PAC adj,t adjustment value as follows:

[0024] PAC adj,t =PAC pred,t ×α t

[0025]

[0026] PAC pred,t is the polyaluminum chloride (PAC) dosage prediction value at time t; PAC adj,t is the polyaluminum chloride (PAC) dosage adjustment value at time t, i.e., the PAC dosage after feedback adjustment.

[0027] Preferably, in step (1), the collected data includes time, influent flow rate, COD, ammonia nitrogen, total nitrogen, total phosphorus, PAC dosage, effluent from the biological treatment tank, total phosphorus from the effluent from the rectangular secondary sedimentation tank, PAM dosage, total effluent, total phosphorus from the effluent from the sedimentation tank, dissolved oxygen, reflux ratio, and sludge concentration.

[0028] In step (2), the data preprocessing methods include:

[0029] (2.1) The collected data was cleaned using the following methods:

[0030]

[0031] x represents the data to be processed. min x is the minimum value in the data. max The maximum value in the array; R + positive

[0032] The set of real numbers, R is the number of real numbers;

[0033] (2.2) Eliminate invalid operating conditions: Filter out PAC (polyaluminum chloride) dosage and PAM (polyacrylamide) dosage.

[0034] Data points where the dosage is 0 indicate that the system is in an abnormal operating state (drug withdrawal period);

[0035] (2.3) Imputing missing values: Missing values ​​are imputed using linear interpolation and forward / backward imputation strategies. That is, for any missing value...

[0036] Lost points x t If there are known values ​​x before and after, t-k x t+m ,but:

[0037]

[0038] t represents time, and m and k represent time differences;

[0039] Right now,

[0040] K is the time distance from the current missing point t to the previous known data point. The previous non-missing value appears at time tk, so k ≡ t - (tk), which means that it took k steps to the left to find the valid data.

[0041] m is the time distance from the current missing point t to the next known data point. The next non-missing value appears at time t+m, so m = (t+m)-t, which means that it took m steps to the right to find the valid data.

[0042] (2.4) Constructing feature engineering data:

[0043] (2.4.1) Rate of change feature:

[0044] Δx t (1) = x t - x t-1

[0045] Δx t (2) = x t - x t-2

[0046] x is the data to be processed; t is the time;

[0047] (2.4.2) Process combination feature:

[0048]

[0049] where Q is the influent flow rate, X is the sludge concentration, COD is the chemical oxygen demand, TP is the total phosphorus, DO is the dissolved oxygen, the influent flow rate V is the effective volume of the biochemical tank; ∈ is 1e -6 ;

[0050] (2.4.3) Drug response delay effect feature: the lag term of PAC / PAM is used with moving average to capture the drug response

[0051] delay effect feature:

[0052]

[0053] where, is the drug response delay effect feature; Lag is the lag order (i.e. "look back for several time steps"), taking values 1, 2, 3; x t-lag is the observation value of the variable at t time forward by lag time units; (2.4.4) Moving average feature:

[0054]

[0055] where σ t is the moving average feature, w takes 3, enhancing the model's perception of fluctuations and trends within 3 hours, x i is the data set.

[0056] In steps (3.2) and (4.2), three machine learning models, XGboots, LightGBM and / or CatBoost, are introduced, and the optimized parameters are recombined with weights to form the weight coefficients of the three models respectively:

[0057]

[0058] The final prediction model is the weighted average prediction result:

[0059]

[0060] Preferably, in the XGboots model, n_estimatiors = 100, verbosity = 0, random_state = 42; in the LightGBM model, n_estimatiors = 100, verbose = 1, random_state = 42; in the CatBoost model, the parameters are n_estimatiors = 100, random_state = 42.

[0061] In steps (3.2) and (4.2), the early stopping condition is:

[0062] If the kth round k u satisfies the following formula, then stop training at the k u + rth round:

[0063]

[0064] Where m k is the evaluation index of the kth round validation set; m * is min 1≤i≤k m i , that is, the historical best index; r is the patience round, which is 30.

[0065] In steps (3.2) and (4.2), the Optuna framework automatically adjusts the next set of hyperparameters to be tried according to the root mean square error as follows:

[0066] ① Divide the hyperparameters into two groups:

[0067] Good performing hyperparameters: D l = {x: f(x) < y *}

[0068] Poor performing hyperparameters: D g = {x: f(x) ≥ y *}

[0069] Where y * is the quantile (such as 10% quantile) of the objective function;

[0070] ② Fit the probability density respectively:

[0071] l(x) = p(x: f(x) < y * )

[0072] g(x) = p(x: f(x) ≥ y * )

[0073] ③ Next hyperparameter calculation:

[0074]

[0075] Where x is the hyperparameter vector, f(x) is the objective function value; y * is the threshold quantile (such as 10%) of the objective function; l(x), g(x) are conditional probability density functions.

[0076] Beneficial effects: The intelligent dosing and effluent water quality prediction method based on machine learning proposed by the application has the following significant advantages compared with the prior art:

[0077] First, forward-looking prediction, precise control, and saving of drug consumption: By constructing a series of PAC dosing and effluent total phosphorus prediction models, the future dosing demand and effluent water quality can be forward-looking predicted based on the current working condition. This makes the dosing operation change from "after-the-fact remedy" to "before-the-fact intervention", so that the required drug dose can be accurately calculated under the premise of ensuring stable and standard effluent (such as ESP <0.05 mg / L), effectively avoiding drug waste and significantly reducing operating costs.

[0078] Second, intelligent self-adaptation, effectively dealing with complex nonlinear relationships: Advanced machine learning models such as LightGBM and XGBoost are used, which do not require manual presetting of complex rules. They can automatically learn the internal laws between inflow flow, water quality indicators, operating parameters, dosing amount, and effluent phosphorus value from historical data, and adapt to fluctuations in water quality and water volume, making the control system more intelligent and robust.

[0079] Third, closed-loop optimization, forming a complete intelligent chain of decision-making and execution: The application constructs a complete closed loop of "prediction-decision-execution-feedback", which not only includes high-precision prediction models, but also innovatively introduces a feedback regulation mechanism (such as dynamically adjusting PAC according to the measured ESP) and a differential evolution algorithm for rolling optimization to ensure that the system can continuously fine-tune the strategy according to the actual effluent effect, forming a self-optimizing intelligent decision-making system with control effect far superior to open-loop prediction or simple rule control.

[0080] Fourth, excellent model performance, reliable prediction results: In the model construction stage, TimeSeriesSplit is used to prevent data leakage, which is more suitable for actual application scenarios; Optuna hyperparameter optimization framework is used to automatically search for the optimal parameter combination, maximizing model performance; and a weighted ensemble learning strategy is used to integrate the advantages of multiple models, further improving the accuracy and stability of the prediction. BRIEF DESCRIPTION OF DRAWINGS

[0081] Figure 1 is the threshold quantile (such as 10%) of the objective function; l(x), g(x) are conditional probability density functions.

[0082] Figure 2 A comparison chart of the measured and predicted PAC dosing amounts after feedback adjustment;

[0083] Figure 3 A comparison chart of the measured and predicted total phosphorus in the sedimentation tank effluent;

[0084] Figure 4 A feature map of the importance of the PAC prediction model;

[0085] Figure 5 A feature map of the importance of the ESP prediction model;

[0086] Figure 6 A comparison chart of the feature maps of the importance of the PAC prediction model and the ESP prediction model. DETAILED DESCRIPTION

[0087] The technical solutions in the embodiments of the present application will be described below in a clear and complete manner, so that those skilled in the art can better understand the advantages and features of the present application, and the protection scope of the present application can be more clearly defined. The embodiments described in the present application are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0088] The intelligent dosing and effluent water quality prediction method based on machine learning comprises the following steps:

[0089] (1) Collecting data: The collected data includes time, influent flow, COD, ammonia nitrogen, total nitrogen, total phosphorus, PAC dosing amount, biochemical tank effluent, rectangular secondary sedimentation tank effluent total phosphorus, PAM dosing amount, total effluent, sedimentation tank effluent total phosphorus, dissolved oxygen, and sludge concentration.

[0090] (2) Processing the data collected in step (1): cleaning the collected data; interpolating the missing data; filtering out the data points where the PAC dosing amount and the PAM dosing amount are both zero; and constructing feature engineering data;

[0091] The data preprocessing method comprises:

[0092] (2.1) The collected data is cleaned by using the following method:

[0093]

[0094] x is the data to be processed, x min is the minimum value in the data, x max is the maximum value in the array; R +R is a set of positive real numbers, R is a real number;

[0095] (2.2) Eliminate invalid conditions: filter out the data points when PAC (polyaluminum chloride) and PAM (polyacrylamide) dosing amount are both 0, at this time the system is in abnormal operation state (drug stop period);

[0096] (2.3) Complete missing values: linear interpolation and forward and backward filling strategy is adopted to complete the missing values, that is, for any missing point x t , if there are known values x t-k , x t+m before and after, then:

[0097]

[0098] t is the time, m and k are time differences;

[0099] That is,

[0100] K is the time distance from the current missing point t to the previous known data point, and the previous non-missing value appears at time t-k, so k≡t-(t-k), which means jumping k steps to the left to find valid data;

[0101] m is the time distance from the current missing point t to the next known data point, and the next non-missing value appears at time t+m, so m=(t+m)-t, which means jumping m steps to the right to find valid data;

[0102] (2.4) Construct feature engineering data:

[0103] (2.4.1) Change rate feature:

[0104] Δx t (1) = x t - x t-1

[0105] Δx t (2) = x t - x t-2

[0106] x is the data to be processed; t is the time;

[0107] (2.4.2) Process combination feature:

[0108]

[0109]

[0110] Wherein, Q is the water flow, X is the sludge concentration, COD is the chemical oxygen demand, TP is the total phosphorus, DO is the dissolved oxygen, Q is the water flow, V is the effective volume of the biochemical tank, which is 12927m 3 in this embodiment -6 ;

[0111] (2.4.3) Drug response delay effect feature: the lag term of PAC / PAM and moving average are used to capture the drug response delay effect feature:

[0112]

[0113] Wherein, is the drug response delay effect feature; Lag is the lag order (i.e. "look back several time steps"), taking values 1, 2, 3; x t-lag is the observation value of the variable when the time unit is pushed forward by lag time units at t time;

[0114] (2.4.4) Moving average feature:

[0115]

[0116] Wherein, σ t is the moving average feature, w takes 3, enhancing the model's perception of fluctuations and trends within 3 hours, x i is the data set.

[0117] (3) Polyaluminum chloride (PAC) dosage prediction model construction and parameter optimization:

[0118] (3.1) Time series cross-validation data division: using TimeSeriesSplit(n_splits=5) method, the whole time series data is divided into 5 folds, the last split is selected as the validation set, and the others are used as the training set;

[0119] (3.2) Model training and optimization: set reasonable value range for the key hyperparameters of the model; for each set of hyperparameters proposed by Optuna, use the training set to train the model and make predictions on the validation set; calculate the root mean square error between the predicted value and the true value as the evaluation index; Optuna framework automatically adjusts the next set of hyperparameters to be tried according to the root mean square error, gradually approaching the optimal solution, when the optimal solution meets the early stopping condition, the polyaluminum chloride (PAC) dosage prediction model is obtained;

[0120] The root mean square error RMSE is calculated by the following formula:

[0121]

[0122] Wherein, y iis the true value, is the predicted value, n is the number of validation set samples;

[0123] Three machine learning models, XGboots, LightGBM and / or CatBoost, are introduced, and the optimized parameters are recombined to form the weight coefficients of the three models respectively:

[0124]

[0125] The final prediction model is the weighted average prediction result:

[0126]

[0127] The early stopping condition is:

[0128] If a round k0 satisfies the following formula, then stop training at k0+r:

[0129]

[0130] Where, m k is the evaluation index of the kth round of validation set; m * is min 1≤i≤k m i , that is, the historical best index; r is the patience number, which is 30;

[0131] The Optuna framework automatically adjusts the next set of hyperparameters to be tried according to the root mean square error as follows:

[0132] ①Divide the hyperparameters into two groups:

[0133] Good performing hyperparameters: D l ={x:f(x)<y *}

[0134] Poor performing hyperparameters: D g ={x:f(x)≥y *}

[0135] Where, y * is the quantile of the objective function (such as 10% quantile);

[0136] ②Fit the probability density respectively:

[0137] l(x)=p(x:f(x)<y * )

[0138] g(x)=p(x:f(x)≥y * )

[0139] ③Next hyperparameter calculation:

[0140]

[0141] where x is the hyperparameter vector, f(x) is the objective function value; y * is the threshold quantile (e.g. 10%) of the objective function; l(x), g(x) are conditional probability density functions;

[0142] (4) The total phosphorus (ESP t ) prediction model is constructed:

[0143] (4.1) The input features are constructed: the output value of the step (3) polyaluminum chloride (PAC) dosage prediction model and the feature engineering data obtained in step (2) and part of the data in step (1) original data (process variables related to the total phosphorus of the sedimentation tank effluent) are used as the input features of the total phosphorus (ESP t ) prediction model of the sedimentation tank effluent;

[0144] (4.2) Model training and optimization: set reasonable value range for the key hyperparameters of the model; for each set of hyperparameters proposed by Optuna, use the training set to train the model and make predictions on the validation set; calculate the root mean square error between the predicted value and the true value as the evaluation index; the Optuna framework automatically adjusts the next set of hyperparameters to be tried according to the root mean square error, gradually approaching the optimal solution, when the optimal solution meets the early stopping condition, the total phosphorus (ESP t ) prediction model of the sedimentation tank effluent is obtained;

[0145] The root mean square error RMSE is calculated using the following formula:

[0146]

[0147] where y i is the true value, is the predicted value, and n is the number of validation set samples;

[0148] Three machine learning models, XGboots, LightGBM and / or CatBoost, are introduced, and the optimized parameters are recombined with weights to form the weight coefficients of the three models respectively:

[0149]

[0150] The final prediction model is the weighted average prediction result:

[0151]

[0152] The early stopping condition is:

[0153] If a round k0 satisfies the following formula, then stop training at the k0+r round:

[0154]

[0155] where m k is the evaluation index of the kth round of validation set; m * is min 1≤i≤k m i , that is, the historical best index; r is the patience round number, which is 30;

[0156] The Optuna framework automatically adjusts the next set of hyperparameters to be tried according to the root mean square error of the following method:

[0157] ①Divide the hyperparameters into two groups:

[0158] Good performing hyperparameters: D l = {x: f(x) < y *}

[0159] Poor performing hyperparameters: D g = {x: f(x) ≥ y *}

[0160] where y * is the quantile (such as 10% quantile) of the objective function;

[0161] ②Fit the probability density respectively:

[0162] l(x) = p(x: f(x) < y * )

[0163] g(x) = p(x: f(x) ≥ y * )

[0164] ③Next hyperparameter calculation:

[0165]

[0166] where x is the hyperparameter vector, f(x) is the objective function value; y * is the threshold quantile (such as 10%) of the objective function; l(x), g(x) are the conditional probability density functions;

[0167] (5) Feedback regulation: dynamically adjust the PAC dosage according to the predicted value of the sedimentation tank effluent total phosphorus (ESP t ) prediction model and the measured value of the effluent total phosphorus OUT t , and construct the total phosphorus process value, that is, the predicted value of the sedimentation tank effluent total phosphorus (ESP t ), PAC adj,t adjustment value is calculated as follows:

[0168] PAC adj,t = PACpred,t Xa t

[0169]

[0170] PAC pred,t PAC is the PAC dosage prediction value at time t; PAC adj,t PAC is the PAC dosage adjustment value at time t, that is, the PAC dosage after feedback adjustment.

[0171] In steps (3.2) and (4.2),

[0172] The parameter ranges of LightGBM, XGBoost and CatBoost are shown in Table 1.

[0173] Table 1 Parameter range

[0174]

[0175]

[0176] (5) Feedback adjustment: according to the measured value of total phosphorus (ESP t ) in the effluent of the sedimentation tank and the effluent flow, the PAC dosage is dynamically adjusted, and the PAC adj,t adjustment value is calculated as follows:

[0177] PAC adj,t = PAC pred,t X a t

[0178]

[0179] (6) Model predictive control optimization: differential evolution algorithm (Differential Evolution) is used as the optimizer to dynamically optimize the PAC dosage.

[0180] The differential evolution algorithm (Differential Evolution) includes the following steps: create a window with a length of horizon on the test data, and slide from the starting point; at each time step, solve the optimal control sequence from the current time to the future one complete optimization window horizon; after obtaining the optimal control sequence of the entire window, the first control action in the sequence is actually applied to the system; the window moves forward one time step, the system state is updated, and the algorithm repeats the entire optimization process based on the new measurement data.

[0181] A more specific example is given below to illustrate the method.

[0182] For one intelligent prediction, the applicant obtained the following results using the above method:

[0183] LGB optimal parameters:

[0184] {'num_leaves': 54, 'learning_rate': 0.03953516823408968, 'feature_fraction': 0.8012071515989376, 'bagging_fraction': 0.8608261189855001, 'bagging_freq': 8, 'lambda_l1': 1.723732652457641, 'lambda_l2': 0.183265117356878,'min_gain_to_split': 0.1727894954696983}

[0185] XGB optimal parameters:

[0186] {'max_depth': 3, 'learning_rate': 0.09901465243388999,'subsample': 0.9956680629038099, 'colsample_bytree': 0.9091811334301978,'reg_alpha': 4.0639585197181916,'reg_lambda': 0.38259061719529663,'min_child_weight': 8}

[0187] CAT optimal parameters:

[0188] {'depth': 4, 'learning_rate': 0.08496117996281755, 'l2_leaf_reg': 1.8718260276398446, 'random_strength': 0.10806388304936544, 'bagging_temperature': 0.5645199576226797}

[0189] Based on the above optimal parameters, the evaluation model is obtained, and the model performance is evaluated, and the results are shown in Figures 1 to 6 .

[0190] Figure 1 The frequency distribution diagram of the adjustment of the addition of medicine is given, and the number of times of three kinds of feedback adjustment is shown in the figure.

[0191] Figure 2A comparison chart of the measured, predicted and feedback-adjusted PAC dosages is given, which shows that:

[0192] Blue is the measured value of PAC, red is the PAC after feedback adjustment combined with the total phosphorus of effluent and the predicted total phosphorus of the sedimentation tank, and yellow is the PAC originally predicted by the model. Figure 1 It can be seen that the PAC after feedback adjustment is generally above the originally predicted PAC, indicating that the dosage is generally rising after feedback adjustment, which indicates the effectiveness of feedback adjustment. The volatility of the originally predicted PAC is less than that of the real PAC, showing a relatively stable state, with the highest value being lower than the highest value of the measured PAC and the lowest value being higher than the lowest value of the measured PAC. The shape of the PAC after feedback adjustment is basically consistent with that of the originally predicted PAC, and the consistency feature is not destroyed. The originally predicted PAC also has a consistency feature with the measured PAC, although the overall change trend is not completely consistent, but the three maximum values (January 4, 5 and 7) are consistent.

[0193] Although the accuracy of the real originally predicted PAC and the measured PAC is not very high, the wisdom of dosing in engineering application is not accuracy, so this model does not put accuracy first. The multiple feedback mechanism considered in this model ensures that the effluent quality meets the standard and can reduce manual work, and can automatically calculate and add the dosage according to the water quality. In addition, under the condition of ensuring the effluent, the dosage is as small as possible, and the predicted PAC is basically below the measured PAC, which shows that the dosage is less than the actual dosage. At the same time, the effluent standard rate is 100%.

[0194] Figure 3 The comparison chart of the measured and predicted values of the total phosphorus of the sedimentation tank effluent shows that the change trend of the predicted value of the total phosphorus of the sedimentation tank effluent is basically consistent with that of the measured value, and the predicted value can be used as a reference for feedback adjustment of PAC.

[0195] The average absolute deviation and other data of the predicted value and the real value are calculated, and the results are as follows:

[0196] PAC prediction model PAC prediction + feedback regulation ESP prediction model MAE 4.5401 6.1374 0.0096 RMSE 6.0341 7.6134 0.0127 [R 2 ]]> 0.5073 0.5619 0.4823

[0197] The above:

[0198] MAE: the average absolute deviation of the predicted value and the real value;

[0199] RMSE: more sensitive to large errors (because of square);

[0200] R 2 : Explains the proportion of variance.

[0201] The MAE of the ESP is only 0.096, which indicates that the model is highly accurate. The MAE of the feedback adjustment is higher than that of the original model, because the feedback adjustment destroys the rules learned by the original model, but further guarantees the effluent. The MAE of the PAC prediction is higher than that of the feedback adjustment, because the average value of the ESP is very small, about 0.05. The average value of the measured PAC is 19.83. The absolute deviation of the PAC prediction model is 4.54, which indicates that the correct rate is about 77%. The model does not pursue the accuracy, but mainly considers the multiple feedback mechanism to guarantee the effluent quality to meet the standard and to reduce the manual operation. The model can automatically calculate and add the dosing amount according to the water quality. In the case of guaranteeing the effluent, the dosing amount is reduced as much as possible, and the predicted PAC is basically below the measured PAC, which can be seen that the dosing amount is less than the actual dosing amount. At the same time, the effluent standard rate is 100%.

[0202] The method is used for evaluating various characteristic parameters of the PAC prediction and the ESP prediction, and the importance of the characteristic parameters is determined according to the number of splits, Figure 4 、 Figure 5 、 Figure 6 The importance characteristic map of the PAC prediction model, the importance characteristic map of the ESP prediction model and a comparison map are given.

[0203] The above-described embodiments only express several embodiments of the present application, and the description is relatively specific and detailed, but it should not be understood as a limitation on the scope of the patent. It should be pointed out that, for ordinary skilled persons in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application should be subject to the appended claims.

Claims

1. A machine learning-based intelligent dosing and effluent water quality prediction method, characterized in that: Includes the following steps: (1) Data collection: (2) Data processing in step (1): Data cleaning is performed on the collected data; data interpolation is performed on the missing data; data points where the dosage of polyaluminum chloride (PAC) and polyacrylamide (PAM) are both 0 are filtered out; feature engineering data is constructed. (3) Construction and parameter optimization of polyaluminum chloride (PAC) dosage prediction model: (3.1) Time series cross-validation data partitioning: The TimeSeriesSplit(n_splits=5) method is used to partition the entire time series data into 5-fold segments. The last split is selected as the validation set, and the others are used as the training set. (3.2) Model training and optimization: Set reasonable ranges for the key hyperparameters of the model; for each set of hyperparameters proposed by Optuna, train the model using the training set and make predictions on the validation set; The root mean square error between the predicted and actual values ​​is calculated as an evaluation index. The Optuna framework automatically adjusts the next set of hyperparameters to be tried based on the root mean square error, gradually approaching the optimal solution. When the optimal solution meets the early stopping condition, the polyaluminum chloride (PAC) dosage prediction model is obtained. The root mean square error (RMSE) is calculated using the following formula: Among them, y i For the true value, The value is the predicted value, and n is the number of samples in the validation set. (4) Total phosphorus (ESP) in sedimentation tank effluent t Predictive model construction and parameter optimization: (4.1) Constructing Input Features: The output value of the polyaluminum chloride (PAC) dosage prediction model in step (3), the feature engineering data obtained in step (2), and a portion of the original data in step (1) (process variables related to total phosphorus in the effluent of the sedimentation tank) are used as the total phosphorus (ESP) in the effluent of the sedimentation tank. t The input features of the prediction model; (4.2) Model Training and Optimization: Reasonable value ranges are set for the key hyperparameters of the model; for each set of hyperparameters proposed by Optuna, the model is trained using the training set and predictions are made on the validation set; the root mean square error between the predicted and actual values ​​is calculated as an evaluation metric; the Optuna framework automatically adjusts the next set of hyperparameters to be tried based on the root mean square error, gradually approaching the optimal solution. When the optimal solution meets the early stopping condition, the total phosphorus (ESP) in the effluent from the sedimentation tank is obtained. t Predictive models; The root mean square error (RMSE) is calculated using the following formula: Among them, y i For the true value, The value is the predicted value, and n is the number of samples in the validation set. (5) Feedback adjustment: Based on the total phosphorus (ESP) in the effluent from the sedimentation tank t The predicted values ​​of the prediction model and the total phosphorus OUT in the sedimentation tank effluent t The dosage of polyaluminum chloride (PAC) is dynamically adjusted based on measured values ​​to construct the total phosphorus process value, i.e., the total phosphorus (ESP) in the effluent from the sedimentation tank. t Predicted value, PAC adj,t The adjustment value is calculated in the following way: PAC adj,t =PAC pred,t ×α t PAC pred,t The predicted dosage of polyaluminum chloride (PAC) at time t; PAC adj,t This is the adjusted dosage value of polyaluminum chloride (PAC) at time t, which is the adjusted PAC dosage after feedback.

2. The intelligent dosing and effluent water quality prediction method based on machine learning according to claim 1, characterized in that: In step (1), the collected data include time, influent flow rate, COD, ammonia nitrogen, total nitrogen, total phosphorus, PAC dosage, effluent from the biological treatment tank, total phosphorus from the effluent from the rectangular secondary sedimentation tank, PAM dosage, total effluent, total phosphorus from the effluent from the sedimentation tank, dissolved oxygen, reflux ratio, and sludge concentration.

3. The intelligent dosing and effluent water quality prediction method based on machine learning according to claim 1, characterized in that: In step (2), the data preprocessing methods include: (2.1) The collected data was cleaned using the following methods: x represents the data to be processed. min x is the minimum value in the data. max The maximum value in the array; R + Let R be the set of positive real numbers; (2.2) Eliminate invalid operating conditions: Filter out data points where the dosage of PAC (polyaluminum chloride) and PAM (polyacrylamide) is 0 at the same time. At this time, the system is in an abnormal operating state (withdrawal period); (2.3) Imputing missing values: Missing values ​​are imputed using linear interpolation and forward / backward imputation strategies. That is, for any missing point x, t If there are known values ​​x before and after, t-k x t+m ,but: t represents time, and m and k represent time differences; (2.4) Constructing feature engineering data: (2.4.1) Characteristics of the rate of change: Δx t (1) =x t -x t-1 Δx t (2) =x t -x t-2 x represents the data to be processed; t represents time. (2.4.2) Characteristics of process combination: Where Q is the influent flow rate, X is the sludge concentration, COD is the chemical oxygen demand, TP is the total phosphorus, DO is the dissolved oxygen, and V is the effective volume of the biological treatment tank; ∈ represents 1e -6 ; (2.4.3) Characteristics of delayed drug response: The delayed drug response characteristics are captured using the lag term and moving average of PAC / PAM. in, The characteristics of delayed drug response; (2.4.4) Moving average characteristics: Where, σ t The moving average feature is used, and w is set to 3 to enhance the model's perception of fluctuations and trends over a 3-hour period.

4. The intelligent dosing and effluent water quality prediction method based on machine learning according to claim 1, characterized in that: In steps (3.2) and (4.2), Three machine learning models, XGboots, LightGBM, and / or CatBoost, are introduced, and the optimized parameters are reweighted to form the weight coefficients for each of the three models: The final prediction model is a weighted average prediction result:

5. The intelligent dosing and effluent water quality prediction method based on machine learning according to claim 1, characterized in that: In steps (3.2) and (4.2), the early stopping condition is: If a certain round k0 satisfies the following formula, then training stops at round k0+r: Where, m k Let m be the evaluation metric for the validation set in round k; * min 1≤i≤k m i , which is the historical best indicator; r is the number of patience rounds, which is 30.

6. The intelligent dosing and effluent water quality prediction method based on machine learning according to claim 1, characterized in that: In steps (3.2) and (4.2), the Optuna framework automatically adjusts the next set of hyperparameters to be tried based on the root mean square error using the following method: ① Divide the hyperparameters into two groups: High-performing hyperparameter: D l ={x:f(x)} <y * } Poorly performing hyperparameter: D g ={x:f(x)≥y * } Among them, y * The quantile of the objective function (e.g., the 10th percentile); ② Fit the probability density respectively: l(x)=p(x:f(x)<y * ) g(x)=p(x:f(x)≥y * ) ③ Next hyperparameter calculation: Where x is the hyperparameter vector, f(x) is the objective function value; y * is the threshold quantile (e.g., 10%) of the objective function; l(x) and g(x) are the conditional probability density functions.