Skip to main content
. Author manuscript; available in PMC: 2022 Apr 8.
Published in final edited form as: IEEE/ACM Trans Comput Biol Bioinform. 2021 Apr 8;18(2):633–643. doi: 10.1109/TCBB.2019.2921577

Algorithm 1.

Object weighting K-means

Input:
- the dataset X with n objects
- the object weighting scheme (WS 1 to 7 defined in Section 2.1)
Output:
- the best clustering according to the selected WS
- the object weights and the cluster centroids
1. Parameter setting. Choose the number of clusters K and the weighting scheme (see Equations 511). Set wi = 1, for i = 1,…,n.
2. Setting initial centers and clusters. Assign K objects from X, selected at random, to be initial cluster centers c1, c2,…, CK. Assign each object xiX to the cluster Sk represented by the nearest ck as per (2) to form the initial clustering S.
3. Cluster update. Let L(Sk,ck,w)=xiSkwi(v=1V(xivckv)2) be the weighted within sum of squares of the cluster Sk. For all objects xiSk and all clusters Sk (k = 1,…,K) do:
If there exists a cluster Sk′ such that after moving xi from Sk to Sk′, we have:
DIFF = L(Sk, ck, w) + L(Sk′, ck′, w) − L(Sk \ xi, ck, w) − L(Sk′xi, ck′, w) > 0
then assign xi to the cluster Sk′ that provides the maximum of DIFF. The cluster centers and object weights in both Sk and Sk′ are updated when calculating DIFF. When all objects of X are examined, a new clustering S′ = {S1, S2,…, SK} is generated.
4. Decision step. If S′ = S or the maximum number of K-means iterations I is reached, then output the generated clustering S′, cluster centers C and object weights w, and end the computation; otherwise go to Step 3.