## 2 Principles and Methods
### Principles of Optimized Random Forest Algorithm
#### 2.2.2 Optimized Strategies  
(1) Feature Importance Evaluation and Feature Selection  
Evaluating the importance of various features helps identify the most influential features for the prediction target. This paper adopts the variable importance measure based on out-of-bag (OOB) data classification accuracy. **Definition 4**. : _The variable importance measure based on OOB data classification accuracy is defined as the average reduction in classification accuracy before and after a slight perturbation of the OOB data's independent variable values._  
Suppose there are bootstrap samples \(b=1\), \(2\), \(\ldots\), \(B\), where \(B\) represents the number of training samples. The variable importance measure \(\overline{D}_{j}\) of feature \(X_{j}\) is calculated as follows:  
Step 1. Set \(b=1\), create a decision tree \(T_{b}\) on the training sample, and mark the OOB data as \(L_{b}^{ob}\). Step 2. Use \(T_{b}\) to classify \(L_{b}^{ob}\) data, and count the number of correctly classified instances, denoted as \(R_{b}^{ob}\). Step 3. For feature \(X_{j}\), \(j=1\), \(2\), \(\ldots\), \(N\), perturb the value of \(X_{j}\) in \(L_{b}^{ob}\), and denote the perturbed dataset as \(\leavevmode\
obreak\ L_{bj}^{ob  
Step 5. Feature importance calculation: The variable importance measure \(\overline{D_{j}}\) of feature \(X_{j}\) is calculated using the following formula:  
\[\overline{D_{j}}=\frac{1}{B}\sum_{i=1}^{B}\left(R_{b}^{oob}-R_{bj}^{oob}\right) \tag{13}\]  
Step 6. Feature Ranking: Rank all features in descending order based on their importance measures. Step 7. Feature Selection: Select the top-ranked features for model training and prediction. (2) Random Forest Parameter Optimization  
The performance of the random forest model is mainly influenced by the number of trees \(n\), the maximum depth of each decision tree \(d\), the minimum number of samples required to split an internal node \(s\), and the maximum number of leaf nodes \(m\). Traditional methods use grid search for parameter optimization, which involves calculating the objective function value for each parameter combination by traversing each grid point. This approach often becomes trapped in local optima and has high computational complexity. To improve the efficiency and accuracy of parameter optimization, this paper employs a genetic algorithm for adaptive parameter optimization. As a classical intelligent algorithm (such as Harmony search algorithm [24; 25], cuckoo search algorithm [26; 27], and Sparrow Search Algorithm [28]), the Genetic Algorithm (GA) is considered one of the most classical heuristic algorithms, with perfect performance. The GA combines mathematical analysis and computer simulation methods, transforming the optimization problem-solving process into mechanisms similar to [PERSON]'s theory of natural selection and genetic mechanisms like chromosome gene crossover and mutation. Compared to some conventional optimization algorithms, this approach can often achieve better results faster, making it suitable for solving complex combinatorial optimization problems [29]. The steps for optimizing the random forest algorithm based on the genetic algorithm are as follows. Step 1. Initialization: Randomly generate a set of parameter combinations containing \(n\), \(d\), \(s\), and \(m\) to form the initial population. Step 2. Evaluation and Selection: Apply the random forest algorithm to each parameter combination in the initial population. Use classification accuracy as the evaluation criterion, calculate the classification accuracy of each parameter combination, and select the best parameter combination. Classification accuracy is defined as:  
\[Acc=\frac{\text{TP}+\text{TN}}{\text{TP}+\text{TN}+\text{FP}+\text{FN}} \tag{14}\]  
where TP (true positive) represents correct positive predictions; TN (true negative) represents correct negative predictions; FP (false positive) represents incorrect positive predictions; FN (false negative) represents incorrect negative predictions. Step 3.