# 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  
This study implements six customized and six ML.NET pre-implemented algorithms to train a model that can compute the _AQI_ based on the input values presented in Figure 5. The Results section conducts a comparative study on the _AQI_ solution's custom-made versus pre-implemented ML.NET algorithm. The custom-made ML models use the regression algorithms with all hyperparameters/parameters set by empirical tests and synthesized in Table 1, according to the algorithm employed, including [71]:  
1. Random Forest Regression (RFR) uses decision tree decomposition in the training process, and next, it uses the mean prediction for each tree [72]. In the evaluated RFR, the hyperparameters/parameters were set as follows: the number of estimators (_n_estimators_) to 500, the maximum features in each tree (_max_features_) to 10, random state (_random_state_) to 0 and, the decision tree maximum depth (_max_depth_) was set to 15;
2. Decision Tree Regression (DTR) is used for regression tasks, where the data are split into subsets based on feature values, creating a tree-like model of decisions. This approach allows for the modeling of complex relationships without requiring linear assumptions. Decision trees are valued for their interpretability and ability to handle numerical and categorical data. They can also manage missing values, making them versatile in practical applications [73; 74]. In this case, the hyperparameters/parameters were set as follows: the decision tree maximum depth (_max_depth_) was set to 5 (sufficient depth to ensure an accurate prediction, with low execution time), the random state (_random_state_) to 42, the minimum number of samples per split (_min_sample_split_) was 4, the minimum number of samples per leaf (_min_samples_leaf_) was set to 2, and the _criterion_ hyperparameter was set to \"_squared_error_\", and the tree was split using minimum mean squared error (MSE);
3. Linear Regression (LR) represents one of the simplest forms of regression analysis. This method assumes a straight-line relationship and is widely used due to its simplicity and ease of interpretation. The algorithm does not perform well in some situations when complex patterns are not identified, which leads to underfitting [75]. In this case, the algorithm calculates the parameter intercept (_intercept_) or bias (whose value is 7.014022494795359), the coefficients (_coef_) or weights for each of the eight features (respectively [\(-5.140072451758598\), \(0.3317304406559781\), \(3.1989070961349095\), \(-0.1828119410953855\), \(-0.03925884240140581\), \(0.0078299461929085\), \(0.00233905\) \(795529826\), \(1.0876253401024537\times 10^{-6}\)), and a single CPU was used to evaluate the model;  
Figure 5: Conceptual diagram of the prediction model. 4. The K-nearest neighbors (KNN) algorithm estimates the target variable's value by averaging the k-nearest neighbors in the feature space. This technique helps capture local patterns in the data and can adapt to various data distributions. Nonetheless, it tends to be computationally demanding, particularly with extensive datasets, since it necessitates calculating distances to every training sample [76]. We set the hyperparameters/parameters as follows: the algorithm uses 5 neighbors (_n_neighbors_), with all neighbors weighted equally (_weights = \"uniform\"_), 2 power parameters (_p_ = 2) for the Minkowski metric, and a single CPU;
5. Support Vector Regression (SVR) is a regression algorithm employed to approximate the output, knowing the input [77]. For SVR, we set the hyperparameters/parameters as follows: the regularization parameter (C) to 1.0 value, the kernel type was employed as a Radial Basis Function-RBF (_kernel = \"rbf\"_), the _epsilon_ value (tolerance) to 0.1, and the kernel coefficient, and the gamma parameter value (_gamma = \"scale\"_) was calculated using the input features;
6. Gradient Boosting Regression (GBR) method constructs an ensemble sub-trees based on the errors provided by the predecessor trees.