Skip to main content
. 2025 May 26;14(11):1882. doi: 10.3390/foods14111882
Algorithm 1: k-means++ clustering
Input:  X: a data set containing N samples
Output:  Set of Centroids (μp)
1:   Choose an initial center μ1 uniformly at random from X
2:   Choose the next center μp, selecting μp=x′∈X with probability
          Md(x′)2∑i=1NMd(xi)2
     //where Md(x) denotes the minimum distance between sample x to the previously computed centroid; x′ is the centroid selected from the given dataset X//
3:   Repeat Step (2) until we have chosen a total of ‘K’ Centers
4:   Proceed as with the conventional k-means++ algorithm in [38]
5:   Return μp