我想使用clusgap来估计给定数据集所需的簇数。问题是我无法从clusgap获取k值,尽管建议将此库用于间隙统计。
以下是我如何使用clusgap:
hcluster = clusGap(dataMatrix, FUN = hcut, nstart = 25, K.max = 100, B = 50)
kcluster = clusGap(dataMatrix, kmeans, K.max=100, B=50)
以下是clusgaps输出,我可以看到建议的群集数是11,但我无法动态访问此数字。
Clustering Gap statistic ["clusGap"] from call:
clusGap(x = dataMatrix, FUNcluster = hcut, K.max = 100, B = 50, nstart = 25)
B=50 simulated reference sets, k = 1..100; spaceH0="scaledPCA"
--> Number of clusters (method 'firstSEmax', SE.factor=1): 11
logW E.logW gap SE.sim
[1,] 8.995981 10.000102 1.004121 0.004184801
[2,] 8.694404 9.716407 1.022003 0.017857009
[3,] 8.538334 9.616808 1.078473 0.008792356
[4,] 8.466726 9.574631 1.107905 0.005905742
[5,] 8.363253 9.550745 1.187492 0.004978537
[6,] 8.303085 9.531952 1.228867 0.004084501
[7,] 8.270890 9.516404 1.245514 0.004118244
[8,] 8.241259 9.502743 1.261484 0.004018474
[9,] 8.220926 9.490543 1.269617 0.003874152
任何帮助将非常感激。
如果有人碰到这个,我就是这样做的:
hcluster = clusGap(dataMatrix, FUN = hcut, nstart = 25, K.max = 100, B = 50)
k <- maxSE(hcluster$Tab[, "gap"], hcluster$Tab[, "SE.sim"], method="Tibs2001SEmax")