## 2 Methodology
### The 1 st ML Model to Predict the Spatial Distribution of Particles on the Substrate
#### 2.3.3 Model Optimization--Weighted Random Forest  
The significantly lower train MSE compared to the validation and test MSEs suggests that the decision tree model has overfit the training data. To mitigate this, a random forest model is adopted. Unlike decision trees, random forests are less prone to overfitting due to their ensemble approach. Specifically, individual decision trees are prone to being overly deep and structurally complex, which often leads to overfitting on the training set [25]. In contrast, random forests train multiple relatively shallow and independent decision trees, and their outputs are averaged (or combined through majority voting), thereby reducing the likelihood of overfitting and improving the model's generalization ability. In addition, a 10-fold cross-validated random search is employed to optimize the hyperparameters of the random forest model. Compared to a fixed validation set, 10-fold cross-validation provides a more robust evaluation of the model's generalization performance. Since the current interpolated data has been carefully selected following an active learning strategy (see Appendix B), it aligns closely with the original data. Consequently, the previous 40 validation dataset samples are merged into the training set to enable cross-validation. The updated data distribution is illustrated in Figure 14. The optimized hyperparameters based on the grid search are shown in Table 5.  
Even within a random forest, the learning performance of different trees can vary: some trees may fit the data pattern well, while others may still exhibit a certain degree of underfitting. To further improve accuracy, a weighted random forest strategy is employed. In this approach, each tree is assigned a weight based on its performance on the training set, with better-performing trees receiving higher weights. This ensures that the ensemble prioritizes the contributions of more effective trees. Figure 14: Dataset partitioning for model optimization. \begin{table}
\begin{tabular}{c c} \hline \hline _Hyperparameters_ & _Values_ \\ \hline _N estimators_ & 200 \\ _Max depth_ & None (Unlimited) \\ _Min samples split_ & 2 \\ _Min samples leaf_ & 1 \\ _Max features_ & None (Unlimited) \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Optimized hyperparameters of the random forest model. During the training of the \(i\)-th random forest tree, the algorithm draws a bootstrap sample (of the same size as the training set) from the overall training data using sampling with replacement. This means that some samples may be selected multiple times, while others may not be selected at all; the latter become the out-of-bag (OOB) samples for the \(i\)-th tree. Since these samples are never used in training that tree (never appear in the \(i\)-th tree's training set), they serve as a natural test set for assessing its performance. Hence, for each tree in the random forest, the MSE computed on its own OOB samples (Equation (29)) is used to determine the corresponding weight for that tree (Equation (30)). To enhance the weight differences among trees, an amplification factor (\(\alpha\)) is applied (Equation (29)), where it serves as an exponent to adjust the weighting emphasis on trees with different error levels. Setting \(\alpha=1.1\) results in inverse-error weighting (i.e., trees with lower OOB error receive proportionally higher weights), while larger values of \(\alpha\) impose a stronger penalty on trees with higher errors. Additionally, an infinitesimal constant (\(\varepsilon\)) is introduced to prevent division by zero. After determining the weights, the final prediction \(\hat{y}\) for any new sample is computed by combining the weighted outputs of all the individual trees (Equation (31)), ensuring that trees with lower OOB error contribute more to the ensemble prediction.