1. 程式人生 > >聚類樹的切割方法

聚類樹的切割方法

文章目錄

  1. 聚類樹的切割方法在R語言中的實現
    在這裡插入圖片描述

  2. 靜態切割比較簡單,現在主要談動態切割
    ##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