模糊C均值聚类

2017-01-16  by:CAE仿真在线  来源:互联网

自编程序,并与matlab toolbox中fcm结果互证

理解fcm运算过程

fuzzy c-means clustering
clear;
data = rand(100, 2);
cluster_n = 2;
data_n = size(data, 1);
max_iter =100;
min_impro = 1e-5;
obj_fcn = zeros(max_iter,1);
U = initfcm(cluster_n, data_n);

expo = 2;

for i =1:max_iter
for j =1:cluster_n
Ue = U(j,:).^expo;
center(j,:) = sum(bsxfun(@times,data,Ue'))/sum(Ue);
for k =1:data_n
dist(j,k)=sqrt(sum((data(k,:)-center(j,:)).^2));

end
end
obj_fcn(i) = sum(sum(U.^expo.*dist.^2));

for j=1:cluster_n
for k =1:data_n
U(j,k) = (dist(j,k))^(-2/(expo-1)) / sum(dist(:,k).^(-2/(expo-1)));
end
end

if i > 1
if abs(obj_fcn(i) - obj_fcn(i-1)) < min_impro, break; end,
end

end

iter_n = i; % Actual number of iterations
obj_fcn(iter_n+1:max_iter) = [];


[center1, U1, obj_fcn1] = fcm(data, cluster_n);

subplot(211)
plot(data(:,1), data(:,2),'o');
hold on;
maxU = max(U);
index1 = find(U(1,:) == maxU);
index2 = find(U(2,:) == maxU);
line(data(index1,1),data(index1,2),'marker','*','color','g');
line(data(index2,1),data(index2,2),'marker','*','color','r');
plot([center([1 2],1)],[center([1 2],2)],'*','color','k')
hold off;

subplot(212)
plot(data(:,1), data(:,2),'o');
hold on;
maxU = max(U1);
index1 = find(U1(1,:) == maxU);
index2 = find(U1(2,:) == maxU);
line(data(index1,1),data(index1,2),'marker','*','color','g');
line(data(index2,1),data(index2,2),'marker','*','color','r');
plot([center1([1 2],1)],[center1([1 2],2)],'*','color','k')
hold off;


模糊C均值聚类

















开放分享:优质有限元技术文章,助你自学成才

相关标签搜索:模糊C均值聚类 MatLab培训 MatLab培训课程 MatLab在线视频教程 MatLab技术学习教程 MatLab软件教程 MatLab资料下载 MatLab代做 MatLab基础知识 Fluent、CFX流体分析 HFSS电磁分析 Ansys培训 Abaqus培训 

编辑
在线报名:
  • 客服在线请直接联系我们的客服,您也可以通过下面的方式进行在线报名,我们会及时给您回复电话,谢谢!
验证码

全国服务热线

1358-032-9919

广州公司:
广州市环市中路306号金鹰大厦3800
电话:13580329919
          135-8032-9919
培训QQ咨询:点击咨询 点击咨询
项目QQ咨询:点击咨询
email:kf@1cae.com