# Analysis of Trends in Mega-Sized Container Ships Using the K-Means Clustering Algorithm
## 2 Materials and Methods
### K-Means Clustering  
\(K\)-means clustering is a clustering method that clusters non-hierarchical data and indicates clusters between data with similar tendencies. This method is the most widely used non-hierarchical cluster classification method and has the advantage of being able to classify many data quickly and easily. In this study, the trend was analyzed through the group of the largest ship among the clustered data. [PERSON] and [PERSON] [PERSON] and [PERSON] (2015) analyzed the ship's main dimensions by classifying them according to the visual form of the graph. However, since the classification method is different depending on the subjective evaluation of the researcher, there is a disadvantage that the classification standard varies depending on the analyst. In this study, the groups were quantitatively classified by performing clustering through the \(k\)-means clustering technique. Cluster analysis is a method of classifying an initial dataset and finding hidden patterns [PERSON] and [PERSON] (2018). \(k\)-means cluster analysis is a method of relocating data based on similarity by randomly dividing the data into \(k\) clusters and dividing the mean of the clusters into representative values [PERSON] and [PERSON] (2018). Based on the centroid value of each cluster, each object is assigned to the nearest centroid using the Euclidean distance, and data objects are clustered based on the closest \(k\)-mean value [PERSON] and [PERSON] (2018). The data are displayed as a voronoi diagram based on the average value, and the average distance for each \(k\) cluster division is readjusted and repeated until it converges to a specific \(k\) value. This process is sensitive to outliers; therefore, it must be performed after data preprocessing, and effective results can be obtained only when an appropriate number of clusters \(k\) is specified as an input parameter. When the variable with the characteristics \(i=1,\ 2,\ldots,N,\)\(j=1,\ 2,\ldots,p\) is \(x_{ij}\), the distance between \(i\  
In this case, \(a_{ik}\) is a binary variable with a value of 1 or 0. The formula for \(k\)-means clustering is as follows:  
\[argmin_{a,n}\sum_{k=1}^{K}\sum_{i=1}^{N}a_{ik}||x_{i}-\mu_{k}||^{2} \tag{7}\]  
In this study, the appropriate number of clusters \(k\) was derived using the NbClust package [32] of the R program version 4.1.1 and applied to clustering. The NbClust package can test and compare most indices proposed in previous studies and provides indices that determine the number of clusters in the dataset. In addition, it provides the optimal number of clusters \(k\) from the results of various methods. This allows multiple clustering schemes to be evaluated simultaneously while changing the number of clusters to determine the most appropriate number of clusters for the dataset of interest. Table 3 presents the 26 indices used in this study. The 26 indices refer to the most appropriate number of \(k\), which is proposed in previous studies [33; 34; 35; 36; 37; 38; 39; 40; 41; 42; 43; 44; 45; 46; 47; 48; 49; 50; 51; 52; 53; 54; 55; 56; 57]. Figure 8: Results of \(k\)-means clustering on container ship deadweight tonnage–length overall (m). (**a**) Number of clusters selected by NbClust; (**b**) Hubert statistic values; (**c**) D index value; (**d**) scatter plot clustered into three groups. \begin{table}
\begin{tabular}{c c} \hline \hline
**Index by NbClust Package** & **Reference** \\ \hline KL & Krzanowski and Lai [33] \\ CH & Calinski and Harabasz [34] \\ Hartigan & Hartigan [35] \\ CCC & Sarle [36] \\ Scott & Scott and Symons [37] \\ \hline \hline \end{tabular}
\end{table} 
Table 3: \(K\)-means clustering indices using NbClust package in this study. \begin{table}