Skip to main content
. 2023 May 18;18(5):e0286034. doi: 10.1371/journal.pone.0286034

Table 2. Main procedures of K-means.

Select k users as centroids based on the dataset
Input: u, training users; k, the number of clusters
Output: {c1,c2,…ck}, k centroids
1. Determine the expected numbers of clusters, k
2. Select the users consistently at random from u, as initial starting points.
3. Assign each user to the cluster with the nearest centroid.
4. Calculate the mean of all clusters and update the centroid value according to the mean value of that cluster.
5. Repeat Steps 3 and 4, until no user changes its cluster membership or any other convergence criteria are met.
6. Return {c1,c2,…ck}