Sewage treatment plant inflow prediction method based on data decomposition and deep learning
By constructing the STL-AmTCN hybrid model, using data decomposition and attention mechanism to treat water inlet prediction in sewage treatment plants, the problem of insufficient prediction accuracy when processing complex data is solved, and higher accuracy and adaptability are achieved , suitable for frequent and outliers time series data, reduces operating costs and reduces carbon emissions.
Patent Information
- Application Number
- CN202411120143.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-15
- Publication Date
- 2024-12-03
AI Technical Summary
The existing water inlet prediction method for sewage treatment plants relies on a single deep learning model, making it difficult to effectively process complex nonlinear and time-varying data, resulting in insufficient prediction accuracy and poor adaptability.
A mixed model (STL-AmTCN) based on local weighted regression based on seasonal term-trend decomposition data decomposition method (STL) and attention mechanism combined with modern time convolutional structure (modernTCN) was constructed for multi-dimensional feature enhancement extraction. Water inlet prediction. The model enhances time-changing features through data decomposition and feature extraction, and uses attention mechanisms and fully connected layers for prediction.
It improves the accuracy and reliability of water quality prediction of sewage treatment plants, and is suitable for frequent and outliers time series data, achieving efficient operation and reducing operating costs and reducing carbon emissions.
Smart Images

Figure CN119067472A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a method for predicting water inflow of a sewage treatment plant based on data decomposition and deep learning, and belongs to the field of sewage treatment. Background Art
[0003] With the development of data science and artificial intelligence technology, the existing sewage treatment plant inflow prediction methods mainly rely on deep learning, which has shown great potential in processing large-scale complex data, extracting data features and modeling prediction. However, when dealing with complex nonlinear and time-varying data, a single deep learning model often shows the shortcomings of insufficient prediction accuracy and poor adaptability. Summary of the invention
[0004] In order to improve the prediction accuracy of the influent water quality of sewage treatment plants, realize the efficient operation of sewage treatment, realize the intelligence of sewage treatment plants on the basis of ensuring the stable and standard discharge of effluent, reduce the operation cost, and reduce the carbon emission of sewage treatment, the present invention provides a seasonal term-trend decomposition data decomposition method (STL) based on local weighted regression, an attention mechanism (Attention) and a modern temporal convolution structure (modernTCN) deep learning model for time series analysis, referred to as a hybrid model of multidimensional feature enhancement extraction (STL-AmTCN), and use STL-AmTCN to perform future influent prediction to improve the accuracy of influent water quality prediction of sewage treatment plants. The technical scheme is as follows:
[0005] A method for predicting water inflow in a sewage treatment plant according to the present invention comprises:
[0006] Step 1: Obtain historical time series data of sewage treatment plant influent indicators and perform preprocessing;
[0007] Step 2: Use the STL time series decomposition method to decompose the historical time series data of the indicator to be predicted into trend component, seasonal component and residual component;
[0008] Step 3: extracting features of the trend component, seasonal component, residual component and auxiliary variables of the indicator to be predicted, and obtaining updated trend component, seasonal component and residual component respectively, wherein the auxiliary variables are: historical time series data of water inflow indicators other than the indicator to be predicted;
[0009] Step 4: Strengthen the time variation features extracted in step 3;
[0010] Step 5: Decode the enhanced time-varying features obtained in step 4 to obtain the predicted value of the indicator to be predicted.
[0011] Optionally, the step 3 uses a feature extraction module to extract features of the trend component, seasonal component, residual component and auxiliary variable of the indicator to be predicted, and the feature extraction module includes: a feature embedding layer and a modern time convolution layer;
[0012] The feature embedding layer uses convolution to increase the dimension of data features;
[0013] The structure of the modern temporal convolution layer includes: depth-wise convolution, batch normalization layer, point-by-point convolution layer in sequence; the point-by-point convolution layer contains two layers, each of which includes the following structure: the first layer of point-by-point convolution, Dropout layer, GELU activation function layer, the second layer of point-by-point convolution, Dropout layer; the output of each layer of modern temporal convolution layer is added to the input, so that the model only learns its residual information to avoid overfitting of the model.
[0014] Optionally, the step 4 uses the attention mechanism layer to add the trend component, the updated seasonal component and the updated residual component updated in step 3 to form the time information sequence H to be processed. The time information sequence H passes through the linear transformation layer and performs matrix multiplication with the original sequence, and scores each moment of the time series through the SoftMax activation function to generate a weight matrix A. The weight matrix A is multiplied by the time information sequence H to obtain the enhanced time information sequence feature H'.
[0015] Optionally, the step 5 uses a fully connected layer to process the enhanced features, and the structure of the fully connected layer includes in sequence: a first linear transformation layer, a Tanh activation function layer, and a second linear transformation layer.
[0016] A sewage treatment plant inflow prediction system of the present invention comprises:
[0017] A data acquisition module is configured to acquire historical time series data of influent water quality indicators of a sewage treatment plant;
[0018] A data preprocessing module, configured to preprocess the historical time series data;
[0019] A data decomposition module is configured to decompose the historical time series data of the indicator to be predicted into a trend component, a seasonal component and a residual component by using an STL time series decomposition method;
[0020] A feature extraction module is configured to extract features of the trend component, seasonal component, residual component and auxiliary variable of the indicator to be predicted, and obtain updated trend component, seasonal component and residual component respectively, wherein the auxiliary variable is: historical time series data of water inflow indicators other than the indicator to be predicted;
[0021] A time feature enhancement module, configured to enhance the extraction of the extracted time variation features;
[0022] The decoding and prediction module is configured to decode the enhanced time variation feature obtained by the time feature enhancement module to obtain the predicted value of the indicator to be predicted.
[0023] Optionally, the feature extraction module includes: a feature embedding layer and a modern temporal convolution layer;
[0024] The feature embedding layer uses convolution to increase the dimension of data features;
[0025] The structure of the modern temporal convolution layer includes: depth-wise convolution, batch normalization layer, point-by-point convolution layer in sequence; the point-by-point convolution layer contains two layers, each of which includes the following structure: the first layer of point-by-point convolution, Dropout layer, GELU activation function layer, the second layer of point-by-point convolution, Dropout layer; the output of each layer of modern temporal convolution layer is added to the input, so that the model only learns its residual information to avoid overfitting of the model.
[0026] Optionally, the time feature enhancement module is an attention mechanism layer, which adds the updated trend component, seasonal component and residual component extracted by the feature extraction module to form a time information sequence H to be processed. The time information sequence H passes through a linear transformation layer and performs matrix multiplication with the original sequence. The SoftMax activation function is used to score each moment of the time series to generate a weight matrix A. The weight matrix A is multiplied by the time information sequence H to obtain the enhanced time information sequence feature H'.
[0027] Optionally, the decoding and prediction module uses a fully connected layer to process the features output by the temporal feature enhancement module, and the structure of the fully connected layer includes, in sequence: a first linear transformation layer, a Tanh activation function layer, and a second linear transformation layer.
[0028] The present invention provides an electronic device, comprising a memory and a processor;
[0029] The memory is used to store computer programs;
[0030] The processor is configured to implement the method described above when executing the computer program.
[0031] The present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described above is implemented.
[0032] The beneficial effects of the present invention are:
[0033] The present invention constructs a hybrid model of multidimensional feature enhanced extraction (STL-AmTCN) and uses STL-AmTCN to predict future water inflow. Aiming at the complex changes in water quality and quantity of sewage treatment plants, the water inflow prediction method of the present invention can better handle the nonlinear characteristics and noise in the data. Experimental results show that the present invention can improve the accuracy, reliability and timeliness of water inflow prediction.
[0034] The STL-AmTCN water inlet prediction hybrid model constructed by the present invention is suitable for more frequent time series data with outliers; the deep learning model used in the prediction module is ModernTCN, which takes into account both efficiency and performance, helps to achieve efficient operation of sewage treatment, and realizes the intelligence of sewage treatment plants on the basis of ensuring stable and standard discharge of effluent, thereby reducing operating costs and carbon emissions from sewage treatment. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0036] Figure 1 It is a schematic flow chart of the sewage treatment plant inflow prediction method of the present invention.
[0037] Figure 2 It is a structural diagram of a hybrid model for multi-dimensional feature enhancement extraction in the first embodiment of the present invention. DETAILED DESCRIPTION
[0038] In order to make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings.
[0039] Embodiment 1:
[0040] This embodiment provides a method for predicting the influent water quality of a sewage treatment plant based on data decomposition and deep learning. Figure 1 , the method comprising:
[0041] Step 1: Obtain and preprocess the historical time series data of sewage treatment plant influent indicators.
[0042] This embodiment predicts the influent water quality of a typical MBR process sewage treatment plant in southern Jiangsu.
[0043] In the historical time data set of the sewage treatment plant obtained, the inflow indicators include the inflow water volume Q Inf, influent COD, influent total phosphorus TP, influent total nitrogen TN, influent ammonia nitrogen NH3-N and influent pH.
[0044] The historical time series data set of water inflow indicators includes historical time series data from 13:00 on June 24, 2022 to 23:00 on December 31, 2023, with a time granularity of 1 hour.
[0045] The preprocessing process of this embodiment is as follows:
[0046] Step 11: Use the fast Fourier transform method to perform periodicity tests on each indicator using the acquired historical time data to determine whether each indicator has clear predictability;
[0047] Step 12: Based on the professional knowledge and experience of the sewage treatment plant, delete the abnormal values for each type of influent index;
[0048] Step 13: Use the multiple interpolation method (MiceForest) to interpolate the missing values and the null values formed by deleting the outliers in step 12 to construct a complete water inflow data set;
[0049] Step 14: Use the maximum and minimum normalization method to perform dimensionless processing on the complete influent data set;
[0050] Step 15: Considering the actual needs of the sewage treatment plant and the expertise of time series prediction, for the influent data set obtained in step 14, the data from June 24, 2022 to May 31, 2023 are used as the training set, and the data for the rest of the time are used as the test set. The influent water volume Q with obvious predictability is selected. Inf , influent COD, influent total phosphorus TP, influent total nitrogen TN, influent ammonia nitrogen NH3-N are used as prediction targets respectively. When a certain indicator is used as the target to be predicted, the other four indicators and the unpredictable pH are used as auxiliary variables. For example, when the target to be predicted is the influent water volume Q Inf When the hybrid model is used, the input historical water quality data are the past influent volume and other auxiliary variables in the past: influent COD, influent total phosphorus TP, influent total nitrogen TN, influent ammonia nitrogen NH3-N and influent pH, and the output data are the influent volume at the future moment.
[0051] Step 16: Based on the period of the change rules of various indicators obtained in step 11, that is, T = 24 hours, as the historical time window, the prediction target of each window is marked, and the prediction value of a certain time window at a certain moment in the future is marked.
[0052] Step 2: Construct a hybrid model for multi-dimensional feature enhancement extraction;
[0053] like Figure 2As shown, the hybrid model is composed of a data decomposition module, a feature extraction module, a temporal feature enhancement module, and a decoding and prediction module connected in series.
[0054] The data decomposition module uses the STL algorithm to decompose the historical time series data of the indicator to be predicted into trend component t, seasonal component s and residual component r, thereby enhancing the ability of subsequent modules to capture data features.
[0055] The feature extraction module is used to extract the time variation pattern of data in each time window and the relationship between variables, and obtain the updated trend component t, seasonal component s and residual component r respectively.
[0056] The time feature enhancement module is used to enhance the extraction of the extracted time variation features.
[0057] The decoding and prediction module is used to decode the encoding of the enhanced time-varying features and generate prediction values.
[0058] The feature extraction module consists of a feature embedding layer and three modern temporal convolutional layers.
[0059] The data decomposition module uses the STL (Seasonal and Trend decomposition using Loess) time series decomposition method. The main input parameter of this method is period, which represents the seasonal period and is used to specify the period of the time series. To match the length of the historical time window in step 16, this parameter is set to 24, thereby decomposing the time series data of the forecast target into three main components: trend component t, seasonal component s, and residual component r. Therefore, for each time window data to be input into the feature extraction module, it contains the decomposition items of the forecast target (t, s, r) and other 5 auxiliary variables, so the dimension of the time window data finally input into the feature extraction module is 8×24.
[0060] The feature embedding layer uses a one-dimensional large convolution kernel with a large step size, that is, the convolution kernel size is 1×8 and the convolution step size is 4. The convolution layer outputs a channel with an input of 1 as 12 channels, thereby increasing the dimension of the data features and extracting more information.
[0061] The structure of the modern temporal convolution layer is as follows: depthwise convolution (input channel and output channel are 8×12, convolution kernel size is 1×3, number of groups is 8×12), batch normalization layer (size is 12), pointwise convolution layer. The pointwise convolution layer contains two layers, each of which includes the following structure: the first layer of pointwise convolution (input channel is 8×12, output channel is 2×8×12, convolution kernel size is 1×1, number of groups is 8×12), Dropout layer, GELU activation function layer, the second layer of pointwise convolution (input channel is 2×8×12, output channel is 8×12, convolution kernel size is 1×1, number of groups is 8×12), Dropout layer. The modern temporal convolution layer uses the above different convolution operations to not only extract features of the time variation law of the prediction target decomposition items (t, s, r), but also extract independent features of the complex relationship between the prediction target decomposition items (t, s, r) and the five auxiliary variables. The output of each modern temporal convolutional layer is added to the input (i.e., the output of the feature embedding layer or the previous modern temporal convolutional layer), so that the model only learns its residual information to avoid overfitting of the model.
[0062] The time feature enhancement module is the attention mechanism layer (Attention), which adds the updated trend component t', the updated seasonal component s', and the updated residual component r' extracted by the above feature extraction module to form the time information sequence H to be processed. After passing through the linear transformation layer, the sequence is matrix multiplied with the original sequence H, and each moment of the time series is scored through the SoftMax activation function to generate a weight matrix A composed of values (0~1). The weight matrix A is multiplied by the time information sequence H to obtain the enhanced time information sequence feature H'.
[0063] The decoding and prediction module outputs the enhanced time information sequence feature H' through the fully connected layer as the final prediction value. The structure of the fully connected layer is: the first linear transformation layer (input length is 12×6, output length is 12×6 / / 2), Tanh activation function layer, and the second linear transformation layer (input length is 12×6 / / 2, output length is 1).
[0064] Step 3: Train the hybrid model
[0065] The training hybrid model is to enable the model to extract the features of the time window data input each time, and through repeated iterative learning, learn different time change laws and relationships between variables, so that its predicted value for a certain moment in the future continues to approach the actual monitoring value.
[0066] Set training epoch = 180, batchsize = 32, so the input data size of the hybrid model and the output data size of each module in the model are as follows:
[0067] X 输入 =32×8×24
[0068] H 特征提取 =32×8×12×6
[0069] H 特征增强 =32×1×12×6
[0070] H 解码 =32×12×6
[0071] H 预测 =32×1
[0072] The sewage treatment plant inflow prediction training set in step 1 is input into the hybrid model, and the parameters of the hybrid model are updated using the gradient descent method. The training is performed until the Loss value converges, that is, the trained hybrid model is obtained when epoch=180.
[0073] Step 4: Make predictions on the test set data and evaluate
[0074] The data from June 1, 2023 to December 31, 2023 is used as the test set. The data with a historical time window of 24 hours containing the prediction target in the test set is input into the trained hybrid model, and the final prediction value corresponding to a certain moment in the future is output.
[0075] The model predicts the test set, and the error between the obtained value and the actual monitoring value is calculated using RMSE, MAE, R 2 And MAPE are used for performance evaluation, and the formula of the evaluation index is:
[0076]
[0077] Among them, y t is the real monitoring value, is the predicted value.
[0078] Table 1 shows the prediction results of the water inflow prediction method provided in this example. It can be seen that the hybrid model (i.e., STL-AmTCN) provided in this example has a good performance in water inflow prediction within the next hour. 2 The values all exceed 0.89, and the R 2 It reached 0.958, the highest accuracy.
[0079] Table 1 Prediction results of the hybrid model of the present invention
[0080]
[0081] In addition, in addition to the STL-AmTCN model proposed in the present invention, this embodiment selects five benchmark models, namely, extreme gradient boosting tree (XGBoost), multilayer perceptron (MLP), long short-term memory network (LSTM), gated recurrent unit (GRU), and modern time convolution structure (modernTCN) without adding data decomposition and attention mechanism, to compare the prediction effect of water inflow index. The prediction results of different models for the data set in the embodiment of the present invention are shown in Table 2.
[0082] Table 2 Prediction results of different models in the embodiments of the invention
[0083]
[0084] It can be seen from Table 2 that the STL-AmTCN model proposed in this invention shows significant stability in the prediction performance of multiple time periods in the future, and the prediction R of the water inlet flow rate in the next 24 hours is 2 They can all be kept above about 0.8, that is, a high prediction accuracy can be maintained.
[0085] This embodiment provides a sewage treatment plant inflow prediction method based on data decomposition and deep learning, and achieves improved accuracy and timeliness of the inflow water quantity and quality prediction of the sewage treatment plant through a hybrid model of multi-dimensional feature enhancement extraction.
[0086] Some steps in the embodiments of the present invention may be implemented using software, and the corresponding software program may be stored in a readable storage medium, such as a CD or a hard disk.
[0087] 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 principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for predicting influent index of a sewage treatment plant, characterized in that: The method comprises: Step 1: Obtain historical time series data of sewage treatment plant influent indicators and perform preprocessing; Step 2: Use the STL time series decomposition method to decompose the historical time series data of the indicator to be predicted into trend component, seasonal component and residual component; Step 3: extracting features of the trend component, seasonal component, residual component and auxiliary variables of the indicator to be predicted, and obtaining updated trend component, seasonal component and residual component respectively, wherein the auxiliary variables are: historical time series data of water inflow indicators other than the indicator to be predicted; Step 4: Strengthen the time variation features extracted in step 3; Step 5: Decode the enhanced time-varying features obtained in step 4 to obtain the predicted value of the indicator to be predicted.
2. The method according to claim 1, characterized in that: The step 3 uses a feature extraction module to extract features of the trend component, seasonal component, residual component and auxiliary variable of the indicator to be predicted, and the feature extraction module includes: a feature embedding layer and a modern time convolution layer; The feature embedding layer uses convolution to increase the dimension of data features; The structure of the modern temporal convolution layer includes: depth-wise convolution, batch normalization layer, point-by-point convolution layer in sequence; the point-by-point convolution layer contains two layers, each of which includes the following structure: the first layer of point-by-point convolution, Dropout layer, GELU activation function layer, the second layer of point-by-point convolution, Dropout layer; the output of each layer of modern temporal convolution layer is added to the input, so that the model only learns its residual information to avoid overfitting of the model.
3. The method according to claim 1, characterized in that The step 4 uses the attention mechanism layer to add the trend component, the updated seasonal component and the updated residual component updated in step 3 to form the time information sequence H to be processed. The time information sequence H passes through the linear transformation layer and performs matrix multiplication with the original sequence, and scores each moment of the time series through the SoftMax activation function to generate a weight matrix A. The weight matrix A is multiplied by the time information sequence H to obtain the enhanced time information sequence feature H'.
4. The method according to claim 1, characterized in that: The step 5 uses a fully connected layer to process the enhanced features, and the structure of the fully connected layer includes: a first linear transformation layer, a Tanh activation function layer, and a second linear transformation layer.
5. A sewage treatment plant inflow prediction system, characterized in that: The system comprises: A data acquisition module is configured to acquire historical time series data of influent water quality indicators of a sewage treatment plant; A data preprocessing module, configured to preprocess the historical time series data; A data decomposition module is configured to decompose the historical time series data of the indicator to be predicted into a trend component, a seasonal component and a residual component by using an STL time series decomposition method; A feature extraction module is configured to extract features of the trend component, seasonal component, residual component and auxiliary variable of the indicator to be predicted, and obtain updated trend component, seasonal component and residual component respectively, wherein the auxiliary variable is: historical time series data of water inflow indicators other than the indicator to be predicted; A time feature enhancement module, configured to enhance the extraction of the extracted time variation features; The decoding and prediction module is configured to decode the enhanced time variation feature obtained by the time feature enhancement module to obtain the predicted value of the indicator to be predicted.
6. The system according to claim 5, characterized in that The feature extraction module includes: a feature embedding layer and a modern temporal convolution layer; The feature embedding layer uses convolution to increase the dimension of data features; The structure of the modern temporal convolution layer includes: depth-wise convolution, batch normalization layer, point-by-point convolution layer in sequence; the point-by-point convolution layer contains two layers, each of which includes the following structure: the first layer of point-by-point convolution, Dropout layer, GELU activation function layer, the second layer of point-by-point convolution, Dropout layer; the output of each layer of modern temporal convolution layer is added to the input, so that the model only learns its residual information to avoid overfitting of the model.
7. The system according to claim 5, characterized in that The time feature enhancement module is an attention mechanism layer, which adds the updated trend component, seasonal component and residual component extracted by the feature extraction module to form a time information sequence H to be processed. The time information sequence H passes through a linear transformation layer and performs matrix multiplication with the original sequence. The SoftMax activation function is used to score each moment of the time series to generate a weight matrix A. The weight matrix A is multiplied by the time information sequence H to obtain the enhanced time information sequence feature H'.
8. The system according to claim 5, characterized in that The decoding and prediction module uses a fully connected layer to process the features output by the temporal feature enhancement module. The structure of the fully connected layer includes: a first linear transformation layer, a Tanh activation function layer, and a second linear transformation layer.
9. An electronic device, characterized in that: including memory and processor; The memory is used to store computer programs; The processor is configured to implement the method according to any one of claims 1 to 4 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Cited By
Highway bridge multi-mode safety monitoring method and system
CN120763844A
Space intelligent watershed hydrology and water quality multivariable prediction method based on quaternion time-frequency multi-scale
CN120822194A
