R语言聚类分析

聚类分析有不少种, 效果好很差大概要根据数据特征来肯定。最多见的是kmeans法聚类html

> setwd("D:\\R_test")
> data_in <- read.delim("tmp_result.txt", header=T)
> fit <- kmeans(data_in, 3)
> library(cluster)
> clusplot(data_in, fit$cluster, color=T, shade=T, labels = 2, lines =0)

也能够用mclustwindows

> install.packages("mclust")
试开URL’http://cloud.r-project.org/bin/windows/contrib/2.14/mclust_4.0.zip'
Content type 'application/zip' length 2371233 bytes (2.3 Mb)
打开了URL
downloaded 2.3 Mb

程序包‘mclust’打开成功,MD5和检查也经过

下载的程序包在
        C:\Users\Administrator\AppData\Local\Temp\RtmpiIyw2o\downloaded_packages里
> fit <- Mclust(data_in)        
> summary(fit)
----------------------------------------------------
Gaussian finite mixture model fitted by EM algorithm 
----------------------------------------------------

Mclust XXX (elliposidal multivariate normal) model with 1 component:

 log.likelihood   n    df     BIC
        1616504 263 33410 3046843

Clustering table:
  1 
263 

> fit$  // 按下Tab键,有如下选项
fit$call           fit$modelName      fit$n              fit$d              fit$G              
fit$BIC            fit$bic            fit$loglik         fit$df             fit$parameters     
fit$classification fit$uncertainty

> plot(fit, what="classification")

// http://www.statmethods.net/advstats/cluster.html
相关文章
相关标签/搜索