## 2 Material and Methods
#### 2.2.2 K-Means and K-Means++ Clustering Algorithms  
The K-means algorithm is an unsupervised clustering algorithm [19]. It divides the data into k clusters, where the centroid, also referred to as the center of each cluster, is determined by the mean of the data in that cluster. Set the dataset to be clustered to \(X=\{x_{1},x_{2},\ldots,x_{n}\}\), and the \(i\)th cluster to be divided to \(D\_i\); then the steps of the K-means algorithm are as follows:  
1. Randomly select \(k\) centroids \(u_{1},u_{2},\ldots,u_{k}\) in \(X\).
2. Calculate the distance from \(x_{i}\) to each centroid \(|x_{i}-u_{k}|^{2}\), select the centroid \(u_{p}\) with the minimum distance from \(x_{i}\) to each centroid, and update the cluster \(D_{p}=u_{p}\cup\ x_{i}\).
3. Calculate the mean within each cluster and update the centroids.
4. Repeat steps 2 and 3 to obtain the cluster \(\{D_{i}\}_{i=1}^{k}\).  
The K-means algorithm has been proven to be convergent. However, the random selection of the initial centroids in this algorithm has a great impact on the final result and running speed. Therefore, the K-means++ algorithm has been designed to optimize the selection of the initial centroids [20]. The steps of the K-means++ algorithm are as follows:  
1. Randomly choose an initial centroid \(u_{1}\).
2. Calculate the minimum distance \(d_{i}\) from \(x_{i}\) to the selected centroid.  
Figure 1: Structure of unsupervised factor importance analysis model.  
Select the next centroid according to the probability; the sample with larger \(d_{i}\) has a greater probability of being selected.  
Repeat steps 2 and 3 until \(k\) centroids are selected.  
Method for Determining Cluster Number K  
Within the K-means series of algorithms, the number of clusters, denoted by \(K\), is a very important parameter that plays a crucial role in the division of the data into multiple clusters. The selection of k typically involves two methods: the elbow method and the silhouette coefficient method.  
The core idea of the elbow method is to evaluate the sum of squares of errors (SSE):  
\[\text{SSE}=\sum_{i=1}^{k}\sum_{x\in D_{i}}\lvert x-u_{i}\rvert^{2} \tag{1}\]  
As the number of clusters \(k\) increases, the degree of aggregation in each cluster increases as well. Consequently, the squared error and SSE become smaller. When the decline in the SSE is no longer significant, the benefits of increasing the \(k\)-value are minimal. The diagram shows the inflection point of the SSE image.  
The elbow method usually requires manual observation of the location of the inflection point to select the k value, while the contour factor method determines the rationality of the clustering method by calculating the silhouette coefficient of the clustering result. The steps for the contour factor method are as follows:  
1. For \(x_{i}\) of cluster \(D_{p}\), calculate the dissimilarity \(\text{a}(i)\) within the cluster: \[\text{a}(i)=\frac{1}{card(D_{p})}\sum_{x\in D_{p}}\lvert x_{i}-x\rvert^{2}\] (2)
2. Calculate the inter-cluster dissimilarity \(\text{b}(i)\) of \(x_{i}\) of the cluster \(D_{p}\): \[\text{b}(i)=min\Bigg{\{}\frac{1}{card(D_{s})}\sum_{x\in D_{s}}\lvert x_{i}-x \rvert^{2}\Bigg{\}}_{s\
eq p}\] (3)
3. Calculate the silhouette coefficient \(\text{s}(i)\) of \(x_{i}\): \[\text{s}(i)=\frac{\text{b}(i)-\text{a}(i)}{max\{\text{a}(i),b(i)\}}\] (4)
4. The average of the silhouette coefficients \(\text{s}(i)\) of all samples is calculated as the silhouette coefficient of the clustering result. A larger silhouette coefficient of the clustering result indicates a more reasonable clustering result.