# Assessment of Hull and Propeller Degradation Due to Biofouling Using Tree-Based Models
## 4 Development of Data-Driven Models
### Data Preparation  
Before feeding the data to an ML algorithm, suitable preparation is required to ensure their quality. In the present study, data preparation was implemented in three steps:  
* Data smoothing
* Voyage extraction
* Threshold value filtering  
These processes are described hereafter. Data smoothing aims to remove signal noise while preserving the main trend. To do this, first, a simple moving average (SMA) filter is applied to each signal (features and output variables). The signal is denoted as X(i), where i represents the data sample at a certain time. The equation for calculating the SMA at time i, denoted as SMA(i), with a window size of k can be expressed as follows:  
\[SMA(i)=\frac{X(i)+X(i-1)+X(i-2)+\cdots+X(i-k+1)}{k} \tag{14}\]  
Then, each SMA-smoothed signal is decimated by a factor of k, i.e., only one sample out of k samples is retained, where k is equal to the window size used for the moving average. In Figure 7, window sizes of 5, 10, and 15 for two variables are compared to show the effect of k. The selected sizes are commonly used in the literature; for example, [11; 12; 17; 24] chose a 5 min window, while [28; 29] chose 10 and 15 min windows, respectively. Clearly, the wider the time window, the more intense the effect of the smoothing. In the current study, we visually compare the effect of these window sizes by inspecting the time series of the original signals and the smoothed signals. Based on our observations, a window size of 5 min effectively reduces the sharpest spikes while maintaining sufficient resolution for accurate model training. Since it is the smallest window of the three, it preserves higher data resolution, providing more data points for the machine learning models. \begin{table}
\begin{tabular}{c c} \hline \hline
**Feature Set w/o Days** & **Feature Set w/Days** \\ \hline STW & STW \\ \hline Mean Draft & Mean Draft \\ \hline Trim & Trim \\ \hline RoT & RoT \\ \hline Wind x & Wind x \\ \hline Wave x & Wave x \\ \hline Current & Current \\ \hline - & Days \\ \hline \hline \end{tabular}
\end{table} 
Table 5: List of the selected features with or without the Days feature. Voyage extraction: An assessment of the vessel's hydrodynamic performance makes sense only in sailing conditions. Thus, it is important to identify in the data records the time intervals during which the ship was traveling. With voyage extraction, the identification of time intervals in the dataset corresponding to actual ship voyages, therefore excluding port calls, is achieved. Thus, a list of the start and end date/time of voyages during the reporting period is derived from noon reports. Subsequently, a dataset containing only voyages is extracted. Threshold value filtering involves the rejection of data points based on threshold values. In such a way, only the values inside the operational range of choice are kept, ensuring that the data analysis is focused on specific conditions related to open-sea operation. Therefore, certain criteria are subsequently applied to the dataset, as presented by the lower and upper limits of Table 6. For the definition of these values, the histogram of each variable is examined to identify the tails of the distributions, as these represent unrepresentative conditions occurring over short periods ([30]). Therefore, the chosen thresholds ensure that only data points within the operational range of interest are retained. These data preparation steps caused a progressive reduction of the number of data points with respect to the raw data, as shown in Figure 8, where the number of points after each step is indicated, showing that the greatest reduction occurred during the smoothing process. This reduction was a side effect deemed necessary to eliminate spikes and reduce the noise present in the raw data.