资源描述:
《实验报告材料 聚类分析报告.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、实验报告聚类分析实验原理:K均值聚类、中心点聚类、系统聚类和EM算法聚类分析技术。实验题目:用鸢尾花的数据集,进行聚类挖掘分析。实验要求:探索鸢尾花数据的基本特征,利用不同的聚类挖掘方法,获得基本结论并简明解释。实验题目--分析报告:data(iris)>rm(list=ls())>gc()used(Mb)gctrigger(Mb)maxused(Mb)Ncells43173023.192971849.760759132.5Vcells7876056.1838860864.0159240312.2>data(ir
2、is)>data<-iris>head(data)Sepal.LengthSepal.WidthPetal.LengthPetal.WidthSpecies15.13.51.40.2setosa24.93.01.40.2setosa34.73.21.30.2setosa44.63.11.50.2setosa55.03.61.40.2setosa65.43.91.70.4setosa#Kmean聚类分析>newiris<-iris>newiris$Species<-NULL>(kc<-kmeans(newiris,
3、3))K-meansclusteringwith3clustersofsizes62,50,38Clustermeans:Sepal.LengthSepal.WidthPetal.LengthPetal.Width15.9016132.7483874.3935481.43387125.0060003.4280001.4620000.24600036.8500003.0736845.7421052.071053Clusteringvector:[1]222222222222222222222222222222222
4、2222222[41]2222222222113111111111111111111111111311[81]1111111111111111111131333313333331133331[121]313133113333313333133313331331Withinclustersumofsquaresbycluster:[1]39.8209715.1510023.87947(between_SS/total_SS=88.4%)Availablecomponents:[1]"cluster""centers
5、""totss""withinss""tot.withinss"[6]"betweenss""size""iter""ifault">table(iris$Species,kc$cluster)123setosa0500versicolor4802virginica14036>plot(newiris[c("Sepal.Length","Sepal.Width")],col=kc$cluster)>points(kc$centers[,c("Sepal.Length","Sepal.Width")],col=1:
6、3,pch=8,cex=2)#K-Mediods进行聚类分析>install.packages("cluster")>library(cluster)>iris.pam<-pam(iris,3)>table(iris$Species,iris.pam$clustering)123setosa5000versicolor0347virginica0491>layout(matrix(c(1,2),1,2))>plot(iris.pam)>layout(matrix(1))#hc>iris.hc<-hclust(di
7、st(iris[,1:4]))>plot(iris.hc,hang=-1)>plclust(iris.hc,labels=FALSE,hang=-1)>re<-rect.hclust(iris.hc,k=3)>iris.id<-cutree(iris.hc,3)#利用剪枝函数cutree()参数h控制输出height=18时的系谱类别>sapply(unique(iris.id),+function(g)iris$Species[iris.id==g])[[1]][1]setosasetosasetosaseto
8、sasetosasetosasetosasetosasetosasetosasetosa[12]setosasetosasetosasetosasetosasetosasetosasetosasetosasetosasetosa[23]setosasetosasetosasetosasetosasetosasetosasetosasetosasetosasetosa[34