## 4 PM2.5 Prediction Modeling Based on Stacking
### Results and Analysis  
To comprehensively evaluate the performance of our proposed model, we calculated three error metrics: mean squared error (MSE), root mean squared error (RMSE), and mean absolute error (MAE). These metrics help us quantify the accuracy of model predictions from different perspectives, thereby ensuring the comprehensiveness and precision of the evaluation results. \[\text{MSE}=\frac{1}{n}\Sigma_{i=1}^{n}(\hat{y}_{i}-y_{i})^{2} \tag{2}\]  
\[\text{RMSE}=\sqrt{\frac{1}{n}\Sigma_{i=1}^{n}(\hat{y}_{i}-y_{i})^{2}} \tag{3}\]  
\[\text{MAE}=\frac{1}{n}\Sigma_{i=1}^{n}|y_{i}-\hat{y}_{i}| \tag{4}\]  
Let \(n\) be the number of observations. \(y_{i}\) represents the \(i\)-th actual observed value, and \(\hat{y}_{i}\) denotes the \(i\)-th predicted value. Comparison of PM2.5 prediction results based on a CNN with observed PM2.5 values (Figure 11a) reveals that the CNN model generally performs well in predicting PM2.5 concentrations. It effectively captures the trend and closely matches the actual measurements most of the time, demonstrating a good understanding of PM2.5 concentration patterns. However, significant deviations are observed during peak periods, such as from 1300 to 1500 and 3800 to 3900, suggesting that the model's assumptions may not hold under certain conditions, necessitating further optimization to enhance adaptability across various scenarios. For the PM2.5 prediction results based on LSTM compared with observed values (Figure 11b), the LSTM model exhibits good performance overall. The model captures the trend of PM2.5 concentrations well, though some mismatches between predicted and actual values are evident at peak values and certain details. These discrepancies might be due to extreme values caused by anomalous events not accounted for in the model. However, compared to other models, LSTM shows clear advantages in predicting peaks and fluctuations. The comparison of PM2.5 prediction results based on RF with observed values (Figure 11c) indicates noticeable volatility in PM2.5 concentrations, with multiple peaks and troughs. This reflects the complex nature of PM2.5 concentrations, influenced by various factors such as meteorological conditions and human activities. The RF model's predictions generally align with the actual peaks and troughs, suggesting that the model can learn the patterns of PM2.5 fluctuations. Despite the overall trends matching well, some deviations are still present at specific times, such as from 1300 to 1500 and 1800 to 2400. The prediction of extreme values also falls short, which is related to the multifaceted factors affecting PM2.5. The comparison of PM2.5 prediction results based on XGBoost with observed values (Figure 11d) shows that, compared to other models, the XGBoost model excels in prediction tasks. Overall, the model's predictions highly coincide with the actual PM2.5 trends, particularly in the precise trend forecasting around the 3800 to 3900 time points. Figure 11: The actual and predicted PM2.5 concentrations (in \(\upmu\)g/m\({}^{3}\) units) of CNN (**a**), LSTM (**b**), RF (**c**), XGBoost (**d**), and Stacking (**e**) models. Based on the comparison between the Stacking ensemble model's PM2.5 predictions and the observed PM2.5 values (Figure 10(e)), we can observe two sets of data: the actual PM2.5 values and the predicted PM2.5 values, represented by blue and red lines, respectively. We find the following:  
1. Overall trend: The predicted PM2.5 values (red line) closely follow the trend of the actual PM2.5 values (blue line), indicating that the model can capture the overall patterns and trends in the data. 2. Peak matching: In most cases, the model successfully predicted the occurrence of peaks, although for some extreme values, the model's predictions did not reach the heights of the actual values. This may be due to the model's inability to capture all the factors contributing to the extreme values. 3. Volatility: The model's predictions exhibit volatility similar to the actual values in certain regions.