# Assessment of Hull and Propeller Degradation Due to Biofouling Using Tree-Based Models
## Appendix A Tree-Based ML Algorithms
Next, for each bootstrap sample, a decision tree is constructed using the CART algorithm. To introduce diversity among the trees in the ensemble, feature randomness is incorporated. At each split during decision tree construction, a random subset of features is considered. Finally, once all of the trees are built, predictions are made by aggregating the individual tree predictions. This is achieved by calculating the mean of the predicted values from each tree. The \"n_estimators\" hyperparameter refers to the number of individual decision trees that are created and combined in the ensemble. Extremely randomized trees build upon the idea of random forests by introducing additional randomness during the tree construction process ([33]). This randomness leads to further diversity among the trees in the ensemble, which can enhance their predictive performance. The CART algorithm is utilized to construct individual decision trees within extremely randomized trees. The construction of extremely randomized trees involves several steps. Firstly, bootstrapping is employed, similar to random forests, to create multiple bootstrap samples from the original training data. Each bootstrap sample is generated by randomly selecting instances with replacement. Secondly, feature randomness is introduced in extremely randomized trees. At each split point during the tree construction process, thresholds for each feature are randomly selected without evaluating the optimal split points. This random selection of thresholds adds more randomness and reduces correlation between the trees in the ensemble. Thirdly, individual decision trees are constructed using the CART algorithm. The feature space is recursively partitioned, and each tree is grown by selecting random thresholds for each feature and choosing the split that minimizes the SSE within each leaf node. Finally, after constructing all of the trees, predictions are made by taking the mean of the predicted values from each tree. The hyperparameter \"n_estimators\" specifies the number of individual decision trees that are generated and aggregated as an ensemble. Gradient tree boosting, or gradient boosted regression trees (GBRT), is an ensemble learning method that combines the predictive power of decision trees with the concept of boosting ([34]). It builds an ensemble of weak prediction models, typically decision trees, in a stage-wise manner. Based on the principle of gradient boosting, each subsequent model tries to correct the residuals (errors) of the previous models. The construction of GBRT entails a series of distinct steps. Firstly, the predictions are initialized by using a selected value, such as the mean of the target variable. This value acts as the starting point for subsequent iterations. An iterative process then begins: the difference between the actual target values and the prediction from the previous iteration is calculated, resulting in residuals that represent the errors to be rectified by the current model. Following that, for each iteration, a new decision tree is built using the CART algorithm. After constructing the tree, the predictions from the tree are multiplied by a learning rate, which governs the contribution of each tree to the final prediction. These predictions are then aggregated to update the overall prediction of the GBRT. This iterative process continues with each iteration aiming to reduce the remaining residuals. Multiple decision trees are added to the ensemble, and their predictions are combined with the previous predictions to progressively refine the overall model. ```
1. # Function to compute SSE for a given set of target values
2. function compute_SSE(target_values):
3. mean_value = mean(target_values)
4. SSE = sum((target_value - mean_value) ^ 2 for target_value in target_values)
5. return SSE
6. # Function to split data into two subsets based on a feature and split point
7. function split_data(dataset, feature, split_value):
8. A1 = subset of dataset where feature <= split_value
9.