# Assessment of Hull and Propeller Degradation Due to Biofouling Using Tree-Based Models
## Appendix A Tree-Based ML Algorithms  
Decision trees are powerful and interpretable models used for both classification and regression tasks. In this report, we focus on decision trees for regression, specifically those that employ the CART (classification and regression trees) algorithm ([31]). A decision tree for regression is a predictive model that uses a tree-like structure to make predictions on continuous numerical target variables. The CART algorithm constructs the decision tree by recursively partitioning the feature space into smaller regions, with the goal of minimizing the sum of squared errors (SSE) within each partition. The CART algorithm starts with the entire dataset and selects a feature \(v\) to split the data. It evaluates different split points for the selected feature and chooses the one that results in the lowest SSE. The splitting process divides the dataset into two subsets \(A_{1}\) and \(A_{2}\) based on the feature value \(f_{v}\), creating left and right child nodes. The cost function minimized with the spilt is given by the following:  
\[J(v_{i}f_{v})=\frac{k_{1}}{k}SSE_{1}+\frac{k_{2}}{k}SSE_{2} \tag{1}\]  
where \(k\), \(k_{1}\), and \(k_{2}\) are the numbers of instances in the original dataset and in subsets \(A_{1}\) and \(A_{2}\), respectively. Thus, the SSE is given as follows:  
\[SSE_{j}=\sum\
olimits_{i\in A_{j}}\left(y_{i}-\overline{y}_{j}\right)^{2}, \text{ for }j=1,2 \tag{2}\]  
\[y_{j}=\frac{1}{k_{j}}\sum\
olimits_{i\in A_{j}}y_{i},\text{ for }j=1,2 \tag{3}\]  
The splitting process is applied recursively to each child node until a stopping criterion is met. This criterion can be a maximum tree depth, a minimum number of samples per leaf node, or a minimum reduction in SSE. The recursive nature of the algorithm allows complex relationships to be captured between features and the target variable. When the recursion stops, the resulting tree contains terminal nodes called leaf nodes. Each leaf node represents a prediction for the target variable in the corresponding region of the feature space. In the case of regression, the prediction is typically the mean or median value of the target variable within that region. The predictions from the leaf nodes form the final output of the decision tree model. Typically, the \"max_depth\" and \"min_samples_leaf\" hyperparameters are tuned when creating a decision tree model. Specifically, the \"max_depth\" hyperparameter determines the maximum depth or levels of the decision tree. It controls how many splits or branches the tree can have from the root node to the leaf nodes. A higher value can result in a more complex tree that can potentially overfit the training data, while a lower value can lead to underfitting. On the other hand, the \"min_samples_leaf\" hyperparameter sets the minimum number of samples required in a leaf node. If the number of samples in a potential leaf node is less than the specified value, further splitting is halted, and the node becomes a leaf. A higher value can prevent the tree from creating very specific rules for a small subset of data, reducing overfitting. These hyperparameters play a crucial role in controlling the complex and generalization ability of a decision tree model for regression tasks. A pseudocode for the Decision Tree regression algorithm (CART) is presented in Algorithm 1. Random forests for regression combine the strength of decision trees with ensemble techniques ([32]). Instead of relying on a single decision tree, random forests aggregate predictions from multiple trees, providing more robust and accurate regression results. The CART algorithm is employed to construct individual decision trees within the random forest. Random forests are constructed through the following steps. First, the algorithm begins by bootstrapping, where subsets of the original training data are randomly selected with replacement. These subsets, called bootstrap samples, have the same size as theoriginal dataset but can contain duplicate instances.