r:根据多数规则从NbClust()中检索最佳簇数,而不查看控制台

时间:2016-05-18 05:54:44

标签: r cluster-analysis hierarchical-clustering

我在一维数据上运行NbClust()

nc <- NbClust(df, distance="euclidean", min.nc=2, max.nc=10, method="complete")

并在我的控制台上获得以下输出:

[1] "Frey index : No clustering structure in this data set"
*** : The Hubert index is a graphical method of determining the number of clusters.
                In the plot of Hubert index, we seek a significant knee that corresponds to a 
                significant increase of the value of the measure i.e the significant peak in Hubert
                index second differences plot. 

*** : The D index is a graphical method of determining the number of clusters. 
                In the plot of D index, we seek a significant knee (the significant peak in Dindex
                second differences plot) that corresponds to a significant increase of the value of
                the measure. 

******************************************************************* 
* Among all indices:                                                
* 1 proposed 4 as the best number of clusters 
* 1 proposed 8 as the best number of clusters 
* 2 proposed 9 as the best number of clusters 
* 2 proposed 10 as the best number of clusters 

                   ***** Conclusion *****                            

* According to the majority rule, the best number of clusters is  9 


*******************************************************************

如何检索值&#34; 9&#34; (在上面的输出的最后一行)没有看它?

谢谢!

规范化数据如下所示:

df <- structure(list(V1 = c(-0.142196220923589, 4.3271395706369, 5.00420146139183, 
    -0.292948282536991, -0.292948282536991, -0.292948282536991, -0.191455118249021, 
    -0.292948282536991, -0.292948282536991, -0.292948282536991, 1.04365387777657, 
    0.150712390018241, -0.275757257967042, -0.292948282536991, -0.292948282536991, 
    0.00392748792098075, -0.0235120320656692, 0.150712390018241, 
    -0.292948282536991, 0.22278245456149, -0.292948282536991, -0.292948282536991, 
    0.0888908208916921, -0.292948282536991, -0.269806518692829, -0.292948282536991, 
    -0.292948282536991, -0.292948282536991, -0.292948282536991, -0.287328139889123, 
    -0.030454561218918, 0.25980927671215, -0.292948282536991, -0.223192394378158, 
    -0.292948282536991, -0.292948282536991, -0.292948282536991, 0.0657490570475295, 
    -0.292948282536991, -0.292948282536991, -0.292948282536991, -0.215258075345874, 
    0.0862460478809306, 0.0862460478809306, -0.522051744594201, -0.518084585078059, 
    -0.496595804365622, -0.522051744594201, -0.516431601946333, -0.518084585078059
    )), .Names = "V1", row.names = c(NA, -50L), class = "data.frame")

1 个答案:

答案 0 :(得分:2)

感谢zx8754,我发现以下内容从控制台输出中产生了所需的值

length(unique(nc$Best.partition))
相关问题