确定基于序列(距离)的群集的理想簇数
-
21-12-2019 - |
题
我已经写了这些函数以用于群集基于序列的数据:
library(TraMineR)
library(cluster)
clustering <- function(data){
data <- seqdef(data, left = "DEL", gaps = "DEL", right = "DEL")
couts <- seqsubm(data, method = "CONSTANT")
data.om <- seqdist(data, method = "OM", indel = 3, sm = couts)
clusterward <- agnes(data.om, diss = TRUE, method = "ward")
(clusterward)
}
rc <- clustering(rubinius_sequences)
cluster_cut <- function(data, clusterward, n_clusters, name_clusters){
data <- seqdef(data, left = "DEL", gaps = "DEL", right = "DEL")
cluster4 <- cutree(clusterward, k = n_clusters)
cluster4 <- factor(cluster4, labels = c("Type 1", "Type 2", "Type 3", "Type 4"))
(data[cluster4==name_clusters,])
}
rc1 <- cluster_cut(project_sequences, rc, 4, "Type 1")
.
但是,这里有任意分配的簇数。有些方法可以表明,通过一定数量的簇捕获的方差量(或一些类似的测量)开始达到一定数量的群集递增的递减点?我想象类似于a scree plot因子分析。 解决方案
library(WeightedCluster)
(agnesRange <- wcKMedRange(rubinius.dist, 2:10))
plot(agnesRange, stat = c("ASW", "HG", "PBC"), lwd = 5)
.
这将为查找理想数量的群集提供多个指标,以及图表。可以在此处找到有关索引的更多信息(在群集质量下): http://mephisto.unige.ch/weightedcluster/
不隶属于 StackOverflow