您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这篇文章主要介绍MATLAB中聚类方法有几种,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
X=[16.21492 2000 -8.2 6.2; 15.7 970 2209 -20.6 1.9; 16.3 1260 2085 -17.3 2.8; 17.2 14221726 -9.5 4.6; 18.8 1874 1709 -4.9 8.0; 17.9 1698 1848 -4.5 7.5; 16.3 976 1239-4.6 5.6]; D=pdist(X,'euclid'); M=squareform(D); Z=linkage(D,'complete'); H=dendrogram(Z); xlabel('City'); ylabel('Scale'); C=cophenet(Z,D); T=cluster(Z,3);
(2) 最短距离法
X=[16.21492 2000 -8.2 6.2; 15.7 970 2209 -20.6 1.9; 16.3 1260 2085 -17.3 2.8; 17.2 14221726 -9.5 4.6; 18.8 1874 1709 -4.9 8.0; 17.9 1698 1848 -4.5 7.5; 16.3 976 1239-4.6 5.6]; D=pdist(X,'euclid'); M=squareform(D); Z=linkage(D,'single') ;H=dendrogram(Z); xlabel('City'); ylabel('Scale'); C=cophenet(Z,D); T=cluster(Z,'cutoff',0.8);
(3)综合聚类子程序
X=[16.21492 2000 -8.2 6.2; 15.7 970 2209 -20.6 1.9; 16.3 1260 2085 -17.3 2.8; 17.2 14221726 -9.5 4.6; 18.8 1874 1709 -4.9 8.0; 17.9 1698 1848 -4.5 7.5; 16.3 976 1239-4.6 5.6]; T=clusterdata(X,0.8); Re=find(T=5)
(4)重心法&标准欧氏距离
S=['福冈';'合肥';'武汉';'长沙';'桂林';'温州';'成都']; X=[16.21492 2000 -8.2 6.2; 15.7 970 2209 -20.6 1.9; 16.3 1260 2085 -17.3 2.8; 17.2 14221726 -9.5 4.6; 18.8 1874 1709 -4.9 8.0; 17.9 1698 1848 -4.5 7.5; 16.3 976 1239-4.6 5.6]; D=pdist(X,'seuclid'); M=squareform(D); Z=linkage(D,'centroid'); H=dendrogram(Z,'labels',S); xlabel('City'); ylabel('Scale'); C=cophenet(Z,D); T=cluster(Z,3);
(5)重心法&欧氏距离平方
S=['福冈';'合肥';'武汉';'长沙';'桂林';'温州';'成都']; X=[16.21492 2000 -8.2 6.2; 15.7 970 2209 -20.6 1.9; 16.3 1260 2085 -17.3 2.8; 17.2 14221726 -9.5 4.6; 18.8 1874 1709 -4.9 8.0; 17.9 1698 1848 -4.5 7.5; 16.3 976 1239-4.6 5.6]; D=pdist(X,'euclid'); D2=D.^2; M=squareform(D2); Z=linkage(D2,'centroid'); H=dendrogram(Z,'labels',S); xlabel('City'); ylabel('Scale'); C=cophenet(Z,D2); T=cluster(Z,3);
(6)重心法&精度加权距离
S=['福冈';'合肥';'武汉';'长沙';'桂林';'温州';'成都']; X=[16.21492 2000 -8.2 6.2; 15.7 970 2209 -20.6 1.9; 16.3 1260 2085 -17.3 2.8; 17.2 14221726 -9.5 4.6; 18.8 1874 1709 -4.9 8.0; 17.9 1698 1848 -4.5 7.5; 16.3 976 1239-4.6 5.6]; [n,m]=size(X); stdx=std(X); X2=X./stdx(ones(n,1),:); D=pdist(X2,'euclid'); M=squareform(D); Z=linkage(D,'centroid'); H=dendrogram(Z,'labels',S); xlabel('City'); ylabel('Scale'); C=cophenet(Z,D); T=cluster(Z,3);
(7)最短距离法&基于主成分的标准欧式距离
S=['福冈';'合肥';'武汉';'长沙';'桂林';'温州';'成都']; X=[16.21492 2000 -8.2 6.2; 15.7 970 2209 -20.6 1.9; 16.3 1260 2085 -17.3 2.8; 17.2 14221726 -9.5 4.6; 18.8 1874 1709 -4.9 8.0; 17.9 1698 1848 -4.5 7.5; 16.3 976 1239-4.6 5.6]; [E,score,eigen,T]=princomp(X); D=pdist(score,'seuclid'); M=squareform(D); Z=linkage(D,'single'); H=dendrogram(Z,'labels',S); xlabel('City'); ylabel('Scale'); C=cophenet(Z,D); T=cluster(Z,3);
(8)平均法&标准欧式距离
S=['福冈';'合肥';'武汉';'长沙';'桂林';'温州';'成都']; X=[16.21492 2000 -8.2 6.2; 15.7 970 2209 -20.6 1.9; 16.3 1260 2085 -17.3 2.8; 17.2 14221726 -9.5 4.6; 18.8 1874 1709 -4.9 8.0; 17.9 1698 1848 -4.5 7.5; 16.3 976 1239-4.6 5.6]; D=pdist(X,'seuclid'); M=squareform(D); Z=linkage(D,'average'); H=dendrogram(Z,'labels',S); xlabel('City'); ylabel('Scale'); C=cophenet(Z,D); T=cluster(Z,3);
(9)权重法&标准欧式距离
S=['福冈';'合肥';'武汉';'长沙';'桂林';'温州';'成都']; X=[16.21492 2000 -8.2 6.2; 15.7 970 2209 -20.6 1.9; 16.3 1260 2085 -17.3 2.8; 17.2 14221726 -9.5 4.6; 18.8 1874 1709 -4.9 8.0; 17.9 1698 1848 -4.5 7.5; 16.3 976 1239-4.6 5.6]; D=pdist(X,'seuclid'); M=squareform(D); Z=linkage(D,'weighted'); H=dendrogram(Z,'labels',S); xlabel('City'); ylabel('Scale'); C=cophenet(Z,D); T=cluster(Z,3);
(10)最短距离法&马氏距离
S=['福冈';'合肥';'武汉';'长沙';'桂林';'温州';'成都']; X=[16.21492 2000 -8.2 6.2; 15.7 970 2209 -20.6 1.9; 16.3 1260 2085 -17.3 2.8; 17.2 14221726 -9.5 4.6; 18.8 1874 1709 -4.9 8.0; 17.9 1698 1848 -4.5 7.5; 16.3 976 1239-4.6 5.6]; D=pdist(X,'mahal');M=squareform(D);Z=linkage(D,'single');H=dendrogram(Z,'labels',S);xlabel('City');ylabel('Scale');C=cophenet(Z,D);T=cluster(Z,3);
(11)重心法&标准化数据的的欧式距离
S=['福冈';'合肥';'武汉';'长沙';'桂林';'温州';'成都']; X=[16.21492 2000 -8.2 6.2; 15.7 970 2209 -20.6 1.9; 16.3 1260 2085 -17.3 2.8; 17.2 14221726 -9.5 4.6; 18.8 1874 1709 -4.9 8.0; 17.9 1698 1848 -4.5 7.5; 16.3 976 1239-4.6 5.6]; [n,m]=size(X); mv=mean(X); st=std(X); x=(X-mv(ones(n,1),:))./st(ones(n,1),:); D=pdist(X,'euclid'); M=squareform(D); Z=linkage(D,'centroid'); H=dendrogram(Z,'labels',S); xlabel('City'); ylabel('Scale'); C=cophenet(Z,D); T=cluster(Z,3);
(12)最长距离法&欧式距离
S=['福冈';'合肥';'武汉';'长沙';'桂林';'温州';'成都']; X=[16.21492 2000 -8.2 6.2; 15.7 970 2209 -20.6 1.9; 16.3 1260 2085 -17.3 2.8; 17.2 14221726 -9.5 4.6; 18.8 1874 1709 -4.9 8.0; 17.9 1698 1848 -4.5 7.5; 16.3 976 1239-4.6 5.6]; D=pdist(X,'euclid'); M=squareform(D); Z=linkage(D,'complete'); [H tPerm]=dendrogram(Z,'labels',S); xlabel('City'); ylabel('Scale'); C=cophenet(Z,D); T=cluster(Z,3);
(13)平均法&相似系数
S=['福冈';'合肥';'武汉';'长沙';'桂林';'温州';'成都']; X=[16.21492 2000 -8.2 6.2; 15.7 970 2209 -20.6 1.9; 16.3 1260 2085 -17.3 2.8; 17.2 14221726 -9.5 4.6; 18.8 1874 1709 -4.9 8.0; 17.9 1698 1848 -4.5 7.5; 16.3 976 1239-4.6 5.6]; D=pdist(X,'cosine'); M=squareform(D); Z=linkage(D,'centroid'); T=dendrogram(Z,'labels',S); xlabel('City'); ylabel('Scale'); C=cophenet(Z,D); T=cluster(Z,3);
(14)最短距离法&基于主成分的标准欧式距离
S=['福冈';'合肥';'武汉';'长沙';'桂林';'温州';'成都']; X=[16.21492 2000 -8.2 6.2; 15.7 970 2209 -20.6 1.9; 16.3 1260 2085 -17.3 2.8; 17.2 14221726 -9.5 4.6; 18.8 1874 1709 -4.9 8.0; 17.9 1698 1848 -4.5 7.5; 16.3 976 1239-4.6 5.6]; [E,score,eigen,T]=princomp(X); PCA=[score(:,1),score(:,2)]; D=pdist(PCA,'seuclid'); M=squareform(D); Z=linkage(D,'single'); H=dendrogram(Z,'labels',S); xlabel('City'); ylabel('Scale'); C=cophenet(Z,D); T=cluster(Z,3);
以上是“MATLAB中聚类方法有几种”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。