How to compute weighted probability for nitialization of centers using kmeans++? How kmeans++ is differ from kmeans?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!