# An Attention-Based CNN-LSTM Method for Effluent Wastewater Quality Prediction
## 4 Experiments
### Experimental Results  
#### 4.3.1 Comparison with Sliding Window Method  
We conducted the experiment on the pre-treated dataset and selected all six influent wastewater quality indicators as the input and all four effluent wastewater quality indicators as the output of the model. According to the design, the residence time of the WWTPs was 12 h and the sampling frequency was 2 h, the interval between input and output was set as 6. After determining the input and output of the model, we put the data into the model for training. The training method adopted a fixed epoch number, and the hyperparameters of the model are shown in Table 2.  
The 3 \(\times\) 3 Conv1-channel is the number of channels in the first 3 \(\times\) 3 convolution layer, the 3 \(\times\) 3 Conv2-channel represents the number of channels in the second 3 \(\times\) 3 convolution kernel, the 1 \(\times\) 1 Conv-channel represents the number of channels in the 1 \(\times\) 1 convolution kernel, and CNN-Dense represents the dimensions of the output in the Dense layer used in the CNN module. LSTM-hidden size represents the number of neurons in the LSTM layer. Epoch number, learning rate, batch size and optimizer refer to the hyperparameters of the training method. After the training was completed, the data in the test set were fed into the model for predicting the effluent wastewater quality at once. The predicted results are shown in Figure 6. \begin{table}
\begin{tabular}{c c} \hline \hline
**Hyperparameter** & **Values** \\ \hline
3 \(\times\) 3 Conv1-channel & 8 \\
3 \(\times\) 3 Conv2-channel & 8 \\
1 \(\times\) 1 Conv-channel & 3 \\ CNN-Dense & 32 \\ LSTM-hidden size & 64 \\ Epoch number & 200 \\ Learning rate & 0.0002 \\ Batch size & 64 \\ Optimizer & Adam \\ \hline \hline \end{tabular}
\end{table} 
Table 2: The hyperparameters of the model. In the figure above, the black line represents the effluent wastewater quality value, and the red line represents the effluent wastewater quality value predicted by the model. The horizontal coordinate represents the sample, and the vertical coordinate represents the concentration. It can be seen from the figure that the model can predict the general trend of effluent wastewater quality value, but for some of the large mutations, such as the middle part of the line, the predicted value differs greatly from the target value. We calculated the MAPE value of the predicted results for 5 days, 10 days, 20 days and 30 days, as shown in Figure 7; it was found that the MAPE of all four wastewater quality indicators increases over time, which may be caused by changes in the wastewater quality conditions or the control methods of the WWTPs. Therefore, we decided to adopt the sliding window method, similar to [25]. The idea of sliding window method is based on the following two points:  
Figure 6: (**a**) Target and predicted values of COD; (**b**) target and predicted values of NH3-N; (**c**) target and predicted values of TP; (**d**) target and predicted values of TN. Figure 7: The trend of the results. In the daily operation of WWTPs, the effluent wastewater quality prediction model should meet the requirement of supporting dynamic updating; that is, the model will constantly update the parameters with changing time. The sliding window method simulates the dynamic updating and incremental training of the model; when a batch of new data is obtained from the WWTPs, the model is dynamically updated to improve the accuracy of the predicted results. 2. Data augmentation refers to the technology of generating new training data by transforming or combining existing data. The sliding window method can also be regarded as the \"data augmentation\" of the datasets, which makes it easier for the model to capture the rules in the data and prevent the model from overfitting a certain section of data. The previous prediction method predicted all the results at once, whereas the sliding window method, shown in Figure 8, breaks the process down into multiple steps.