代码之家  ›  专栏  ›  技术社区  ›  Jack Armstrong

从nbclust可视化结果

  •  0
  • Jack Armstrong  · 技术社区  · 6 年前

    演出时 NbClust 根据我的数据,我发现根据多数法则,5个簇被确定为最佳数。但是,我怎样才能找出这5个集群是由哪些索引产生的呢?

    另外,如何使用省略来绘制这个新数据和颜色/组?过去我用过 fviz_cluster facto 包装,但通常带有 kmeans 反对。我试着输入 nb 但这是一个列表,因此会导致一个错误。我知道我可以用最佳簇数绘制柱状图,但我不想绘制。

    以iris为例的可复制示例

    library("NbClust")
    data(iris)
    iris.scaled <- scale(iris[, -5])
    set.seed(123)
    res.nb <- NbClust(iris.scaled, distance = "euclidean",
                      min.nc = 2, max.nc = 10, 
                      method = "complete", index ="gap") 
    res.nb # print the results
    fviz_nbclust(res.nb) + theme_minimal()
    
    0 回复  |  直到 6 年前
        1
  •  1
  •   bbiasi    5 年前

    论据 index 应该是 all .但是,如果忽略填写这个参数,则可能会让包本身执行此操作。

    res.nb <- NbClust(iris.scaled, distance = "euclidean",
                      min.nc = 2, max.nc = 10, 
                      method = "complete")
    
    res.nb <- NbClust(iris.scaled, distance = "euclidean",
                      min.nc = 2, max.nc = 10, 
                      method = "complete", 
                      index ="all") 
    
    library(factoextra)
    fviz_nbclust(res.nb)
    

    enter image description here