# A Traffic-Based Method to Predict and Map Urban Air Quality
## 2 Materials and Methods
### Modeling  
#### 2.4.1 Decision Trees Algorithm  
The predictive models were built by using a category of the machine learning method called Decision Trees. The chosen algorithm was C4.5 ([PERSON] et al., 2016). Besides its high classification performance, this method offers an easy tree-based visualization that facilitates the interpretation of the output of the model. C4.5 is based on a top-down recursive divide and conquer strategy. An attribute to split on is selected at the root node, and then a branch is created for each possible attribute value. This operation splits the instances into subsets, one for each branch that extends from the root node. Then, this procedure is repeated recursively for each branch, selecting an attribute at each node and choosing only instances that reach that branch to make the selection. The purest split defines the selection of the best attribute for each node. To do so, the heuristic used in C4.5 is based on information theory and quantification of entropy, which measures information in bits for each of the possible outcomes (\(p\)), as described in Equation (1). The idea is to know how much information is gained by knowing the value of an attribute. The information gain is obtained by calculating the entropy of the distribution before the split minus the entropy of the distribution after the split. At each node, the attribute to be selected is the one that provides the highest information gain. The process is repeated until reaching the end of the tree (pure nodes) or getting a maximum depth that preserves the readability of the model. The program J48 from the machine learning workbench Weka was used as the implementation of the algorithm C4.8 (upgraded version of C4.5) to train and test the models. \[entropy(p_{1},\ p_{2},\ \ldots,\ p_{n})=-p_{1}logp_{1}-p_{2}logp_{2}\ldots-p_{n} logp_{n} \tag{1}\]In this study, three types of models were created from four days of measurements: 30 May 2019, and 3, 12 and 18 June 2019. The first one is based on an IDW to predict the concentration of PM\({}_{2.5}\) at street level. The values used to proceed with this calculation are provided by the four closest monitoring stations of the Secretariat of the Environment: Belisario (elev. 2835 m.a.s.l., coord. 78\({}^{\circ}\)29\({}^{\prime}\)24\" W, 0\({}^{\circ}\)10\({}^{\prime}\)48\" S), Centro (elev. 2820 m.a.s.l., coord. 78\({}^{\circ}\)30\({}^{\prime}\)36\" W, 0\({}^{\circ}\)13\({}^{\prime}\)12\" S), [PERSON] (elev. 2739 m.a.s.l., coord. 78\({}^{\circ}\)29'50\" W, 0\({}^{\circ}\)6'28\" S), and El Camal (elev. 2840 m.a.s.l., coord. 78\({}^{\circ}\)30'36\" W, 0\({}^{\circ}\)15'00\" S) (see Figure 1b). Each of those stations are located about 4-6 km apart from each other (study radius of about 8 km). This method provides an estimation of the pollution concentration which is inversely correlated to the distance from the measured contamination (monitoring stations) [33], IDW assumes that each measured point has a local influence that diminishes with distance. It gives greater weights to points closest to the prediction location, and the weights diminish as a function of distance, as described in Equation (2). Where \(Zp\) stands for the interpolated value of pollution, \(Zi\) stands for the actual values measured at the monitoring stations, \(n\) stands for the number of stations considered (here \(n=4\)), and \(d\) stands for the distance between the monitoring stations and a given geolocation point. It is to note that different powers (\(p\)) can be used to calculate the distance. The \(p\) value defines the smoothness of the interpolation. Increasing the p raises the overall influence of the known values on the concentration gradient. For instance, a \(p=2\) will provide values more localized and not averaged out as much as a \(p=1\). \[Z_{p}=\frac{\sum_{i=1}^{n}\left(\frac{z_{i}}{d_{i}^{2}}\right)}{\sum_{i=1}^{n} \left(\frac{1}{d_{i}^{2}}\right)} \tag{2}\]  
The two other types of models are based on a closer but indirect measurement of the pollution: traffic intensity and time of the day.