# Machine Learning Approaches for Ship Speed Prediction towards Energy Efficient Shipping
## 2 Material and Methodology
### Prediction Models
#### 2.4.1 Decision Tree Regressor  
DTR is a non-parametric supervised learning regression method [24] in the form of a tree structure with nodes and branches. In DTR, the features are partitioned into a rectangle space and a simple model (tree) is trained for each feature. The models are learned using a training dataset on a continuous range. Their output ends up being the mean value of the observations of training sets that are located on the same node. Classification and Regression Trees (CART) is one of the most common methods for tree-based regression methods. In CART, the feature space will be split into two regions after choosing the optimal split point to obtain the best model fit. This will execute recursively until the stopping rules are activated.  
To develop the model, for a given \(n\) number of dataset samples and \(d\) number of features, \(\mathcal{D}(\mathbf{(x_{i},y_{i})})\left(\left|\mathcal{D}\right|=n,\ \ \mathbf{x_{i} \in\mathbb{R}^{d}},\ \ y_{i}\in\mathbb{R}\right)\) the feature space is assumed to be split into \(K\)-number of regions, called \(R_{K}\) and the prediction value of the model is obtained from the average value of the observation which lies in the \(k^{\text{th}}\) region:  
\[\hat{y}_{i}=\mathbf{ave}(y_{i}|\mathbf{x}_{i}\in R_{k}). \tag{2}\]  
The best \(\hat{y}_{i}\) can be obtained by minimizing the least square error of \(\sum\left(y_{i}-\overline{y}_{i}\right)^{2}\). Though optimal \(\hat{y}_{i}\) values can be simply calculated, however, it is not easy to split the region. To overcome this, a greedy algorithm is applied recursively to determine the optimal splitting nodes until the stopping point is triggered. Usually, this depends on the hyperparameters and the difficulty of the fundamental problem. The selectable hyperparameters are:  
* The maximum depth of the tree (_max_depth_) which indicates how deep the built tree can be. The deeper the tree, the more splits it has, and it captures more information about the data; however, increasing depth could increase the computation time.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Remark** & **No.** & **Features** & **Units** \\ \hline \multirow{8}{*}{Input Features} & 1 & Max draught & m \\ \cline{2-4}  & 2 & COG & deg. \\ \cline{2-4}  & 3 & Total wave height & m \\ \cline{2-4}  & 4 & Total wave direction & deg. \\ \cline{2-4}  & 5 & Total wave period & sec \\ \cline{2-4}  & 6 & Wind speed & m/sec \\ \cline{2-4}  & 7 & Wind speed & m/sec \\ \cline{2-4}  & 8 & Pressure MSL & hPa \\ \cline{2-4}  & 9 & Ambient temperature & \({}^{\circ}\)C \\ \cline{2-4}  & 10 & Sea surface salinity & Psu \\ \cline{2-4}  & 11 & Current speed & m/s \\ \cline{2-4}  & 12 & Current speed & m/s \\ \cline{2-4}  & 13 & Gross tonnage & tons \\ \hline Output & 1 & SOG & knots \\ \hline \hline \end{tabular}
\end{table}
Table 3: Final selected features.  
* _min_samples_split_ represents the minimum number of samples required to split an internal node. This can vary between considering only one sample at each node to considering all of the samples at each node. When this parameter is increased, the tree becomes more constrained as it has to consider more samples at each node.
* The minimum number of samples required to exist at each leaf node (_min_samples_leaf_). This is similar to _min_samples_splits_, however, this describes the minimum number of samples at the leaves.
* In addition, the number of features (_max_features_) to consider while searching for the best split should be specified.