## 5 Establishment of Random-Forest Model  
Random forest [63] is an ensemble machine learning algorithm with CART decision trees as the base classifier, where each decision tree is generated independently and completely split. It can solve both classification and regression problems by combining multiple independent decision trees based on voting or taking the average value; this approach tends to have higher accuracy and greater stability than using a single decision tree. Each decision tree is generated according to the following rules: (1) For a training set size of \(N\), for each decision tree, \(N\) training samples that are put back are taken randomly from the training set as the training set. Approximately two-thirds of the observations are selected more than once, while the rest will not be chosen. The remaining one-third is called \"out of bag\" (OOB). (2) If the feature dimension of each sample is \(M\), a subset of \(mtry\) features is randomly selected from \(M\) features (\(mtry<<M\)), and \(mtry\) is called the split features. When the decision tree is split, the best of these \(mtry\) features is selected for splitting. Each tree grows to the greatest extent and without the pruning process. (3) To classify the samples of the testing set, the classification label is the majority vote decision of the decision trees. The introduction of random samples and random variables is crucial to the classification performance of the random-forest model. The former enables the model to have a more stable resistance to overfitting, and the latter enables it to have a higher accuracy rate than the decision tree method. The architecture of the random-forest model is shown in Figure 7. The working process is summarized as follows: random samples are input to each independent decision tree for classification, and each decision tree provides independent results. For the classification problem, the final decision is made by considering the majority of votes to determine the classification result.  
The random-forest model classification performance is related to two factors [52]: the correlation of any two trees (the higher the correlation, the higher the error rate) and the classification ability of each tree (the stronger the classification ability, the lower the error rate). The classification ability of a tree and the correlation between two trees increases with the split features \(mtry\). Therefore, the key problem is to determine the optimal split features \(mtry\) such that the classification ability and correlation are balanced, which is a parameter of the random-forest model. In addition, the more the number of decision trees, the better the randomization of the model, and thus the smaller the testing error of the model. Theoretically, the more the number of decision trees \(T\), the better the randomization. With increasing number of decision trees, the test error variation decreases; hence, a reasonable number of trees can be determined. Hence, the split features \(mtry\) and the number of decision trees \(T\) are the two parameters of the random-forest model. The number of decision trees in the random-forest model can be determined by modifying the split features \(mtry\) and OOB error, while the error can be adjusted by changing the split features \(mtry\) and the number of decision trees \(T\).  
Figure 7: Architecture of a random-forest classification model.