2014-02-26 5 views
3

는 I 클러스터링 시퀀스 기반의 데이터에 대한 이러한 함수를 작성한 :결정 이상적인 번호 - 기반 클러스터링

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

그러나, 여기서 클러스터의 개수는 임의로 할당된다. 특정 수의 클러스터에 의해 포착 된 분산 (또는 비슷한 측정)의 양이 특정 수의 클러스터에서 수익을 감소시키는 지점에 도달하기 시작한다는 것을 보여줄 수있는 방법이 있습니까? 나는 scree plot in factor analysis과 비슷한 것을 상상하고 있습니다.

답변

2
library(WeightedCluster) 
(agnesRange <- wcKMedRange(rubinius.dist, 2:10)) 
plot(agnesRange, stat = c("ASW", "HG", "PBC"), lwd = 5) 

이것은 그래프뿐만 아니라 이상적인 클러스터 수를 찾기위한 여러 인덱스를 제공합니다. 색인에 대한 자세한 내용은 여기 (클러스터 품질 기준)에서 확인할 수 있습니다. http://mephisto.unige.ch/weightedcluster/

관련 문제