# Defect Detection and Error Source Tracing in Laser Marking of Silicon Wafers with Machine Learning
## 2 Materials and Methods  
A random forest classifier algorithm was chosen because of its powerful ensemble machine learning, which has been used primarily for classification tasks. Random forest is widely used because of its robustness, accuracy, and ability to handle complex high-dimensional data. It operates by constructing a multitude of decision trees during training and makes predictions based on the majority vote of those trees. It works as a flow function: Ensemble of decision trees: Random Forest builds multiple decision trees using different random subsets of the training data and features. Each tree is trained independently and may view the data differently. Bootstrapping: Each tree is trained on a bootstrapped sample, meaning that it is built from a random sample of data selected with replacement. This ensured the diversity among the trees. Feature randomness: during the tree-building process, at each split, only a random subset of features is considered, further increasing the diversity and reducing the correlation between trees. Voting mechanism: For classification, each tree votes for a class, and the class with the most votes is the final prediction. For regression analysis, the average of all tree predictions was used [16]. The key steps of this algorithm are as follows: Randomly select subsets of data and features for each tree. A decision tree is built for each subset. A new data point passes through all trees and collects their predictions. Aggregate predictions (majority vote for classification, mean for regression). Advantages of it are it reduces overfitting: By averaging the predictions of many trees, random forest reduces the risk of overfitting that is common with single decision trees; and handles missing data: it can maintain accuracy even when some features are missing. Feature importance: random forest can provide measures of feature importance, helping identify the variables that are most influential in the data. Versatility: it works well for both classification and regression problems and can handle large datasets with high dimensionality. When using the random forest algorithm to solve regression problems, we use the mean squared error (MSE) to determine how the data branch from each node. \[MSE=\frac{1}{N}\sum_{i=1}^{N}(fi-yi)^{2}\]  
where \(N\) is the number of data points, \(fi\) is the value returned by the model, and \(yi\) is the actual value of the data point \(i\). A random forest python code is applied; the selective parameters are set as follows. The number of decision trees in the forest: 1000, maximum depth of each tree: 4, to prevent overfitting, minimum number of samples required to split an internal node: 2, minimum number of samples required to be at a leaf node: 1, number of features considered at each split: sqrt, using bootstrap samples while building trees and random seed: 42 to ensure reproducibility. In total, 1000 pieces of a tree from the iris databases with 4 various classes were employed to test the functioning and accuracy of the code. The 4 classes of the random forest decision boundaries are illustrated in Figure 1 and the classifications have an accuracy of 89.0 and kappa = 0.853; the entire computing took around 20 min on a regular CPU desktop computer with 64 GB RAM. The specifications of the experimental camera and laser marking machine are listed in Tables 1 and 2, respectively. Photographs of the microscope and laser marking machine are shown in Figure 2. \begin{table}
\begin{tabular}{c c} \hline
**Item** & **Specification** \\ \hline Frame Rate & 60 fps \\ Image Resolution & 1920 \(\times\) 1080 pixel \\ Sensor & 1/2.8\({}^{\prime\prime}\) SONY \\ Pixel Size & 2.9 \(\times\) 2.9 \(\upmu\)m \\ Picture & SD card 38M \\ Light & Ring Light 52D LED \\ Measurement & Via software \\ Output Interface & HDMI + USB \\ \hline \end{tabular}
\end{table} 
Table 1: Specification of argus microscope. Figure 1: The 4 classes of the random forest decision boundaries.