How to compute weighted probability for nitialization of centers using kmeans++? How kmeans++ is differ from kmeans?
1 view (last 30 days)
Show older comments
load dara1.dat;
nc=4;
niters=100;
[r,col]=size(data1);
p=randperm(r);
p=p(1:nc);
c=data1(p,:);
id=eye(nc);
for n=1:niters
old_c=c;
d2=dist2(data1,c);
%d2=d2';
[minval,indx]=min(d2,[],2);
post=id(indx,:);
num_points=sum(post,1);
for jj=1:nc
if num_points(jj) > 0
c(jj,:)=sum(data1(find(post(:,jj)),:),1)/num_points(jj);
end
end
e=sum(minval);
if n>1
if max(max(abs(c-old_c))) <0.00001 && abs(old_e-e) <0.00001
options(8)=e;
return;
end
end
old_e=e
en
This is simple kmeans algorithm for clustering. But I want to applied kmeans++ algorithm instead of simple kmeans, where I have to initialize the centers by suing a weighted probability distribution where a point x is chosen with probability proportional to d2. I am not understanding that how to initialize the center using kmeans++ algorithm: please help me on this.
0 Comments
Answers (0)
See Also
Categories
Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!