首页 文章

模糊c均值聚类

提问于
浏览
0
[centers,U,obj_fcn] = fcm(sod,5);
expo = 2.0;                             
max_iter = 100;                         
min_impro = 1e-6; 
figure,
scatter3(sod1(:,1),sod1(:,2),sod1(:,3),'ob')
hold on
scatter3(sod2(:,1),sod2(:,2),sod2(:,3),'oc')
scatter3(sod3(:,1),sod3(:,2),sod3(:,3),'og')
scatter3(sod4(:,1),sod4(:,2),sod4(:,3),'or')
scatter3(sod5(:,1),sod5(:,2),sod5(:,3),'om')
scatter3(centers(1,1),centers(1,2),centers(1,3),'xb','Sizedata',100,'LineWidth',3)
scatter3(centers(2,1),centers(2,2),centers(2,3),'xc','Sizedata',100,'LineWidth',3)
scatter3(centers(3,1),centers(3,2),centers(3,3),'xg','Sizedata',100,'LineWidth',3)
scatter3(centers(4,1),centers(4,2),centers(4,3),'xr','Sizedata',100,'LineWidth',3)
scatter3(centers(5,1),centers(5,2),centers(5,3),'xm','Sizedata',100,'LineWidth',3)
legend('P.1','P.2','P.3','P.4','P.5','P.1 center','P.2 center','P.3 center','P.4 center','P.5 center')
hold off
title 'Fuzzy C Mean';
view(3), axis vis3d, box on, rotate3d on
xlim ([0 10])
ylim ([0 10])
zlim ([0 10])
xlabel('Severity')
ylabel('Occurrence')
zlabel('Detect')

每次运行代码时,模糊c均值聚类的质心都不同 . 有什么不对吗?

enter image description here

Sod1到sod5是草皮数据的一部分,我将它们提取成部分

1 回答

  • 0

    fcm文档:

    fcm在群集期间执行以下步骤:1随机初始化群集成员资格值μij .

    由于优化问题是随机初始化的,并且可能会陷入局部最小值,因此每次都会发现不同的结果 .

    使用k均值和模糊c均值(这些非常相似)的一种方法是多次运行聚类并查看是否比其他中心更频繁地找到任何一组中心 . 这可能是当地最小的最稳定的 .

    如果您需要确定性方法,请滚动您自己的函数版本并为其提供确定性初始化 . 内置方法似乎没有此选项 . 虽然也许您可以在调用函数之前将随机数生成器设置为固定值的种子?一个简单的

    rng(0);
    [centers,U,obj_fcn] = fcm(sod,5);
    

    会做到这一点 . See the documentation .

相关问题