【问题标题】:Extracting gap statistic info to identify K for Kmeans clustering提取间隙统计信息以识别 Kmeans 聚类的 K
【发布时间】:2016-04-04 19:31:54
【问题描述】:

我正在查看“cluster”库,它具有“clusGap”函数来提取 Kmeans 聚类的簇数。

这是代码:

# Compute Gap statistic (http://web.stanford.edu/~hastie/Papers/gap.pdf)
computeGapStatistic() <- function(data) {
gap <<- clusGap(shift_len_avg_data, FUN = kmeans, K.max = 8, B = 3)
if (ENABLE_PLOTS) {
    plot(gap, main = "Gap statistic for the Nursing shift data")
}
print(gap)
return(gap)
}

当 'gap' 被打印出来时,这给了我以下输出:

    >   print(gap)
Clustering Gap statistic ["clusGap"].
B=3 simulated reference sets, k = 1..8
--> Number of clusters (method 'firstSEmax', SE.factor=1): 2
        logW   E.logW         gap      SE.sim
[1,] 8.702334 9.238385  0.53605067 0.007945542
[2,] 7.940133 8.544323  0.60418996 0.003790244
[3,] 7.772673 8.139836  0.36716303 0.005755805
[4,] 7.325798 7.849233  0.52343473 0.002732731
[5,] 7.233667 7.629954  0.39628748 0.003496058
[6,] 7.020220 7.439709  0.41948820 0.006451708
[7,] 6.707678 7.285907  0.57822872 0.002810682
[8,] 7.166932 7.150724 -0.01620749 0.004274151

这就是情节的样子:

问题:

如何从“gap”变量中提取聚类数? 'gap' 似乎是一个列表。从上面的描述中,它似乎找到了 2 个集群。

【问题讨论】:

  • 请注意,统计数据会随着数据规范化而发生很大变化,并且可能完全具有误导性。 可视化并评估您的结果!

标签: r cluster-analysis k-means


【解决方案1】:

这是我自己想出来的。这是我用的:with(gap,maxSE(Tab[,"gap"],Tab[,"SE.sim"]))

【讨论】:

    猜你喜欢
    • 2017-04-09
    • 2015-04-18
    • 2023-01-12
    • 2018-04-18
    • 2019-12-09
    • 2021-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多