# Data-Driven Approaches for Predicting and Forecasting Air Quality in Urban Areas
## 2 Materials and Methods
### ML Custom-Made Versus Pre-Implemented Algorithms for AQI
Gradient boosting is known for its ability to model complex relationships [78]. In this case, the hyperparameters/parameters setup contains a learning rate of 0.1 (\"_learning_rate\"_: 0.01), the number of estimators was set to 500 (\"_n_estimators\"_: 500), the maximum depth of each regression estimator was set to 4 (\"_max_depth_\": 4), the minimum number of samples per split was set to 5 (\"_min_samples_split_\": 5), and it was used a squared error type loss function (\"_loss_\": \"_squared_error_\"). \begin{table}
\begin{tabular}{c c c} \hline \hline
**Model** & **Hyperparameters/Parameters** & **Value** \\ \hline \multirow{4}{*}{RFR} & n\_estimators & 500 \\  & random\_state & 0 \\  & max\_depth & 15 \\  & max\_features & 10 \\ \hline \multirow{4}{*}{DTR} & max\_depth & 5 \\  & min\_samples\_split & 4 \\  & min\_samples\_leaf & 2 \\  & criterion & MSE \\  & random\_state & 42 \\ \hline \multirow{2}{*}{LR} & features weights & [\(-\)5.14, 0.33, 3.19, \(-\)0.18, \(-\)0.03, 0.007, 0.002, 0] \\  & intercept (bias) & 7.01 \\ \hline \multirow{4}{*}{KNN} & n\_neighbors & 5 \\  & weights & uniform \\  & p & 2 \\  & metric & minkowski \\ \hline \multirow{4}{*}{SVR} & kernel & rbf \\  & C & 1.0 \\ \cline{1-1}  & epsilon & 0.1 \\ \cline{1-1}  & gamma & scale \\ \hline \multirow{4}{*}{GBR} & n\_estimators & 500 \\  & max\_depth & 4 \\ \cline{1-1}  & min\_samples\_split & 5 \\ \cline{1-1}  & learning\_rate & 0.01 \\ \cline{1-1}  & loss & squared\_error \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Hyperparameters/parameters tuning for ML Models. Table 1 lists the tuning hyperparameters/parameters for ML models. These hyperparameters/parameters optimize the performance of the analyzed ML algorithms. The values are extracted from the Python 3.9 software and TensorFlow library used for the customized algorithms. The six above-mentioned algorithms were specifically tailored to address the characteristics of the labels analyzed. At this stage, 1305 entries have been utilized for training. The pre-implemented ML_NET analyzed models are as follows [79; 80]:  
1. Fast Forest and Fast Tree are specific implementations of decision tree algorithms optimized for speed. Fast Forest combines multiple decision trees to improve predictive performance while maintaining computational efficiency. Fast Tree is designed to build trees quickly and make predictions, making it suitable for large datasets [81; 82];
2. FastTreeTweedie is a modified version of the FastTree tree algorithm. When predicting _AQI_, which varies widely and may not follow a normal distribution, FastTreeTweedie is expected to provide a more accurate estimate by accommodating the characteristics of the _AQI_ data, particularly when dealing with extreme values;
3. Generalized Additive Models (GAM) increase linear models by incorporating smooth functions to capture non-linear relationships between independent and dependent variables. This flexibility makes GAMs a powerful tool for modeling complex data while retaining interpretability [75];
4. LbfgsPoissonRegression treated _AQI_ as count data, especially in cases of high pollution levels, capturing the frequency of extreme AQ events;
5. Online Gradient Regression involves updating regression models incrementally as new data become available, making it suitable for dynamic environments where data stream continuously. Online gradient regression algorithms are designed to minimize computational costs while maintaining predictive performance [83]. The algorithms' performance was assessed through standard metrics [84]:
* \(R^{2}\) quantifies the proportion of variance in the _AQI_ explained by the predictive models based on feature input values. An \(R^{2}\) score of 1 indicates that the model perfectly predicts _AQI_ based on the selected pollutants, whereas a score of 0 suggests that the model fails to account for any variability in the _AQI_;
* _Mean Absolute Error (MAE)_ measures the average magnitude of the absolute errors in predicting the _AQI_ from input values.