試驗(yàn)報(bào)告聚類分析_第1頁(yè)
試驗(yàn)報(bào)告聚類分析_第2頁(yè)
試驗(yàn)報(bào)告聚類分析_第3頁(yè)
試驗(yàn)報(bào)告聚類分析_第4頁(yè)
試驗(yàn)報(bào)告聚類分析_第5頁(yè)
已閱讀5頁(yè),還剩27頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、實(shí)驗(yàn)報(bào)告聚類分析實(shí)驗(yàn)原理:K均值聚類、中心點(diǎn)聚類、系統(tǒng)聚類和EM算法聚類分析技術(shù)。實(shí)驗(yàn)題目:用鶯尾花的數(shù)據(jù)集,進(jìn)行聚類挖掘分析。實(shí)驗(yàn)要求:探索鶯尾花數(shù)據(jù)的基本特征,利用不同的聚類挖掘方法,獲得基本 結(jié)論并簡(jiǎn)明解釋。實(shí)驗(yàn)題目-分析報(bào)告:data(iris)> rm(list=ls()> gc()used (Mb) gc trigger (Mb) max used (Mb)Neelis 431730929718 607591Vcells 7876058388608 1592403> data(iris)> d at a v-iris> head(data)Specie

2、s1setosa2setosa3setosa4setosa5setosa6setosa#Kmear聚類分析> n ewiris v iris> n ewiris$Species v NULL> (kc v kmea ns(n ewiris, 3)K-mea ns clusteri ng with 3 clusters of sizes 62, 50, 38Cluster mea ns:Clusteri ng vector:1222222222222222222222222222222222222241 2222222222113111111111111111111111111

3、3 1 1 81 11111111111111111111313333133333311333 3 1 121 3 1 3 1 33 1 13333313333133313331331With in cluster sum of squares by cluster:1(between_SS / total_SS = %)Available comp onen ts:1 'cluster1' "centers""totss""withinss(6)”betweenss size”“iter”Fault”> table(ir

4、is$Species, kc$cluster)1 23setosa 0 50 0versicolor 48 0 2virgi nica 14 0 36> plot( newirisc(HM, col = kc$cluster)> poi nts(kc$ce nters,c(nn,col = 1:3, pch = 8, cex=2)o o0 O <Xi ,oQ O QO O O0 2OGiO0 0 oO Q OO O 0goo - e> cooooo o455055 fio 057075 8DSepal.Length#K-Mediods進(jìn)行聚類分析> ("

5、cluster")> library(cluster)> <-pam(iris,3) > table(iris$Species,$clusteri ng)setosa 50 0 0versicolor 0 3 47virgi nica 0 49 1> layout(matrix(c(1,2),1,2)> plotclusplot(pam(x = iris, k = 3)Tn®閱 two componerts explain &&.02 % of meSilhouette plot of pam(x = iris, k =

6、3) nwl50 3 AJSteis Cjj. iAaveAcj s;I. 50 O.6C2 52 0.410.0 0.2 0.4 D.S 0.6 1.0SilfKiucle widdl SiHowHie widWi - 0.57> layout(matrix(1)2#hc> <-hclust( dist(iris,1:4)> plot(, hang = -1)> plclust(, labels = FALSE, ha ng => re <,k = 3)> <-cutree, 3)9寸CM1o iih *l 1R IWk ftdist(i

7、ris: 1:4 hclust 仁”complete”)#利用剪枝函數(shù)cutree()參數(shù)h控制輸出height=18時(shí)的系譜類別> sapply (uniq ue,+ fun ctio n(g)iris$Species=g)1 setosa setosa setosa setosa setosa setosa setosa setosa setosa setosa setosa12 setosa setosa setosa setosa setosa setosa setosa setosa setosa setosa setosa23 setosa setosa setosa set

8、osa setosa setosa setosa setosa setosa setosa setosa34 setosa setosa setosa setosa setosa setosa setosa setosa setosa setosa setosa45 setosa setosa setosa setosa setosa setosaLevels: setosa versicolor virginica1 versicolor versicolor versicolor versicolor versicolor versicolor versicolor8 versicolor

9、 versicolor versicolor versicolor versicolor versicolor versicolor 15 versicolor versicolor versicolor versicolor versicolor versicolor versicolor22 versicolor versicolor virginica virginica virginica virginica virginica29 virginicavirginica virginica virginica virginicavirgi nica virgi nica36 virgi

10、nicavirginica virginica virginica virginicavirgi nica virgi nica43 virginicavirginica virginica virginica virginicavirgi nica virgi nica50 virginicavirginica virginica virginica virginicavirgi nica virgi nica57 virginicavirginica virginica virginica virginicavirgi nica virgi nica64 virginicavirginic

11、a virginica virginica virginicavirgi nica virgi nica71 virginica virginicaLevels: setosa versicolor virginica31 versicolor versicolor versicolor versicolor versicolor versicolor versicolor8 versicolor versicolor versicolor versicolor versicolor versicolor versicolor15 versicolor versicolor versicolo

12、r versicolor versicolor versicolor versicolor22 versicolor versicolor versicolor versicolor versicolor versicolor virginicaLevels: setosa versicolor virginica> plot> ,k=4,border-light grey”)# 用淺灰色矩形框出4分類聚類結(jié)果> ,k=3,border Jdark grey")#用淺灰色矩形框出3分類聚類結(jié)果> ,k=7)which=c(2,6),border=',d

13、ark grey")Cluiter Dendrogrtiim# DBSCAN基于密度的聚類> (”fpc”)> library(fpc)> ds 仁 dbsca n(iris,1:4,eps=1,Mi nPts=5)#半徑參數(shù)為 1、密度閾值為 5> ds1 dbsca n Pts=150 Mi nPts=5 eps=11 2 border 0 1seed 50 99total 50 100> ds2=dbsca n(iris,1:4,eps=4,Mi nPts=5)> ds3=dbsca n(iris,1:4,eps=4,Mi nPts=2)&g

14、t; ds4=dbsca n(iris,1:4,eps=8,Mi nPts=2)> par(mfcol=c(2,2)> plot(ds1 ,iris,1:4,main='1: MinPts=5 eps=1 ”)> plot(ds3,iris,1:4,main='3: MinPts=2 eps=4n)> plot(ds2,iris,1:4,main= *2: MinPts=5 eps=4n)> plot(ds4,iris,1:4,main=H4: MinPts=2 eps=8H)4: MinPts=2 eps=82.G3.G MSepal Lengt

15、h0 5 IF 2 5T7seed 150Petal. Length4恥金 4Petal Width4.55.5657512 3 4 5 6 7> d=dist(iris,1:4)#計(jì)算數(shù)據(jù)集的距離矩陣d> max(d);min(d)#計(jì)算數(shù)據(jù)集樣本的距離的最值10> (“ggpiot?')> Iibrary(ggplot2)> in terval=cut_i nterval(d,30)> table(i nterval)interval0,,88585876891831688,】,】,543369379339335406,4584594654804

16、68505,349385321291187138J,,97927850184> (table(i nterval),4> for(i in 3:5)+ for(j in 1:10)+ ds=dbsca n(iris,1:4,eps=i,M in Pts=j)+ prin t(ds)+ +dbscan Pts=150 Min Pts=1 eps=31seed 150total 150dbscan Pts=150 Min Pts=2 eps=31seed 150total 150dbscan Pts=150 Min Pts=3 eps=31seed 150total 150 dbsca

17、n Pts=150 MinPts=4 eps=31seed 150total 150 dbscan Pts=150 Min Pts=5 eps=31seed 150total 150dbscan Pts=150 Min Pts=6 eps=31seed 150total 150dbscan Pts=150 Min Pts=7 eps=31seed 150total 150dbscan Pts=150 Min Pts=8 eps=31seed 150total 150dbscan Pts=150 Min Pts=9 eps=31seed 150total 150dbscan Pts=150 Mi

18、 nPts=10 eps=31seed 150total 150dbscan Pts=150 Min Pts=1 eps=41total 150dbscan Pts=150 MinPts=2 eps=41seed 150total 150dbscan Pts=150 Min Pts=3 eps=41seed 150total 150dbscan Pts=150 MinPts=4 eps=41seed 150total 150dbscan Pts=150 MinPts=5 eps=41seed 150total 150dbscan Pts=150 Min Pts=6 eps=41seed 150

19、total 150dbscan Pts=150 MinPts=7 eps=41seed 150total 150dbscan Pts=150 Min Pts=8 eps=41seed 150total 150dbscan Pts=150 Min Pts=9 eps=41seed 150total 150dbscan Pts=150 Mi nPts=10 eps=41seed 150total 150 dbscan Pts=150 MinPts=1 eps=51seed 150total 150dbscan Pts=150 Mi nPts=2 eps=51seed 150total 150dbs

20、can Pts=150 Mi nPts=3 eps=51seed 150total 150dbsca n Pts=150 Mi nPts=4 eps=51seed 150total 150dbscan Pts=150 Mi nPts=5 eps=51seed 150total 150dbscan Pts=150 Mi nPts=6 eps=51seed 150total 150dbsca n Pts=150 Mi nPts=7 eps=51seed 150total 150dbscan Pts=150 Mi nPts=8 eps=51total 150dbscan Pts=150 Min Pt

21、s=9 eps=51seed 150total 150dbscan Pts=150 Mi nPts=10 eps=51seed 150total 150#30次dbscan的聚類結(jié)果> ds5=dbsca n(iris,1:4,eps=3,Mi nPts=2)> ds6=dbsca n(iris,1:4,eps=4,Mi nPts=5)> ds7=dbsca n(iris,1:4,eps=5,Mi nPts=9)> par(mfcol=c(1,3)> plot(ds5,iris,1:4,main="1: MinPts=2 eps=3")>

22、 plot(ds6,iris,1:4,main=',3: MinPts=5 eps=4")> plot(ds7,iris,1:4,main=H2: MinPts=9 eps=5")2: MinPts=9 eps=52.G3.G "0 5 IE 2 5# EM期望最大化聚類> (“mclust”)> library(mclust)> fit_EM=Mclust(iris,1:4)fitting .|=|1Oo%> summary(fit_EM)Gaussian finite mixture model fitted by EM

23、algorithmMclust VEV (ellipsoidal, equal shape) model with 2 comp onents: n df BIC ICL150 26Clusteri ng table:1 250 100> summary(fit_EM,parameters 二 TRUE)Gaussian finite mixture model fitted by EM algorithmMclust VEV (ellipsoidal, equal shape) model with 2 comp onents: n dfBIC ICL150 26Clusteri ng

24、 table:1 250 100Mixing probabilities:1 2Mea ns:川,2Varia nces:,10. 0.0. 0.,£0. 0.0. 0.0.0.> plot(fit_EM)#對(duì)EM聚類結(jié)果作圖Model-based clusteri ng plots:1: BIC2: classificati on3: un certa inty4: den sitySelectio n:(下面顯示選項(xiàng))#選1Number of camponenla#選2Sep al.Le ngth1 1OD 嚅 C qfla1 1 19 B加jrf11t nD口Sepal.

25、Width”CD才禎瀛口*1閹日手PEted 丄 ength嚴(yán)1*sI才畀Petal Width25 3.0 3.5 A.Q0.5 1.0 1.5 2.0 254555657.512 34567#選32.0 2.5 3.0 3.5 4.CSepal Length 1 .ABO ai .ISrS7 JL.電< / .Sepal.Width9 寥 # 1、盼 訊巧 1 1 ' 八.:尹' PetaLL ength",t b# I.twh * .宓: 歹 Petal WidthyiN令七,兀A<r)26#選42.0 2.5 3.0 3.5 4.QQ.B 1.0-

26、 1.5 20 2 54 5556.57.51234567Selectio n: 0> iris_BIC=mclustBIC(iris,1:4)fitting .|=|100%> iris_BICsum=summary(iris_BIC,data=iris,1:4)> iris_BICsum #獲取數(shù)1據(jù)集iris在各模型和類別數(shù)下的BIC值Best BIC values:VEV,2 VEV,3 VW,2BICBIC diffClassification table for model (VEV,2):1 250 100> iris_BICBayesian Inform

27、ation Criterion (BIC):Ell VII EEI VEI EVI VVIEEE123456789123456789TopEVE VEE WE EEV VEV EVVVWNA NANANANA3 models based on the BIC criterion:VEV,2 VEV,3 VW,2> par(mfcol=c(1,1)> plot(iris_BIC5G=1:7,col=”yellow”)EVVEVEVu 二二 二/HJVCIVLUVLU123456Number of comp on ents> mclust2Dplot(iris,1:2,+classificati on=iris_BICsum$classificati on

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論