您好,登錄后才能下訂單哦!
這篇文章主要介紹MATLAB中聚類方法有幾種,文中介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!
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)重心法&標(biāo)準(zhǔn)歐氏距離
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)重心法&精度加權(quán)距離
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)最短距離法&基于主成分的標(biāo)準(zhǔn)歐式距離
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)平均法&標(biāo)準(zhǔn)歐式距離
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)權(quán)重法&標(biāo)準(zhǔn)歐式距離
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)重心法&標(biāo)準(zhǔn)化數(shù)據(jù)的的歐式距離
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)平均法&相似系數(shù)
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)最短距離法&基于主成分的標(biāo)準(zhǔn)歐式距離
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中聚類方法有幾種”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。