FIND ME ON

GitHub

LinkedIn

K-Means Clustering

🌱

MachineLearning

Algorithm

Initialize kk prototypes wj=xp,Ā j∈{1,…,k},Ā p∈{1,…,P}w_j=x_{p}, \ j\in\{1,\ldots,k\}, \ p\in\{1,\ldots,P\}where we pick random points in the dataset (i.e.Ā k≤Pk\le P) to initialize each weight. Each cluster CjC_{j} is associated with prototype wjw_{j} while for each xpx_p in input set: put xpx_p in cluster with nearest prototype wjw_j for jj in range(kk): wj=1∣cJāˆ£āˆ‘xl∈cjxlw_j=\frac{1}{|c_{J}|}\sum\limits_{x_{l}\in c_{j}}x_{l} where cjc_{j} is the cluster size E=āˆ‘j=1kāˆ‘xl∈cj∣xlāˆ’wj∣2E=\sum\limits^{k}_{j=1}\sum\limits_{x_{l}\in c_{j}}|x_{l}-w_{j}|^2 if(EE not increasing): break