Deep learning-based drainage pipe network water quality prediction method

By establishing a deep learning model in the urban drainage pipeline network, the BOD value of the water inlet of sewage treatment plants is predicted, the shortcomings of traditional manual monitoring are solved, monitoring efficiency and accuracy are improved, cost is reduced, and the screening basis for key nodes is provided.

CN120579437APending Publication Date: 2025-09-02ZHEJIANG INST OF HYDRAULICS & ESTUARY

Patent Information

Application Number
CN202510665415.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-22
Publication Date
2025-09-02

AI Technical Summary

Technical Problem

In the prior art, the water quality monitoring and management of urban drainage pipelines relies on traditional manual testing methods, with poor real-time performance, high labor costs, low efficiency, and difficult to cover all key nodes, affecting the water quality of the inlet of the sewage treatment plant and resulting in a decrease in the biochemical treatment effect.

Method used

Establish a water quality prediction model for drainage pipeline network based on deep learning. By selecting key pump station nodes, combining water quality indicators such as pH, SS, TP, COD, NH3-N and flow data, using linear regression, neural network and other algorithms for feature scaling and collinear detection, training RNN and LSTM models, predicting the BOD value of water inlet in sewage treatment plants, and screening out key nodes.

Benefits of technology

It realizes timely judgment on the biochemicalability of water inlet in sewage treatment plants, reduces manual testing costs, improves prediction accuracy, provides operational reference basis, solves the shortcomings of traditional monitoring methods, and reduces the frequency of random inspections of pump stations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120579437A_ABST
    Figure CN120579437A_ABST
Patent Text Reader

Abstract

The invention provides a drainage pipe network water quality prediction method based on deep learning, and belongs to the technical field of drainage pipe network water quality monitoring and prediction. The technical problems of poor real-time performance, high labor cost and low efficiency due to the fact that the conventional manual sampling and measuring method is still adopted for daily monitoring and management of the water quality of the urban drainage pipe network at present are solved. According to the technical scheme, the method comprises the steps of S1, determining input data and output data of a drainage pipe network water quality prediction model; s2, data preprocessing; s3, a prediction model is selected, model parameters are set and adjusted, the pump station-sewage treatment plant pipe network water quality process is simulated, and the prediction performance of the model is evaluated; s4, speculating key pump station water quality indexes influencing the biodegradability of the inflow water of the sewage treatment plant. The method has the beneficial effects that the key nodes influencing the inflow water quality of the sewage treatment plant are screened out through deep learning, and suggestions are provided for urban drainage monitoring management subsequently.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of drainage network water quality monitoring and prediction, and in particular to a drainage network water quality prediction method based on deep learning. Background Art

[0002] The urban sewage treatment system is an integrated "source-network-plant" system comprised of sewage treatment plants, pumping stations, and wastewater users. Currently, monitoring and management of urban drainage networks face numerous challenges, particularly the daily monitoring and management of water quality, which still relies on traditional manual sampling methods. These traditional manual monitoring methods have numerous limitations, such as long monitoring cycles, poor real-time performance, high labor costs, and low efficiency. Urban drainage networks consist of numerous branches, intersections, and tributaries, making it difficult to cover all key nodes through manual inspections. Furthermore, the instantaneous water quality during sampling at key wastewater users often fails to truly reflect the true impact of the problem. Furthermore, for sewage treatment plants, due to factors such as rainwater and sewage mixing and drainage overflow, lower levels of organic pollutants such as chemical oxygen demand (COD) and biochemical oxygen demand (BOD5) in the influent are insufficiently carbon-rich, resulting in reduced effectiveness of the biochemical treatment process and low removal rates of pollutants such as total nitrogen and total phosphorus, further impacting the water quality of receiving urban rivers. Therefore, there is an urgent need to further improve the urban sewage supervision methods, accurately implement water quality source monitoring and sewage discharge traceability management that exceeds the standard, and provide data reference for the refined control of sewage treatment plant processes.

[0003] In recent years, many researchers have established urban drainage water quality prediction models. For example, patent number CN118298963A, "A Drainage Network Water Quality Prediction Method Based on Long-Short-Term Memory Step Sequence," predicts the changing characteristics of drainage network water quality by analyzing key factors affecting drainage network water quality, such as land area, drainage pipe diameter, social indicators, water volume indicators, sewage flow, flow rate, and liquid level. This method is suitable for predicting the water quality of drainage nodes such as pumping stations, but lacks adaptability for predicting the influent water quality of complex drainage networks and sewage treatment plants. Furthermore, the input data lacks actual water quality monitoring data, raising questions about the accuracy of the output predictions.

[0004] For example, the invention patent with patent number CN 118886325 A, "A method and system for joint regulation of urban drainage systems", inputs data including the flow rate and velocity of rainwater and sewage at the collection point and inlet of rainwater and sewage, as well as the pH value, COD, BOD, NH3-N, and TP indicator data of rainwater and sewage. A single LSTM model is used to predict the total amount of rainwater and sewage entering the sewage treatment plant and the amount of COD, BOD, NH3-N, and TP. The model prediction accuracy is not high, and the key nodes that affect the water quality of the sewage treatment plant inlet are not screened out through deep learning. Subsequently, it provides suggestions for urban drainage monitoring and management, reduces the frequency of spot checks of pump stations with less impact, and effectively reduces the cost of manual sampling and testing.

[0005] Therefore, based on the current traditional manual data collection of urban drainage, it is very necessary to establish a deep learning coupling model to provide technical support for urban drainage supervision and sewage treatment plant process control. Summary of the Invention

[0006] The purpose of the present invention is to provide a method for predicting the water quality of a drainage network based on deep learning. In order to solve the technical problems that the daily monitoring and management of the water quality of the current urban drainage network still adopts the traditional manual sampling method, which has poor real-time performance, high labor costs and low efficiency, it is very necessary to establish a deep learning coupling model. At present, the prediction model for the water quality of urban drainage networks generally only predicts a single drainage node, or in the process of predicting the water quality of the sewage treatment plant inlet water, it does not compare the nodes of each pump station, and cannot find the key inspection blocks of urban drainage. Therefore, the present invention aims to propose a deep learning coupling model based on the collation of urban drainage sampling data for three consecutive years, to predict the COD and BOD values ​​of the sewage treatment plant inlet water, to determine the biodegradability of the incoming water, and to provide a reference basis for the operation of the sewage treatment plant in a timely manner; to screen out the key nodes that affect the water quality of the sewage treatment plant inlet water through deep learning, and to provide suggestions for urban drainage monitoring and management in the future.

[0007] In order to achieve the above-mentioned purpose, the present invention adopts a technical solution specifically as follows: a drainage network water quality prediction model based on deep learning, comprising the following steps:

[0008] (1) Determine the input and output data of the drainage network water quality prediction model

[0009] The inlet of a municipal sewage treatment plant is composed of various pumping stations. These pumping stations serve as sewage collection points for each district. With a large number of pumping stations, the flow of sewage between these stations is complex. Therefore, the first step is to identify key pumping stations based on the urban drainage network diagram. The principle of selection is to identify the sewage collection points for different urban districts, which are generally key confluence points.

[0010] In addition to determining the pumping station nodes, the selection of water quality indicators is also very important for input data. The pumping station water quality indicators for input data include pH, SS, TP, COD, and NH3-N. At the same time, the flow rate of each pumping station and the influent flow rate of the sewage treatment plant are also input data. Because the biodegradability of the sewage treatment plant's influent has a significant impact on the adjustment of subsequent treatment process parameters, the water quality indicator BOD / COD value can reflect the biodegradability of sewage. However, BOD testing requires 5 days and lacks timeliness. Therefore, the output data is determined to be the BOD value of the sewage treatment plant's influent water quality indicator.

[0011] (2) Data preprocessing

[0012] 21) After collecting all input and output data, first check the data quality and use a sliding time window to replace missing data and erroneous data in the input and output data to ensure that the quality of the input and output data of the prediction model meets the prediction requirements.

[0013] 22) Feature Scaling

[0014] For regression prediction problems, whether feature scaling is needed depends mainly on the type of model you plan to use. For example, for linear regression and logistic regression, although these models theoretically do not require features to be on the same scale, feature scaling can help improve the efficiency of gradient descent, making the training process faster and more stable; for decision trees and their derivative models, such as random forests and gradient boosting trees, these models are not sensitive to feature scaling because they divide the data space based on rules rather than distances or angles; for neural networks, feature scaling is very important when training neural networks because the weight update process depends on the scale of the input values. Appropriate feature scaling can accelerate the learning process and help avoid the problem of gradient disappearance or explosion.

[0015] Since the present invention adopts algorithms such as linear regression and neural network, feature scaling processing is required.

[0016] Because the measured concentrations of wastewater quality indicators are not sensitive to their range, standardization is employed. Standardization is generally more suitable for algorithms that assume zero mean and unit variance for input features, such as linear regression, logistic regression, and support vector machines (SVMs). It is also well-suited for neural networks, as it helps accelerate gradient descent and reduces the impact of features of different scales on weight updates.

[0017] Standardization is also called Z-score standardization, and the calculation formula is as follows:

[0018]

[0019] Where X′ is the normalized data point, X is the original data point, μ is the mean of the entire data set, and σ is the standard deviation of the entire data set.

[0020] 23) Collinearity Detection

[0021] In order to build an effective regression model, it is necessary to judge whether there is a collinearity problem between the water quality index characteristics of SS, TP, NH3-N and COD. Collinearity refers to the situation in a regression model where a predictor variable can be accurately predicted to some extent by other predictor variables. In simple terms, it refers to the high correlation between two or more input features. Collinearity can affect the estimation of the regression coefficient, making it unstable and difficult to explain. Collinearity can be detected by methods such as the correlation matrix and variance inflation factor (VIF) between the calculated variables. The present invention adopts the method of calculating VIF to detect collinearity, which measures how much the variance of the estimated coefficient has increased due to collinearity. Generally speaking, if the VIF value of a certain predictor variable exceeds 5 or 10, it is considered that there is a serious multicollinearity problem.

[0022] The VIF is calculated as follows: For a given predictor variable X i , and its VIF value is calculated by the following steps:

[0023] 231) Perform auxiliary regression: X i A linear regression analysis was performed with as the response variable and all other predictor variables in the model as independent variables.

[0024] 232) Calculate the coefficient of determination: The coefficient of determination R obtained from the above linear regression 2 Indicates the relationship between the independent variable and X in the auxiliary regression i The degree of variability explained.

[0025] 233) Calculate VIF: Use the following formula to calculate X i Corresponding VIF values:

[0026] Among them, R i 2 is the coefficient of determination of the model obtained by regressing the i-th predictor variable as the response variable with all other predictor variables.

[0027] (3) Select a prediction model, set and adjust the model parameters, simulate the water quality process of the pump station-wastewater treatment plant network, and evaluate the prediction performance of the model

[0028] 31) Model selection

[0029] This paper selects common machine learning models such as linear regression, polynomial regression, decision tree regression, random forest regression, gradient boosting (such as XGBoost), neural network, recurrent neural network (RNN), and long short-term memory neural network (LSTM) for training, and finally compares their prediction performance for the water quality process of the pump station-sewage treatment plant pipeline network.

[0030] 32) Model Training

[0031] Next, taking RNN as an example, the training process of the model is explained as follows:

[0032] 311) Data preparation: Convert the water quality indicator concentration data into a form suitable for RNN input. In this case, convert it into a PyTorch tensor.

[0033] 312) Initialize model parameters: including initializing all weights and biases of the RNN model; fixed parameters of the model, including the number of RNN layers, feature dimensions, and output dimensions; hyperparameters that can be tuned, including learning rate, hidden layer size, etc.

[0034] 313) Forward propagation: For a given input, RNN performs forward propagation through the following steps:

[0035] Calculation of time step t: Starting from the first element of the sequence, apply the same set of weights to each time step t and update the hidden state. Hidden state h t According to the current input x t and the hidden state h at the previous moment t-1 Calculated:

[0036] h t =f(W h [h t-1 , x t ]+b h )

[0037] Among them, W h is the weight matrix, b h is the bias term, and f is the activation function (such as tanh, ReLU).

[0038] Output calculation: Based on the hidden state of the last time step, the value of the output layer is calculated.

[0039] 314) Loss calculation: Calculate the loss based on the forward propagation result and the true label. The commonly used loss function is mean square error (MSE).

[0040] 315) Backpropagation: Because RNNs involve sequential information, the traditional backpropagation algorithm is extended to "backpropagation through time." This means that the gradient of the loss with respect to the weights depends not only on the state at the current time step, but also on the state at all previous time steps. Backpropagation gradually adjusts the weights at each time step in reverse order to reduce the loss function.

[0041] 316) Parameter Update: Update the network’s weights and biases using an optimization algorithm (e.g., SGD, Adam, etc.). These updates aim to minimize the loss function, thereby improving the model’s ability to predict future unseen data.

[0042] 317) Iterative training: Repeat the above process of forward propagation, loss calculation, backpropagation and parameter update multiple times until a certain stopping condition is met (for example, the maximum number of iterations is reached or the loss change is less than the set threshold).

[0043] 33) Model Evaluation

[0044] In the evaluation of regression prediction models, commonly used evaluation indicators include mean square error (MSE), root mean square error (RMSE), mean absolute error (MAE), coefficient of determination (R 2 ), etc. This case calculates the most commonly used MSE for regression models.

[0045] MSE is the average of the squares of the differences between the predicted values ​​and the true values. It is calculated as follows:

[0046]

[0047] where y i represents the true value of the i-th sample, represents the corresponding predicted value, and n is the number of samples.

[0048] 34) Model Tuning

[0049] The model's hyperparameters are tuned using grid search and K-fold cross-validation. For neural networks, these hyperparameters primarily include learning rate, batch size, number of layers, and number of nodes per layer.

[0050] (4) Estimate the key pumping station water quality indicators that affect the biodegradability of sewage treatment plant influent

[0051] The present invention adopts the method of permutation importance to explore which features have a more significant impact on the prediction results.

[0052] Permutation importance is a method for assessing the impact of a feature on a model's predictive ability. The basic principle is to measure the importance of a feature by observing how model performance changes when its values ​​are randomly perturbed. If a feature is critical to the model's predictions, then performance will significantly decrease when its values ​​are perturbed. Conversely, if perturbing a feature's values ​​has no significant impact on model performance, then this feature is not particularly important to the model's predictions.

[0053] The specific steps for ranking importance are as follows:

[0054] 41) Initial model performance evaluation: First, use the trained model to make predictions on the original dataset and record the model’s performance indicators (such as MSE, etc.).

[0055] 42) Feature value shuffling: Select a feature and randomly shuffle its values ​​in the test set. This means redistributing the values ​​of the feature so that any correlation in the original sequence is destroyed, but other features remain unchanged.

[0056] 43) Model performance re-evaluation: Use the processed data to run the model again and calculate new performance indicators.

[0057] 44) Calculate importance score: The importance score of a feature can be determined by comparing the performance of the model before and after shuffling.

[0058] Typically, the importance score is defined as the MSE of the feature after shuffling minus the original MSE.

[0059] 45) Repeat step 42) to step 44): Repeat the above process for each feature to obtain the importance scores of all features.

[0060] 46) Interpretation: By ranking each feature by its importance score, we can identify which features are most critical to the model's predictions. The higher the score, the more important the corresponding feature.

[0061] Compared with the prior art, the present invention has the following beneficial effects:

[0062] 1. The present invention discloses a water quality prediction model for drainage pipe networks based on deep learning. By predicting the BOD value of the influent of the sewage treatment plant and determining the biodegradability of the influent, the model provides a timely operational reference for the sewage treatment plant and the timeliness of the BOD data. Through deep learning, the model screens out the key nodes that affect the influent quality of the sewage treatment plant, and subsequently provides suggestions for urban drainage monitoring and management, reducing the frequency of random inspections of pumping stations with less impact, and effectively reducing the cost of manual sampling and testing. The water quality of each major pumping station node reflects the overall operational problems of the sewage system in different blocks, providing a basis for subsequent inspections of key drainage users, and solving the technical problem that manual inspections are difficult to cover all key nodes and are inefficient.

[0063] 2. This paper selects common machine learning models such as linear regression, polynomial regression, decision tree regression, random forest regression, gradient boosting (such as XGBoost), neural network, recurrent neural network (RNN), long short-term memory neural network (LSTM) for training and compares their prediction performance. The mean square error (MSE), root mean square error (RMSE), mean absolute error (MAE), coefficient of determination (R 2) and other common evaluation indicators to evaluate the prediction results, and finally the model with the best prediction performance was selected for prediction, which improved the accuracy of the previous single model prediction, and used the measured data of the main water quality indicators of the pumping station for three consecutive years for prediction, which further improved the accuracy of the model prediction.

[0064] 3. For sewage treatment plants, COD and BOD5 are important indicators for judging the biodegradability of influent, which will affect the adjustment of subsequent biochemical treatment process parameters. However, since the experimental test results of BOD5 take 5 days, the timeliness is poor. This invention predicts the BOD5 / COD value of sewage treatment plants for the first time, providing a timely reference for the operation of sewage treatment plants.

[0065] 4. The present invention adopts the method of ranking importance to explore the pumping stations and water quality indicators that mainly affect the biodegradability of the influent of the sewage treatment plant, which is conducive to identifying key inspection targets in subsequent urban drainage monitoring and management, and effectively reducing the cost of manual sampling and testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0066] The accompanying drawings are used to provide further understanding of the present invention and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention and do not constitute a limitation of the present invention.

[0067] Figure 1 This is a flow chart of the drainage network water quality prediction model based on deep learning in the present invention.

[0068] Figure 2 This is a graph of the loss changes corresponding to the iterative process of RNN model training in Example 1 of the present invention.

[0069] Figure 3 This is a comparison chart of the model prediction performance of Example 1 of the present invention.

[0070] Figure 4 This is a schematic diagram of the importance ranking results calculated by the RNN model in Example 1 of the present invention.

[0071] Figure 5 This is a comparison chart of the model prediction performance of Example 2 of the present invention.

[0072] Figure 6 This is a schematic diagram of the importance ranking results calculated by the RNN model in Example 2 of the present invention. DETAILED DESCRIPTION

[0073] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. Of course, the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0074] Example 1

[0075] This embodiment provides a technical solution, which is a method for predicting water quality in a drainage network based on deep learning, including the following:

[0076] step:

[0077] (1) Data collection

[0078] We selected the actual manual measurement data of the drainage network of a southern city, including the data of each pump station and sewage treatment plant. First, we used the sewage flow diagram of the drainage network of the city (see Appendix). Figure 2 ) Determine the input pump station nodes and output sewage treatment plant nodes. The output sewage treatment plant is determined to be the inlet water of the Qige Phase III Sewage Treatment Plant, and the output water quality index is the BOD5 / COD value; the input pump stations include five key nodes: the large Hemugang Pump Station, Xintang Road Pump Station, Sibao Pump Station, Songyue Pump Station, and Coral Sand Pump Station. The input data includes SS, COD, TP, and NH3-N. Considering the impact of the sewage flow rate of each pump station on the sewage treatment plant node, the above four indicators are multiplied by the corresponding pump station sewage flow rate, for a total of 20 input characteristics. The input data is the measured data from January 2022 to December 2024, and the measurement frequency is once every two weeks.

[0079] (2) Data preprocessing

[0080] After collecting all input and output data, the data quality is checked and a sliding time window is used to replace missing data and erroneous data in the input and output data to ensure that the quality of the input and output data of the prediction model meets the prediction requirements.

[0081] The dataset after data preprocessing operations such as cleaning outliers and missing values ​​is shown in Table 1 below: (Due to space limitations, only 5 data are shown, the same below):

[0082] Table 1

[0083]

[0084] Where x11, x12, x13, and x14 are the concentrations of SS, COD, TP, and NH3-N at the first pumping station (the large Harmony Harbor pumping station) multiplied by the flow rate at the corresponding pumping station, and so on. Y is the BOD5 / COD ratio of the sewage treatment plant.

[0085] (3) Feature Scaling

[0086] For regression prediction problems, whether feature scaling is needed depends mainly on the type of model you plan to use. For example, for linear regression and logistic regression, although these models theoretically do not require features to be on the same scale, feature scaling can help improve the efficiency of gradient descent, making the training process faster and more stable; for decision trees and their derivative models (such as random forests and gradient boosting trees), these models are not sensitive to feature scaling because they divide the data space based on rules rather than distances or angles; for neural networks, feature scaling is very important when training neural networks because the weight update process depends on the scale of the input values. Appropriate feature scaling can speed up the learning process and help avoid the problem of vanishing or exploding gradients.

[0087] In summary, since this case will use algorithms such as linear regression and neural networks, feature scaling is performed.

[0088] Since this data is not sensitive to value range, normalization is used. Normalization is generally more suitable for algorithms that assume zero mean and unit variance for input features, such as linear regression, logistic regression, and support vector machines (SVM). It is also suitable for neural networks because it helps speed up gradient descent and reduces the impact of features of different scales on weight updates.

[0089] Standardization is also called Z-score standardization, and the calculation formula is as follows:

[0090]

[0091] Where X′ is the normalized data point, X is the original data point, μ is the mean of the entire data set, and σ is the standard deviation of the entire data set.

[0092] The eigenvalues ​​after standardization are shown in Table 2 below:

[0093] Table 2

[0094]

[0095]

[0096] (4) Collinearity detection

[0097] To build an effective regression model, it is necessary to determine whether there is collinearity between features. Collinearity refers to a situation in which one predictor variable in a regression model can be predicted with some accuracy by other predictors. Simply put, it refers to a high degree of correlation between two or more input features. Collinearity can affect the estimation of regression coefficients, making them unstable and difficult to interpret. Collinearity can be detected by calculating the correlation matrix between variables and the variance inflation factor (VIF). In this case, the VIF method is used to detect collinearity. It measures the increase in the variance of the estimated coefficients due to collinearity. Generally speaking, if the VIF value of a predictor variable exceeds 5 or 10, it is considered to be a serious multicollinearity problem.

[0098] The VIF is calculated as follows: For a given predictor variable X i , and its VIF value is calculated by the following steps:

[0099] 1. Perform auxiliary regression: X i A linear regression analysis was performed with as the response variable and all other predictor variables in the model as independent variables.

[0100] 2. Calculate the coefficient of determination: The coefficient of determination R obtained from the above linear regression 2 Indicates the relationship between the independent variable and X in the auxiliary regression i The degree of variability explained.

[0101] 3. Calculate VIF: Use the following formula to calculate X i Corresponding VIF values:

[0102] Among them, R i 2 is the coefficient of determination of the model obtained by regressing the i-th predictor variable as the response variable with all other predictor variables.

[0103] The VIF of each feature is calculated as follows:

[0104] x11:1.692248

[0105] x12: 1.718942

[0106] x13: 2.013547

[0107] x14: 3.128397

[0108] x21:3.258746

[0109] x22:2.200737

[0110] x23:3.677663

[0111] x24: 2.451732

[0112] x31: 3.404900

[0113] x32: 2.035785

[0114] x33:4.457972

[0115] x34:3.162207

[0116] x41:2.223254

[0117] x42:1.380807

[0118] x43:1.681718

[0119] x44:2.340306

[0120] x51:2.551613

[0121] x52:1.404019

[0122] x53:3.808513

[0123] x54:1.813421

[0124] It was found that all VIF values ​​were less than 5, indicating that there was no serious collinearity between the variables.

[0125] (5) Model selection

[0126] This case selected common machine learning models such as linear regression, polynomial regression, decision tree regression, random forest regression, gradient boosting (such as XGBoost), neural network, recurrent neural network (RNN), and long short-term memory neural network (LSTM) for training, and finally compared their prediction performance.

[0127] (6) Model training

[0128] Next, taking RNN as an example, the training process of the model is explained.

[0129] 1. Data preparation: Convert the data into a form suitable for RNN input. In this case, convert it into a PyTorch tensor.

[0130] 2. Initialize model parameters: This includes initializing all weights and biases of the RNN model; fixed parameters of the model, including the number of RNN layers, feature dimensions, and output dimensions; and tunable hyperparameters, including the learning rate and hidden layer size.

[0131] 3. Forward propagation: For a given input, RNN performs forward propagation through the following steps:

[0132] Calculation of time step t: Starting from the first element of the sequence, apply the same set of weights to each time step t and update the hidden state. Hidden state h t According to the current input x t and the hidden state h at the previous moment t-1 Calculated:

[0133] h t =f(W h [h t-1 , x t ]+b h )

[0134] Among them, W h is the weight matrix, b h is the bias term, and f is the activation function (such as tanh, ReLU).

[0135] Output calculation: Based on the hidden state of the last time step, the value of the output layer is calculated.

[0136] 4. Loss calculation: Calculate the loss based on the forward propagation results and the true label. The commonly used loss function is mean square error (MSE).

[0137] 5. Backpropagation: Because RNNs involve sequential information, the traditional backpropagation algorithm is extended to "backpropagation through time." This means that the gradient of the loss with respect to the weights depends not only on the state at the current time step, but also on the state at all previous time steps. Backpropagation gradually adjusts the weights at each time step in reverse order to reduce the loss function.

[0138] 6. Parameter Update: Update the network’s weights and biases using an optimization algorithm (e.g., SGD, Adam, etc.). These updates aim to minimize the loss function, thereby improving the model’s ability to predict future unseen data.

[0139] 7. Iterative training: Repeat the above process of forward propagation, loss calculation, backpropagation and parameter update multiple times until a stopping condition is met (for example, the maximum number of iterations is reached or the loss change is less than the set threshold).

[0140] Down Figure 2 The corresponding loss change image during the RNN model training iteration is as follows:

[0141] (7) Model evaluation

[0142] In the evaluation of regression prediction models, commonly used evaluation indicators include mean square error (MSE), root mean square error (RMSE), mean absolute error (MAE), coefficient of determination (R 2 ) etc. This example calculates the most commonly used MSE for regression models. MSE is the average of the squares of the differences between the predicted values ​​and the true values. Its calculation formula is as follows:

[0143]

[0144] where y i represents the true value of the i-th sample, represents the corresponding predicted value, and n is the number of samples.

[0145] This case evaluated the prediction performance of multiple models including linear regression, polynomial regression, decision tree regression, random forest regression, gradient boosting (such as XGBoost), neural network, recurrent neural network (RNN), long short-term memory neural network (LSTM), etc. The evaluation results are as follows Figure 3 :

[0146] It can be seen that for this data set, RNN has the smallest MSE, indicating that its model performs best.

[0147] (8) Model tuning

[0148] The model's hyperparameters were tuned using grid search and K-fold cross-validation. For neural networks, these hyperparameters primarily include the learning rate, batch size, number of layers, and the number of nodes per layer. In this case, the RNN model performed optimally when the learning rate was 0.001 and the hidden layer size was 32.

[0149] (9) Feature Importance Assessment

[0150] This case uses the permutation importance method to explore which features have a more significant impact on the prediction results.

[0151] Permutation importance is a method for assessing the impact of a feature on a model's predictive ability. The basic principle is to measure the importance of a feature by observing how model performance changes when its values ​​are randomly perturbed. If a feature is critical to the model's predictions, then performance will significantly decrease when its values ​​are perturbed. Conversely, if perturbing a feature's values ​​has no significant impact on model performance, then this feature is not particularly important to the model's predictions.

[0152] The specific steps for ranking importance are as follows:

[0153] 1. Initial model performance evaluation: First, use the trained model to make predictions on the original dataset and record the model's performance indicators (such as MSE, etc.). This is the baseline performance.

[0154] 2. Feature value shuffling: Select a feature and randomly shuffle its values ​​in the test set. This means redistributing the value of the feature so that any correlation in the original sequence is destroyed, but other features remain unchanged.

[0155] 3. Model performance re-evaluation: Run the model again using the processed data and calculate new performance indicators.

[0156] 4. Calculate the importance score: The importance score of a feature can be determined by comparing the performance of the model before and after shuffling. Usually, the importance score is defined as the MSE of the feature after shuffling minus the original MSE.

[0157] 5. Repeat steps 2-4: Repeat the above process for each feature to obtain the importance scores of all features.

[0158] 6. Result Interpretation: By ranking each feature by its importance score, you can identify which features are most critical to the model's predictions. The higher the score, the more important the corresponding feature.

[0159] The results of calculating the importance of permutation for the RNN model in this case are as follows Figure 4 As shown:

[0160] It was found that x53 had the highest importance score, followed by x52, indicating that the TP and COD indicators of the Coral Sand Pumping Station had the most significant impact on the BOD5 / COD predicted value of the Qige Phase III Wastewater Treatment Plant.

[0161] Example 2

[0162] The above method is used to predict the BOD5 / COD value (Y) of the Chengxi Wastewater Treatment Plant. The input data are SS, COD, TP, and NH3-N of the Zhangjiayang pumping station multiplied by the corresponding pumping station sewage flow, with a total of 4 input features (x1, x2, x3, x4).

[0163] The original data is shown in Table 3 below:

[0164] Table 3

[0165] x1 x2 x3 x4 Y 46431286 37109854 1167769 5841068 0.1686461 47486543 66657036 1183670 11344007 0.2080997 61575934 41050623 711108 2524462 0.1853521 91454552 55860025 1638624 15499654 0.182808 65202635 27245387 1637693 12781047 0.1984091

[0166] The eigenvalues ​​after standardization are shown in Table 4:

[0167] Table 4

[0168] x1 x2 x3 x4 -0.44838 -0.96022 -1.02562 -1.76001 -0.40983 -0.56340 -0.99781 -0.81481 0.10483 -0.90730 -1.82451 -2.32968 1.19624 -0.70840 -0.20190 -0.10102 0.23730 -1.09270 -0.20353 -0.56798

[0169] VIF value of each feature:

[0170] x1: 1.151353

[0171] x2: 1.309804

[0172] x3: 1.746933

[0173] x4: 1.449892

[0174] It was found that all VIF values ​​were less than 5, indicating that there was no serious collinearity between the variables.

[0175] The model behaves as Figure 3 As shown:

[0176] For this dataset, the LSTM model performs best.

[0177] The importance of the arrangement of each indicator of the LSTM model is as follows Figure 4 As shown:

[0178] It was found that x3 had the highest importance score, indicating that the TP index of Zhangjiayang Pumping Station had the most significant impact on the BOD5 / COD prediction of Chengxi Wastewater Treatment Plant.

[0179] Through the above two examples, the following conclusions can be drawn:

[0180] 1. The SS, COD, TP, and NH3-N indicator data at the pump station node can effectively predict the BOD5 / COD value at the sewage treatment plant node.

[0181] 2. The RNN-based deep learning model (LSTM can be regarded as a special form of RNN) has better prediction effects for such problems.

[0182] 3. Compared with water quality indicators such as SS, COD, and NH3-N, the TP concentration of pumping station sewage has a more significant impact on the BOD5 / COD prediction of the sewage treatment plant.

[0183] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A drainage network water quality prediction method based on deep learning, characterized in that: The steps include: S1. Determine the input and output data of the drainage network water quality prediction model The inlet of a municipal sewage treatment plant is composed of various pumping stations. The pumping stations are the sewage collection points of each block. There are many pumping stations, and the separation and merging of sewage between pumping stations is complex. First, according to the urban drainage network map, the pumping stations at key nodes are found. The principle of selection is to reflect the sewage collection points of different urban blocks, that is, the key confluence points; S2. Data Preprocessing S21) After all input and output data are collected, the data quality is first checked, and missing data and erroneous data in the input and output data are replaced using a sliding time window to ensure that the quality of the input and output data of the prediction model meets the prediction requirements; S22) Feature Scaling For regression prediction problems, whether feature scaling is necessary depends on the type of model you plan to use; Since the measured concentrations of sewage quality indicators are not sensitive to the value range, a standardization method is used. Standardization is suitable for algorithms that assume that the input features have zero mean and unit variance; Standardization is also called Z-score standardization, and the calculation formula is as follows: Where X′ is the normalized data point, X is the original data point, μ is the mean of the entire data set, and σ is the standard deviation of the entire data set; S23) Collinearity Detection Collinearity refers to the high correlation between two or more input features in a regression model. Collinearity affects the estimation of the regression coefficient. It is detected by calculating the correlation matrix and variance inflation factor (VIF) between variables. The VIF calculation method is used to detect collinearity. S3. Select a prediction model, set and adjust the model parameters, simulate the water quality process of the pump station-wastewater treatment plant network, and evaluate the prediction performance of the model S31) Model selection We trained machine learning models using linear regression, polynomial regression, decision tree regression, random forest regression, gradient boosting (XGBoost), neural networks, recurrent neural networks (RNNs), and long short-term memory (LSTMs) to compare their performance in predicting water quality in the pumping station-wastewater treatment plant network. S32) model training; S33) Model evaluation In the evaluation of regression prediction models, the evaluation indicators include mean square error MSE, root mean square error RMSE, mean absolute error MAE, determination coefficient R 2 , calculate the regression model using MSE; MSE is the average of the squares of the differences between the predicted values ​​and the true values, and is calculated as follows: where y i represents the true value of the i-th sample, represents the corresponding predicted value, n is the number of samples; S34) Model Tuning Tune the model's hyperparameters using grid search and K-fold cross-validation. For neural networks, these hyperparameters include learning rate, batch size, number of layers, and number of nodes per layer. S4. Estimate the key pumping station water quality indicators that affect the biodegradability of sewage treatment plant influent; The permutation importance method is used to explore which features have a more significant impact on the prediction results.

2. The method for predicting water quality of drainage pipe network based on deep learning according to claim 1, characterized in that: In step S1, in addition to determining the pump station node, the water quality index is one of the input data indicators. The pump station water quality indicators of the input data include pH, SS, TP, COD, NH3-N. The flow rate of each pump station and the influent flow rate of the sewage treatment plant are also input data. The output data is determined to be the BOD value of the influent water quality indicator of the sewage treatment plant.

3. The method for predicting water quality of drainage pipe network based on deep learning according to claim 1, characterized in that: In step S23, the VIF is calculated as follows: for a given predictor variable X i , and its VIF value is calculated by the following steps: S231), perform auxiliary regression: X i A linear regression analysis was conducted using as the response variable and all other predictor variables in the model as independent variables; S232) Calculate the coefficient of determination: The coefficient of determination R obtained from the above linear regression 2 Indicates the independent variable X in the auxiliary regression i The degree of variability explained. S233) Calculate VIF: Use the following formula to calculate X i Corresponding VIF values: Among them, R i 2 is the coefficient of determination of the model obtained by regressing the i-th predictor variable as the response variable with all other predictor variables.

4. The method for predicting water quality of drainage pipe network based on deep learning according to claim 1, characterized in that: In step S31, the RNN training process is as follows: S311) Data preparation: Convert the water quality index concentration data into a form suitable for RNN input and convert it into a PyTorch tensor; S312) Initialize model parameters: including initializing all weights and bias terms of the RNN model; fixed parameters of the model, including the number of RNN layers, feature dimensions, and output dimensions; hyperparameters to be tuned, including learning rate and hidden layer size; S313) Forward propagation: For a given input, RNN performs forward propagation through the following steps: Calculation of time step t: Starting from the first element of the sequence, apply the same set of weights to each time step t and update the hidden state, the hidden state h t According to the current input x t and the hidden state h at the previous moment t-1 Calculation yields: h t =f(W h [h t-1 ,x t ]+b h ) Among them, W h is the weight matrix, b h is the bias term, f is the activation function; Output calculation: Based on the hidden state of the last time step, calculate the value of the output layer; S314) Loss calculation: Calculate the loss based on the result of forward propagation and the true label. The commonly used loss function is mean square error (MSE). S315) Back propagation: Since RNN involves sequence information, the back propagation algorithm is a back propagation through time. That is, the gradient of the loss relative to the weight depends on the state of the current time step and the state of all previous time steps. Back propagation gradually adjusts the weight at each time step in reverse order of time to reduce the loss function; S316) Parameter update: Use optimization algorithms to update the network weights and biases. The update aims to minimize the loss function and improve the model's ability to predict future unseen data. S317) Iterative training: Repeat the above-mentioned forward propagation, loss calculation, back propagation and parameter update process cyclically until the stopping condition is met, that is, the maximum number of iterations is reached or the loss change is less than the set threshold, and then exit the loop.

5. The method for predicting water quality of drainage pipe network based on deep learning according to claim 1, characterized in that: In step S4, the specific steps of arranging the importance are as follows: S41) Initial model performance evaluation: First, use the trained model to make predictions on the original dataset and record the model's performance indicators; S42) Feature value shuffling: Select a feature, randomly shuffle its value in the test set, and redistribute the value of the feature so that any correlation in the original sequence is destroyed and other features remain unchanged; S43) Model performance re-evaluation: Use the processed data to run the model again and calculate new performance indicators. S44) Calculate the importance score: The importance score of a feature can be determined by comparing the performance difference of the model before and after the shuffle. The importance score is defined as the MSE of the feature after shuffling minus the original MSE; S45), repeat step S42) to step S44): repeat the above process for each feature to obtain the importance scores of all features; S46) Result interpretation: Sort by the importance score of each feature to identify which features are most critical to the model's prediction. The higher the score, the more important the corresponding feature.

Citation Information

Patent Citations

  • Drainage pipe network water quality prediction method based on long and short term memory step sequence

    CN118298963A

  • Combined regulation and control method and system for urban drainage system

    CN118886325A

Cited By

  • Water plant raw water quality data fault diagnosis method and system

    CN121144761A

  • Method for predicting BOD (Biochemical Oxygen Demand) of hourly inflow of sewage plant based on multi-element machine learning fusion

    CN121502720A

  • A sewage plant hourly influent BOD prediction method based on multi-element machine learning fusion

    CN121502720B