您好,登錄后才能下訂單哦!
這篇文章主要介紹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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。