# Learning-Based Colorization of Grayscale Aerial Images Using Random Forest Regression
## 2 Materials and Methods
### Random Forest  
Random forest is a highly versatile ensemble of decision trees that performs well for linear and non-linear prediction by finding a balance between bias and variance [20]. This ensemble learning method constructs and subsequently averages a large number of decision trees for classification or regression purposes [24; 25]. At this time, to avoid correlation among the trees, RF increases the diversity of the trees by forcing them to grow from different training data created through a procedure called bootstrap aggregating (bagging) [26]. Bagging refers to aggregating base learners trained through bootstrapping, which creates training data subsets by randomly resampling a given original dataset [27]. That is, as a process of de-correlating trees to train different datasets, it increases stability and makes it more robust when facing slight variations in the input data [28]. Furthermore, approximately one-third of the samples are excluded for the tree training in the bagging process, which is known as the \"out-of-bags\" (OOB) samples. These OOB samples can be used to evaluate performance, which allows the RF to compute an unbiased estimation of the generalization error without using an external data subset [29]. From the predictions of the OOB samples for every tree in the forest, the mean square error (MSE) is calculated, and the overall MSE is obtained by aggregation, as shown in Equation (1):  
\[MSE_{\text{OOB}}=\ \frac{1}{n}\sum_{i=1}^{n}{(y_{i}-\overline{y_{i_{OOB}}})^{2}} \tag{1}\]  
Figure 4: Experimental area of site 4: (**a**) input grayscale image acquired on 10 June 2013, (**b**) reference color image acquired on 2 June 2016.  
Figure 3: Experimental area of site 3: (**a**) input grayscale image acquired on 10 June 2013, (**b**) reference color image acquired on 2 June 2016.  
where \(n\) is the number of trees, \(y_{i}\) denotes the prediction for the \(i\)th observation, and \(\overline{\hat{y}_{i_{\text{OOB}}}}\) denotes the average of the OOB predictions for the \(i\)th observation.  
Furthermore, the use of RF requires the specification of two standard parameters: the number of variables to be selected and tested for the best split at each node (mtry), and the number of trees to be grown (ntree). At each node per tree, the number of mtry variables from the total variables in the model is selected at random, the variable that best splits the input space and the corresponding split are computed, and the input space is split at this point [30]. In a regression problem, the standard value for mtry is one-third of the total number of variables due to computational benefits [31; 32]. In the case of ntree, the majority of the studies set the ntree value to 500 since the errors are stabilized before this number of regression trees is achieved [33]. However, recent studies have found that the number of trees does not significantly affect performance improvement, which allows the selection of ntree to consider the performance and training time together [34; 35; 36].  
Random forest can also be used to assess the importance of each variable during modeling. To determine the importance of input variables, a variable is randomly permuted, and regression trees are grown on the modified dataset. The measure of each variable's importance is then calculated as the difference in the MSE between the original OOB dataset and the modified dataset [37; 38]. A key advantage of RF variable importance is that it not only deals with the impact of each variable individually but also looks at multivariate interactions with other variables [39].