## 2 Materials and Methods
### Modelling  
#### 2.3.1 Random Forest  
The Random Forest algorithm combines a series of independent regression trees by selecting random samples and features [27]. By generating a set of weak learners based on a bootstrap of the data, the algorithm converges to an optimal solution while avoiding issues related to CARTs and parametric statistics. In this paper, the Random Forest algorithm in the Matlab environment (v2016) was used to model the relationship between the 23 environmental variables and site-specific NAI measurements across the Zhejiang Province.  
Ninety percent of these data were used for model training, and the rest were used for model testing.  
In the training procedure, each tree was built on a random subset of the original data (with replacements). Three parameters were optimized and named \(\mathrm{N_{trees}}\), \(\mathrm{M_{try}}\), and \(\mathrm{Min_{leaf}}\). The first parameter presented the number of trees in the forest. \(\mathrm{M_{try}}\) is the number of feature variables selected randomly for each decision split, and it was always set to one-third of the total number of variables for regression by default. As for \(\mathrm{Min_{leaf}}\), it defined the minimum number of observations per tree leaf and its default value was 5.  
The modeling workflow is exhibited in Figure 2. During the training process, \(\mathrm{N_{trees}}\) were identified according to the change in OOB.Error, and values of \(\mathrm{Min_{leaf}}\) and \(\mathrm{M_{try}}\) were ensured and combined with the grid search according to the determination coefficient (R\({}^{2}\)), root mean square error (RMSE), and bias obtained by ten-fold cross-validation. The model error decreased when \(\mathrm{N_{trees}}\) increased to a certain level, and \(\mathrm{Min_{leaf}}\) and \(\mathrm{M_{try}}\) were influenced mutually. Considering the training time, the optimal parameter combination was chosen based on the training samples, and the model of validation samples and test samples were evaluated.  
The relevant calculation formulas are as follows:  
\[\mathrm{R_{C}}=\left|\frac{\mathrm{X_{n}}-\mathrm{X_{n-1}}}{\mathrm{X_{n-1}}}\right| \tag{1}\]  
where \(\mathrm{R_{C}}\) represents the rate of change in the OOB.Error, \(\mathrm{X}\) is OOB.Error, and \(\mathrm{n}\) is the number of trees.  
\[\mathrm{R^{2}}=\sum_{i=1}^{n}(\hat{y_{i}}-\overline{y_{i}})^{2}/\sum_{i=1}^{n }(y_{i}-\overline{y_{i}})^{2} \tag{2}\]  
\[\mathrm{RMSE}=\sqrt{\frac{1}{n}\sum_{i=1}^{n}(\hat{y_{i}}-y_{i})^{2}} \tag{3}\]  
\[\mathrm{Bias}=\overline{\hat{y_{i}}}-\overline{y_{i}} \tag{4}\]  
where \(\hat{y}\) is the predicted value, \(y\) is the measured value, \(\overline{y}\) is the mean of the predicted value, \(\overline{y}\) is the mean of the measured value, and \(\mathrm{n}\) is the number of samples in the validation set.  
Variable importance measures (VIM) performed from the RF algorithm made it possible to explore the weight of each input variable. For any variable, feature importance measures the increase in prediction error. The VIM metric is computed for each tree, then averaged and divided by the standard deviation of the entire ensemble. In this paper, 23 feature variables are ranked based on their feature importance score.