# The Power of Machine Learning Methods and PSO in Air Quality Prediction
## 4 Experimental Results  
This paper used machine learning and PSO approaches to forecast air quality using a dataset containing a small amount of clean data. For this purpose, this entire study was carried out using Python (v.3.10) with a computer with an i7 processor, GPU card, and 16 GB RAM. Figure 2: The implementation stages of the proposed method. Metrics are utilized to measure the success of machine learning regressors. This study uses the error-based metrics mean absolute error (MAE), mean squared error (MSE), root mean squared error (RMSE), and coefficient of determination (R\({}^{2}\)). Definitions and equations for the metrics used are given in Appendix A. Some preprocessing steps were performed before using the relevant dataset. 1. Missing data in the dataset were deleted. 2. Repeated data were de-duplicated. 3. Min-max normalization was applied. 4. In total, 827 clean data were obtained. The boxplot in Figure 3 displays the distribution of the final data characteristics. In the first approach in this study, the performances of SVR, RF, XGBoost, and LR models were performed with non-optimized parameters. Table 1 presents the training time and performance measurements of the models before optimization. RF and XGBoost models provided the lowest MAE and MSE values. In other words, they showed the most successful prediction performance. Support vector regression and linear regression models had higher error rates. In particular, the LR model's MAE (0.470) and RMSE (0.644) values gave higher error rates than others. In the second approach in this study, SVR, RF, XGBoost, and LR models were implemented using the optimum parameters determined by particle swarm optimization. Table 2 shows the time and performance measurement results obtained with the parameters optimized with PSO. The performances of the models optimized with PSO were significantly improved. The largest performance increase was reported in the SVR model. The SVR model, which had MAE = 0.461, MSE = 1.239, RMSE = 1.113, and R\({}^{2}\) = 0.974 in the \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Model** & **MAE** & **MSE** & **RMSE** & **R\({}^{2}\)** & **Time (s)** \\ \hline SVR & 0.461 & 1.239 & 1.113 & 0.974 & 0.020 \\ RF & 0.059 & 0.021 & 0.146 & 0.999 & 0.522 \\ XGBoost & 0.173 & 0.061 & 0.247 & 0.998 & 6.738 \\ LR & 0.470 & 0.415 & 0.644 & 0.991 & 0.001 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Time and performance measurement results of machine learning regressors without hyper-parameter optimization. Figure 3: The value ranges for each feature after preprocessing. unoptimized case, reached MAE = 0.071, MSE = 0.015, RMSE = 0.122, and R\({}^{2}\) = 0.999 after being optimized with PSO. This shows that PSO effectively improves the parameters of the SVR model and provides high accuracy with lower error rates. Similarly, the XGBoost model also exhibited better performance after PSO optimization. Before optimization, the XGBoost model had MAE = 0.173, MSE = 0.061, and RMSE = 0.247, and, after optimization, it significantly reduced its errors by reaching values of 0.082, 0.018, and 0.133, respectively. A lesser improvement was observed in the performance of the RF model, which reached MAE = 0.065, MSE = 0.022, and RMSE = 0.150 after PSO optimization. However, the gain provided by optimizing the RF model was less than that of the SVR and XGBoost models. This was because the RF model already had a high level of accuracy. However, the LR model was not affected by the optimization process of its parameters and provided the best performance in its current state, being not optimized as there is no specific hyperparameter that can be optimized for linear regression models. While there was a model improving effect on error rates, there was an increase in optimization, with a negligible increase in computation time. Table 3 shows the best parameters obtained by PSO optimization.