温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

R语言聚类分析

发布时间:2020-06-24 21:24:12 来源:网络 阅读:1618 作者:qizok 栏目:编程语言

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

> 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)

也可以用mclust

> 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


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI