聚類樹的切割方法
阿新 • • 發佈:2018-11-08
文章目錄
-
聚類樹的切割方法在R語言中的實現
-
靜態切割比較簡單,現在主要談動態切割
##dynamicTreeCut 函式包的使用
這個包主要是探測層次聚類中的clusters
2.1 執行動態切割比較重要的包(“cutreeDynamic”)
input :
clutering tree
dissimilarity matrix that was used to produce the tree
Most important options
deepSplit(0,1,2,3,4):controls how finely clusters will be split
pamStage Only used for method “hybrid”. If TRUE, the second (PAM-like) stage will be performed.
預設是執行進行PAMstage ,允許使用者分配更多的outlying onbjects 資料到 clusters中
2.2 附帶一個好玩兒的功能:
merge2Clusters
merge2Clusters(labels, mainClusterLabel, minorClusterLabel)
labels :a vector or factor giving the cluster labels
mainClusterLabel :是融合之後會留下的標籤
主要用途:將兩個聚類標籤融合成一個聚類標籤(這是什麼鬼)
舉個栗子:
#Works with character labels:
options(stringsAsFactors = FALSE);
install.packages("dynamicTreeCut")
library(dynamicTreeCut)
labels = c(rep("grey", 5), rep("blue", 2), rep("red", 3))
merge2Clusters(labels, "blue", "red")
就可以把labels裡面的blue標籤程式設計red