setwd( D:\\R_test ) > data_in  fit  libra..."/>
溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

R語言聚類分析

發(fā)布時間:2020-06-24 21:24:12 來源:網(wǎng)絡(luò) 閱讀:1628 作者:qizok 欄目:編程語言

聚類分析有很多種, 效果好不好大概要根據(jù)數(shù)據(jù)特征來確定。最常見的是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問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI