Deep Learning-Based Prediction of Effluent Quality from Wastewater Treatment Plant by Integrating Precipitation
Abstract:
Stable and compliant effluent discharge from wastewater treatment plants (WWTPs) is of great significance for environmental safety and for the synergistic reduction of pollution and carbon emissions. To address the difficulty of real-time monitoring and accurate prediction of effluent quality indicators by conventional methods—owing to large fluctuations and complex influencing factors—this study proposes a deep learning-based prediction model for WWTP effluent quality that integrates precipitation. Based on a full year of operational data from a municipal WWTP in 2024, one-day-ahead rolling prediction models were constructed using a back propagation neural network (BPNN), a convolutional neural network (CNN), a long short-term memory (LSTM) network, and an improved Informer model. All four models take five input features, including precipitation. Building on the standard Informer model, the improved Informer model further adds historical sequences of the target variables and periodic time features on the input side, introduces a sample-weighting mechanism into the loss function to strengthen learning from abnormal operating samples, and adopts a lightweight encoder-only architecture adapted to small-sample daily data, in which the generative decoder is removed, a fully connected readout head is added, and the model dimensions are compressed. The models take a sliding 14-day window of historical data as input to predict next-day effluent chemical oxygen demand (COD) and ammonia nitrogen (NH$_3$-N). Experimental results show that the improved Informer model enhances the prediction accuracy and stability of effluent quality indicators and improves the responsiveness to effluent fluctuations under abnormal operating conditions, providing strong technical support for real-time intelligent monitoring of WWTP effluent quality.1. Introduction
The effluent quality of wastewater treatment plants (WWTPs) directly affects the environmental safety and ecological health of receiving water bodies and is an important indicator of the operation and management level of WWTPs \citep{1}. With the acceleration of urbanization in China and increasingly stringent environmental protection requirements, stable and compliant effluent discharge has become a key link in water environment governance \citep{2, 3}. Effluent quality is affected by factors such as influent volume, influent quality, meteorological conditions such as rainfall, treatment processes, and microbial activity, and exhibits obvious fluctuation and nonlinearity \citep{4, 5}. Conventional WWTPs mainly monitor water quality indicators through online instruments and regular laboratory tests \citep{6}. However, conventional detection methods for key pollutants such as ammonia nitrogen (NH$_3$-N) suffer from time lag and can hardly achieve continuous real-time monitoring, which restricts the real-time optimal control and emergency response capability of the wastewater treatment process \citep{7, 8}. Therefore, constructing an accurate and reliable effluent quality prediction model to predict effluent quality in advance is of great significance for ensuring stable and compliant effluent discharge and optimizing process control strategies.
In recent years, data-driven effluent quality prediction models have attracted extensive attention \citep{8, 9, 10, 11}. Among them, machine learning-based ensemble algorithms have shown good prediction performance. Shah et al. \citep{12} compared the effluent quality prediction performance of various ensemble algorithms and found that gradient boosting-based models have advantages in handling complex nonlinear mapping problems. Inbar et al. \citep{13} used an optimized random forest model to predict biochemical oxygen demand (BOD) throughout the wastewater treatment process from readily measured parameters such as chemical oxygen demand (COD), total suspended solids, and total Kjeldahl nitrogen, and proposed it as part of a BOD monitoring sensor to bridge the long intervals between conventional laboratory BOD tests. Owing to their adaptive nonlinear modeling capability, artificial neural networks (ANNs) and deep learning techniques have been widely applied to data analysis of the wastewater treatment process; Dantas et al. \citep{14} found that ANNs achieve higher prediction accuracy for WWTP water quality than conventional methods. Time-series neural network models have also achieved remarkable results in effluent quality prediction \citep{15}: Wongburi and Park \citep{16} used recurrent neural network and long short-term memory (LSTM) network models to model multiple effluent quality indicators of WWTPs, achieving high-accuracy prediction of indicators such as BOD5, total phosphorus, total nitrogen, suspended solids, and NH$_3$-N. Although the above models have shown great potential in WWTP effluent quality prediction \citep{17, 18, 19}, the following shortcomings remain: (1) In terms of feature selection, most prediction models mainly consider the internal operating parameters of the wastewater treatment process and pay insufficient attention to the influence of external meteorological factors (e.g., precipitation); however, meteorological factors affect the confluence characteristics of the sewer network and dilute influent pollutant concentrations, thereby exerting a non-negligible indirect influence on effluent quality \citep{4, 20}. (2) In terms of model selection, the Informer model based on the Transformer architecture has shown advantages in time-series prediction owing to its self-attention mechanism \citep{19, 21, 22}; however, it is designed for long-sequence multi-step prediction, with a complex structure and a large number of parameters, and is prone to overfitting when directly applied to daily-scale effluent quality prediction with a limited sample size. Studies on adapting it to this task are still scarce.
To address the above problems, based on the full-year daily operating data of a municipal WWTP in 2024, this study constructs a deep learning-based WWTP effluent quality prediction model integrating precipitation, so as to improve the accuracy and stability of daily prediction of effluent COD concentration and NH$_3$-N concentration. First, outlier correction and standardization are performed on the operating data, and the model input features, including precipitation, are determined by combining correlation analysis with the mechanism of action. Second, the standard Informer model is improved in three aspects, namely input features, loss function, and model structure: historical sequences of the target variables and periodic time features are added on the input side to supplement the autoregressive and periodic information of water quality evolution; a sample-weighting mechanism is introduced into the loss function to strengthen the model’s learning of samples under abnormal operating conditions; and the generative decoder is removed, an encoder-only architecture plus a fully connected readout head is adopted, and the model dimensions are compressed, so as to adapt to small-sample daily-scale data. Finally, the prediction performance of the improved Informer model is verified through comparative experiments with a back propagation neural network (BPNN), a convolutional neural network (CNN), and the LSTM model.
2. Data Sources and Preprocessing
This study takes a large WWTP in a city in southern China as a case study. The WWTP serves a population of approximately 410,000 and has a design treatment capacity of 200,000 m$^3$/d. It adopts a modified \sloppy anaerobic—anoxic—oxic (A$^2$/O) process, and its effluent quality complies with the Class 1A standard of GB 18918-2002
As shown in Figure 1, the treated water volume of the WWTP exhibited obvious seasonal fluctuations: it was larger in summer (June–August, mean 463.56 × 10$^4$ t) and smaller in winter (December–February, mean 363.91 × 10$^4$ t), with the highest value of 487.85 × 10$^4$ t in May and the lowest value of 347.68 × 10$^4$ t in February. The dry sludge production fluctuated markedly, reaching 2,879 t in April and only 721 t in August, mainly owing to the influence of the influent load intensity and seasonal operating strategies. The influent COD concentration fluctuated within 110–199 mg/L over the year (mean 144.17 mg/L), showing a seasonal pattern of “high in winter and low in summer”, with a peak of 199 mg/L in December and a minimum of 110 mg/L in July. The effluent COD concentration remained stable between 13 and 17 mg/L throughout the year, indicating relatively stable COD removal. The influent NH$_3$-N concentration fluctuated within 14.67–26.25 mg/L over the year (mean 20.49 mg/L), showing the same “high in winter and low in summer” pattern as the influent COD concentration, with a peak of 26.25 mg/L in December and a minimum of 14.67 mg/L in August. The effluent NH$_3$-N concentration remained within 0.62–1.51 mg/L throughout the year (mean 0.94 mg/L), with the highest value of 1.51 mg/L in June and the lowest value of 0.62 mg/L in September; overall, it remained stable at around 1 mg/L, far below the Class 1A discharge limit. In summary, the WWTP maintained good treatment performance under fluctuating water quality and quantity conditions, showing a certain capacity to resist shock loads and good operational stability.

Outlier detection and correction, data standardization, and other operations were performed on the full-year daily operating data of the WWTP in 2024. The data contained no missing records. Outlier detection adopted the 3$\sigma$ criterion combined with process prior constraints, and a total of 22 outliers were identified (approximately 0.55\% of all numerical observations); they were set to NaN and then corrected by bidirectional linear interpolation. Data standardization adopted the Z-score method to convert each input feature and target variable into dimensionless data with a mean of 0 and a standard deviation of 1, so as to eliminate the influence of differences in dimensions and numerical ranges on model training; the mean and standard deviation were fitted on the training set only and then applied to all data, to avoid information leakage from the test set.
3. Feature Selection
The candidate features for the correlation analysis are the six operating parameters recorded daily by the plant, namely daily treated water volume, influent COD concentration, influent NH$_3$-N concentration, dry sludge production, reclaimed water volume, and electricity consumption. Precipitation is an external meteorological variable; it does not participate in the correlation screening and is justified separately based on its mechanism of action (see Section 3.2). The Pearson correlation coefficient was used to analyze the correlations between the above candidate features and the effluent COD and effluent NH$_3$-N concentrations, as well as the collinearity among the candidate features. The results are shown in Figure 2 (the figure includes all candidate features and the two output variables).
As shown in Figure 2, the daily treated water volume is significantly negatively correlated with the influent COD concentration ($r$ = $-$0.83) and highly negatively correlated with the influent NH$_3$-N concentration ($r$ = $-$0.94), indicating that influent pollutant concentrations tend to decrease as the influent volume increases, which is consistent with the general pattern of the dilution effect in the rainy season. The influent COD concentration and the influent NH$_3$-N concentration are highly positively correlated ($r$ = 0.90), indicating that the two share homologous pollution characteristics. The influent NH$_3$-N concentration shows a moderate positive correlation with dry sludge production ($r$ = 0.56), indicating that changes in the influent load affect not only influent and effluent quality but also dry sludge production. The influent COD concentration shows a moderate positive correlation with the effluent COD concentration ($r$ = 0.56), whereas the correlation between the influent NH$_3$-N concentration and the effluent NH$_3$-N concentration is weak ($r$ = 0.14), indicating that the effluent NH$_3$-N concentration is more difficult to predict and requires richer input information such as the historical sequence of the target variable. The above analysis shows that there are obvious homology and collinearity among the candidate features; if all of them were input into the model without screening, redundant information would be introduced and the risk of overfitting would increase. Therefore, features that are weakly correlated with the effluent indicators or highly redundant with the selected features need to be eliminated.

Based on the above correlation analysis results, each candidate feature was either retained or eliminated. Although electricity consumption shows a moderate positive correlation with the daily treated water volume ($r$ = 0.58), it is essentially an operating response variable jointly driven by the daily treated water volume and the reclaimed water volume ($r$ = 0.51), carries information redundant with the daily treated water volume, and is only weakly correlated with the effluent COD and effluent NH$_3$-N concentrations ($r$ = $-$0.16 and 0.039, respectively); therefore, it was eliminated. The correlations of the reclaimed water volume with the effluent COD and effluent NH$_3$-N concentrations are both close to 0 ($r$ = 0.067 and $-$0.015, respectively); therefore, it was eliminated. Dry sludge production is positively correlated with the influent COD and influent NH$_3$-N concentrations ($r$ = 0.41 and 0.56, respectively), which can indirectly characterize the influent load and the biomass state of the system, and its correlation coefficient with the effluent NH$_3$-N concentration ($r$ = $-$0.20) has the largest absolute value among all operating parameters; therefore, it was retained. The daily treated water volume shows a weak negative correlation with the effluent COD concentration ($r$ = $-$0.27) and reflects the hydraulic load and its dilution effect on influent concentrations; therefore, it was retained. Although the influent COD concentration and the influent NH$_3$-N concentration are highly correlated ($r$ = 0.90), they are the influent indicators most directly corresponding to the two prediction targets, i.e., the effluent COD concentration and the effluent NH$_3$-N concentration, respectively, and each carries the load information of its corresponding target; therefore, both were retained.
Precipitation, as an external meteorological variable, was not included in the above correlation analysis of the operating parameters; instead, its inclusion was determined based on its mechanism of action. Rainfall directly increases the influent volume and dilutes influent pollutant concentrations as stormwater flows into the sewer network \citep{4, 20}, and it is the main external driving factor causing fluctuations in effluent quality; therefore, it was used as an input feature.
Consequently, the final input features of the models are five: influent COD concentration, influent NH$_3$-N concentration, daily treated water volume, dry sludge production, and precipitation. On this basis, the improved Informer model additionally incorporates the historical sequence of the target variable and periodic time features (see Section 4.2.1).
4. Improved Informer Model
By introducing an information theory-based sparse self-attention mechanism and self-attention distilling, the standard Informer model \citep{21} effectively reduces the computational complexity of the conventional Transformer model and can efficiently extract key features from long time windows. The model consists of an encoder and a decoder. By default, the encoder adopts two stacked ProbSparse multi-head self-attention modules (8 attention heads, a hidden dimension of 512, and a feed-forward layer dimension of 2048), and down-samples the temporal dimension through inter-layer self-attention distilling to extract long-range temporal features. The decoder adopts the standard structure of “masked multi-head self-attention + encoder–decoder cross-attention + feed-forward network (FFN)”, with each sub-layer followed by a residual connection and layer normalization. The decoder is a generative decoder that takes a start token and a placeholder sequence as input and outputs multi-step prediction results in a single forward pass through a fully connected projection layer, which is suitable for long-sequence multi-step prediction.
When predicting time series such as effluent quality, which are non-stationary, fluctuating, and accompanied by sudden anomalies, the standard Informer model suffers from insufficient response to short-term anomalies and limited capture of periodic features; moreover, its complete encoder–decoder structure, designed for long-sequence multi-step prediction, has redundant parameters for small-sample daily-scale data. Therefore, this study made targeted improvements to its input features, loss function, and model structure: the historical sequence of the target variable and periodic time features are introduced on the input side to supplement the autoregressive and periodic information of water quality evolution; a weighting strategy for the spike segments in the training samples is introduced into the loss function to improve the sensitivity of the anomaly response; and, in terms of model structure, the generative decoder is removed, an encoder-only architecture plus a fully connected readout head is adopted, and the model dimensions are compressed, so as to reduce the number of parameters and suppress overfitting. The structure of the improved Informer model is shown in Figure 3, in which the gray-shaded parts are the improvements made in this study.
The historical sequence of the target variable and periodic time features are introduced into the input features. When predicting the effluent COD or NH$_3$-N concentration on a given day, the measured values of the corresponding indicator over the previous 14 d are fed into the encoder as an additional channel, providing the model with autoregressive information. Meanwhile, the day of year and the weekday corresponding to the date are transformed by sine and cosine functions and encoded as periodic numerical features (4 dimensions in total), which are used to characterize the operating states in different seasons and on weekdays/weekends, thereby enhancing the model’s ability to perceive samples with long-term periodic variations. These two types of features, together with the five input features determined in Section 3, constitute the encoder input.
A sample-weighting mechanism is introduced into the loss function to strengthen the model’s ability to learn from samples under abnormal operating conditions. The conventional mean squared error loss function treats all samples equally, causing the model to tend to fit the main body of the data distribution while ignoring extreme values \citep{23}. However, in the wastewater treatment process, sudden peaks of effluent quality indicators often correspond to abnormal operating conditions; although such samples are few, they have a direct impact on effluent quality prediction. Therefore, the improved Informer model introduces a sample-weighting mechanism into the loss function, i.e., the weight of each sample is adaptively adjusted according to the degree to which its target value deviates from the mean target value of the training set, so that samples with larger deviations receive higher weights in the loss calculation, thereby improving the model’s prediction accuracy for sudden peaks of effluent quality indicators and abnormal operating conditions.
The weighted loss function $L$ is calculated as follows:
where, $N$ is the number of samples; $\omega_i$ is the weight of the $i$-th sample; $y_i$ and $\hat{y}_i$ are the true value and the predicted value of the $i$-th sample, respectively; $\bar{y}$ and $\sigma_y$ are the mean and standard deviation of the target values of the training set, respectively; $\alpha$ is the weight adjustment coefficient, and $\alpha$ = 1 is used in this study; and 5 is the truncation upper limit of the degree of deviation, which is used to prevent the weights of individual extreme samples from becoming excessively large.

The generative decoder of the standard Informer model described in Section 4.1 is designed for long-sequence multi-step prediction, whereas this study performs daily single-step prediction with a total of only about 350 samples; in this case, the complete encoder–decoder structure has redundant parameters and is prone to overfitting. Therefore, this study performed a lightweight reconstruction of the model structure. (1) The generative decoder (including the masked multi-head self-attention, the encoder–decoder cross-attention, and the decoder FFN) is removed, and only the encoder is retained; the hidden vector at the last time step of the encoder output sequence is taken as the representation of the entire 14-day input window and mapped to the predicted value through two fully connected layers (96 hidden units, rectified linear unit (ReLU) activation). (2) The hidden dimension is compressed from 512 to 192, the feed-forward layer dimension is compressed from 2048 to 384, the number of attention heads is reduced from 8 to 6, and L2 regularization (coefficient 1 × 10$^{-4}$) is applied to the weights of the feed-forward layers. (3) Since the input window is only 14 d, the number of active queries selected by ProbSparse self-attention is approximately $c$·ln $L$ $\approx$ 5 × ln 14 $\approx$ 13 (where $c$ is the sampling factor, which is 5 by default in the standard Informer model, and L is the input sequence length), which is comparable to the sequence length, so sparsification can hardly reduce the computational cost; therefore, the encoder adopts standard multi-head self-attention. A comparison of the model structure configurations before and after the improvement is shown in Table 1. After the above reconstruction, the number of model parameters was reduced from approximately 11,330,000 to approximately 730,000, a reduction of approximately 93.6\%.
| Configuration Item | Standard Informer Model | Improved Informer Model |
|---|---|---|
| Decoder | One-layer generative decoder | Removed |
| Output mode | Decoder output → fully connected projection layer | Last time step of the encoder → fully connected layer (96, ReLU) → fully connected layer (1) |
| Number of encoder layers | 2 | 2 |
| Attention mechanism | ProbSparse self-attention | Standard multi-head self-attention |
| Number of attention heads | 8 | 6 |
| Hidden dimension | 512 | 192 |
| Feed-forward layer dimension | 2048 | 384 |
| Distilling layer | One-dimensional convolution + batch normalization + ELU + max pooling | One-dimensional convolution (stride 2) + batch normalization + ReLU |
| Regularization | Dropout (0.05) | Dropout (0.12) + L2 regularization of the feed-forward layers (1 × 10$^{-4}$) |
| Number of parameters | Approximately 11,330,000 | Approximately 730,000 |
5. Experiments
The inputs and outputs of the models are as follows: the historical data of the previous 14 d (the five input features determined in Section 3; the improved Informer model additionally includes the historical sequence of the target variable and the periodic time features added in Section 4.2.1) are used as the input features, and the effluent COD concentration and effluent NH$_3$-N concentration on day 15 are used as the outputs, to construct a single-step daily rolling prediction model. In this study, only the effluent COD concentration and the effluent NH$_3$-N concentration are used as output variables, for the following reasons: both are key control indicators of the Class 1A standard of GB 18918-2002, and the conventional detection of NH$_3$-N has obvious lag and is difficult to monitor online in real time, making NH$_3$-N the indicator that most needs to be anticipated in process control; moreover, the research focus of this study is to improve the prediction accuracy of key indicators and the response capability under abnormal operating conditions through improvements to the input features, loss function, and model structure, rather than to expand the number of output indicators. This differs from the approach of Wongburi and Park \citep{16}, which focuses on the simultaneous prediction of multiple indicators. Specifically, the observed values of the input features from day 1 to day 14 are used as the input of the first sample, and the effluent COD and effluent NH$_3$-N concentrations on day 15 are used as the output of this sample; the time window is then moved forward by 1 d, the observed values of the input features from day 2 to day 15 are used as the input of the next sample, and the effluent COD and effluent NH$_3$-N concentrations on day 16 are used as its output; the window is slid in this way until the operating data of the entire year of 2024 have been traversed, forming a complete sliding-window time-series sample set. In chronological order, the first 80\% of the samples in this sample set are used as the training set for learning the model parameters, and the last 20\% are used as the test set for evaluating the generalization performance of the models.
In this study, the BPNN, CNN, and LSTM models were selected for comparison with the improved Informer model in terms of effluent quality prediction performance. The BPNN model adopts a three-layer feedforward neural network with one hidden layer (10 hidden nodes), and its weights are trained by the error back propagation algorithm \citep{24}. The CNN model adopts a one-dimensional CNN \citep{25} with one convolutional layer (32 filters, window size of 3) and one pooling layer, and finally outputs the prediction results through a fully connected layer. The LSTM model adopts a two-layer stacked LSTM network \citep{26} with 100 memory units in each layer, and a Dropout layer (dropout rate of 20\%) is added to prevent overfitting. The improved Informer model was developed on the basis of the publicly available PyTorch implementation of Informer, and its structure is described in Section 4.2.
The improved Informer model was trained with the standardized training samples: the weighted mean squared error shown in Eq. (1) was used as the loss function, and the Adam optimizer (initial learning rate of 0.0001) was adopted in combination with a cosine annealing strategy to dynamically adjust the learning rate; the batch size was 16, the maximum number of training epochs was 100, and an early stopping strategy (patience = 10) was adopted to prevent overfitting.
To comprehensively evaluate the prediction accuracy of the improved Informer model, the root mean squared error (RMSE), mean absolute error (MAE), and coefficient of determination ($R^2$) were selected as evaluation metrics. RMSE is the square root of the mean of the squared errors between the predicted and true values; its unit is consistent with that of the target variable, which facilitates intuitive interpretation, and it is relatively sensitive to outliers. MAE is the mean of the absolute errors between the predicted and true values, which avoids the mutual cancellation of positive and negative errors. $R^2$ is the proportion of the variation in the dependent variable that can be explained by the independent variables; the closer its value is to 1, the stronger the explanatory power of the model.
On the test set, the standardized predicted values output by each model were first restored to the original data scale according to $\hat{y}={\hat{y}}^\prime\sigma_y+\overline{y}$, where ${\hat{y}}^\prime$ is the standardized predicted value output by the model, and $\bar{y}$ and $\sigma_y$ are the mean and standard deviation of the target values of the training set, respectively (consistent with the parameters used in Eq. (2) and in data standardization). Then, RMSE, MAE, and $R^2$ were calculated based on the restored predicted values and the measured values to evaluate the model performance.
The prediction results of the BPNN, CNN, LSTM, and improved Informer models for the effluent COD concentration are shown in Figure 4, and the corresponding evaluation metrics are listed in Table 2.
As shown in Figure 4 and Table 2, in terms of RMSE, MAE, and $R^2$, the prediction performance of the four models for the effluent COD concentration ranks from best to worst as follows: the improved Informer model, LSTM, BPNN, and CNN. The BPNN model has limited capability to fit the nonlinear relationships of the effluent quality indicators; its prediction curve is relatively flat, with a fluctuation amplitude significantly smaller than that of the measured values, making it difficult to capture sudden peaks, and its $R^2$ is only 0.448. The CNN model uses convolution kernels to extract local features within a fixed window and cannot effectively model long-term dependencies; its RMSE and MAE are 2.942 and 2.232, respectively, both the highest among the four models, and its $R^2$ is only 0.338, making it unsuitable for prediction tasks with long-term temporal dependencies such as effluent quality. The LSTM model uses recurrent units to memorize long-term information and can reproduce the variation trend and most of the fluctuations of effluent COD well, with RMSE, MAE, and $R^2$ of 2.399, 1.862, and 0.560, respectively. The improved Informer model proposed in this study performs best, with RMSE and MAE of 2.023 and 1.583, respectively, which are 15.7\% and 15.0\% lower than those of LSTM, and its $R^2$ increases to 0.687 (0.127 higher than that of LSTM). Its advantage is more pronounced when the effluent concentration changes abruptly, indicating that its self-attention mechanism can globally model the dependencies among the time steps within the input window and that its ability to capture sudden peaks is superior to that of conventional time-series models such as LSTM.
By quarter (Q1–Q4 denote the first to fourth quarters of 2024), in Q1 the effluent COD fluctuated relatively gently overall (approximately 8–21 mg/L), and all models could capture the overall trend, but BPNN and CNN responded weakly to local fluctuations. In Q2, shock loads increased: the effluent COD rose to approximately 24–25 mg/L on days 7–10, rose again to approximately 25 mg/L on days 32–33 and then fell back to approximately 6 mg/L, and a peak of approximately 24 mg/L also occurred on day 75; the improved Informer model and LSTM could follow these rises and falls, whereas the predicted values of CNN on days 7–10 were only about 16 mg/L, a significant underestimation. Spikes of approximately 23–25 mg/L occurred repeatedly on days 32 and 62 of Q3 and on days 37, 59–60, and 77 of Q4, where the improved Informer model showed the highest agreement with the measured curve, whereas the predicted values of BPNN and CNN on day 37 of Q4 still hovered at about 15 mg/L, showing obvious peak clipping. The above comparison shows that, after the historical sequence of the target variable and periodic time features were added, the spike-sample weighted loss was introduced, and the model structure was reconstructed in a lightweight manner, the improved Informer model outperformed the comparison models in both the response sensitivity and the prediction accuracy for drastic fluctuations of effluent COD under abnormal operating conditions.

| Model | RMSE | MAE | $\boldsymbol{R^2}$ |
|---|---|---|---|
| BPNN | 2.687 | 2.065 | 0.448 |
| CNN | 2.942 | 2.232 | 0.338 |
| LSTM | 2.399 | 1.862 | 0.560 |
| Improved Informer model | 2.023 | 1.583 | 0.687 |
To verify the applicability of the improved Informer model to different effluent quality indicators, the effluent NH$_3$-N concentration was further predicted and analyzed. The prediction results of the four models for the effluent NH$_3$-N concentration are shown in Figure 5 and Table 3.
As shown in Figure 5 and Table 3, in terms of RMSE and $R^2$, the prediction performance of the four models for the effluent NH$_3$-N concentration ranks from best to worst as follows: the improved Informer model, LSTM, BPNN, and CNN (the MAE of BPNN is slightly lower than that of LSTM). The prediction curve of the BPNN model is generally smooth, and its response amplitude to the rise at the end of Q2 and to the isolated spikes in Q3 and Q4 is clearly insufficient. Although the CNN model shows some fluctuations, they are often inconsistent with the measured values in phase and amplitude (e.g., obvious overestimation on days 24–26 of Q1 and a spurious peak on day 72 of Q4). The $R^2$ values of the two models are 0.355 and 0.256, respectively, both below 0.4, indicating insufficient capability to model a highly fluctuating indicator such as effluent NH$_3$-N. The LSTM model can capture some trend changes, with RMSE, MAE, and $R^2$ of 0.519, 0.388, and 0.420, respectively, but it still exhibits “peak clipping” for isolated sudden peaks such as those on day 36 of Q1 (approximately 3.3 mg/L) and day 16 of Q3 (approximately 3.8 mg/L). The improved Informer model performs best among the four models, with RMSE and MAE of 0.448 and 0.330, respectively, which are 13.7\% and 14.9\% lower than those of LSTM, and its $R^2$ increases to 0.567 (0.147 higher than that of LSTM). As shown in Figure 5, the model can track the upward trend well in the continuously fluctuating segment on days 70–85 of Q2, during which the effluent NH$_3$-N rose continuously from approximately 0.3 mg/L to approximately 3.0–3.5 mg/L, and it can also respond synchronously to the spike of approximately 3.6 mg/L on days 57–59 of Q4, which verifies its applicability and robustness for different effluent quality indicators (effluent COD and effluent NH$_3$-N).

| Model | RMSE | MAE | $\boldsymbol{R^2}$ |
|---|---|---|---|
| BPNN | 0.547 | 0.376 | 0.355 |
| CNN | 0.588 | 0.432 | 0.256 |
| LSTM | 0.519 | 0.388 | 0.420 |
| Improved Informer model | 0.448 | 0.330 | 0.567 |
The main reasons why the prediction accuracy of effluent NH$_3$-N is lower than that of effluent COD include the following:
(1) The biological removal process of effluent NH$_3$-N is more sensitive to the environment and is easily affected by the combined influence of dissolved oxygen, pH, temperature, and other factors, resulting in more random fluctuations in effluent NH$_3$-N;
(2) The input features lack key process parameters such as dissolved oxygen, which limits the model’s ability to characterize the nitrification process;
(3) The measured values of effluent NH$_3$-N may contain certain detection errors.
6. Conclusions
To address the technical bottlenecks of conventional methods in the real-time monitoring and accurate prediction of WWTP effluent quality, this study constructed a deep learning-based WWTP effluent quality prediction model integrating precipitation and proposed an improved Informer model: historical sequences of the target variables and periodic time features were added on the input side, a sample-weighting mechanism was introduced into the loss function, and a lightweight structure was achieved by removing the generative decoder, adopting an encoder-only architecture with a fully connected readout head, and compressing the model dimensions, which reduced the number of model parameters from approximately 11,330,000 to approximately 730,000. The experimental results show that the model can more fully learn the temporal patterns and nonlinear relationships of effluent quality, effectively reduce prediction errors (compared with the LSTM model, the RMSE of the effluent COD and effluent NH$_3$-N concentration predictions was reduced by 15.7\% and 13.7\%, respectively), and improve the response capability of the model under abnormal operating conditions, which is of great significance for ensuring stable and compliant effluent discharge and improving the intelligent management and control level of the entire wastewater treatment process. In future work, the deep integration of this prediction model with real-time control strategies for the wastewater treatment process will be further explored to construct a closed-loop “prediction–regulation” intelligent system, so as to achieve precise and stable control of effluent quality and synergistic optimization of operating energy consumption, thereby contributing to the quality and efficiency improvement and low-carbon operation of wastewater treatment.
7. Declaration on the Use of Generative AI and AI-assisted Technologies
Conceptualization, Z.Z. and C.Z.; methodology, Z.Z. and D.Y.G.; software, H.Y.G.; validation, D.Y.G.; formal analysis, Z.Z.; investigation, Z.Z.; resources, C.Z.; data curation, Z.Z.; writing—original draft preparation, Z.Z.; writing—review and editing, D.Y.G. and C.Z.; visualization, H.Y.G.; supervision, C.Z.; project administration, C.Z. All authors have read and agreed to the published version of the manuscript.
Raw data are available from the corresponding author on reasonable request.
We thank the on-site instrument operators for facilitating data collection and the analytical chemistry laboratory technicians for quality-control measurements.
The authors declare no conflicts of interest.
The authors used generative AI tools to assist with language polishing and figure-script scaffolding during manuscript preparation. All scientific content, data analysis, and conclusions were generated and verified by the authors. The authors take full responsibility for the integrity of the manuscript.
