2016-03-25 9 views
1

私はclValidを使って階層的クラスタリングの良さを検証しています。以下は私のコードです。クラスタリングは常に、要素の70%を含む1つのノイズの多いクラスタをもたらし、したがって、ノイズの多いクラスタ内の要素を再帰的にクラスタリングする。私はclValidを(実行)以上で私の最高のシルエット値を与えるクラスタ数を(選択する必要があり、各繰り返しでR:clValidオブジェクトのsummary()から値を抽出する

Clustering Methods: 
hierarchical 

Cluster sizes: 
2 3 4 5 6 7 8 9 10 

Validation Measures: 
           2  3  4  5  6  7  8  9  10 

hierarchical Connectivity 3.8738 3.8738 8.2563 10.9452 16.0286 18.6452 20.6452 22.6452 24.6452 
      Dunn   4.0949 0.8810 0.6569 0.8694 0.8808 1.0416 1.0230 1.0262 1.3724 
      Silhouette  0.9592 0.9879 0.9785 0.9751 0.9727 0.9729 0.9727 0.9726 0.9725 

Optimal Scores: 

      Score Method  Clusters 
Connectivity 3.8738 hierarchical 2  
Dunn   4.0949 hierarchical 2  
Silhouette 0.9879 hierarchical 3 

:要約の

intern <- clValid(primaryDataSource, 2:10,clMethods = c("Hierarchical"), 
        validation="internal", maxitems = 2200) 
summary(intern) 

出力(インターン)例3)です。再帰的クラスタリングのアプローチを自動化しようとしています。したがって、シルエット値が最も高いクラスターの数を選択することを検討しています。あなたはその情報の抽出に私を助けてくれますか?ありがとうございました。

P.S:結果をデータフレームまたはテーブルに変換しようとしました。しかし、それは動作しませんでした。

更新:STRを使用した後()

> str(intern) 

Formal class 'clValid' [package "clValid"] with 14 slots 
    [email protected] clusterObjs:List of 1 
    .. ..$ hierarchical:List of 7 
    .. .. ..$ merge  : int [1:2173, 1:2] -1673 -714 -1121 -1688 -1876 -1123 -1689 -1228 -429 -535 ... 
    .. .. ..$ height  : num [1:2173] 0 0.001 0.001 0.001 0.001 ... 
    .. .. ..$ order  : int [1:2174] 2165 2166 1950 1951 1954 1955 1577 1565 1564 1576 ... 
    .. .. ..$ labels  : chr [1:2174] "out_M_aacald_c_boundary" "out_M_12ppd_DASH_R_e_boundary" "out_M_12ppd_DASH_S_e_boundary" "in_M_14glucan_e_boundary" ... 
    .. .. ..$ method  : chr "average" 
    .. .. ..$ call  : language hclust(d = Dist, method = method) 
    .. .. ..$ dist.method: chr "euclidean" 
    .. .. ..- attr(*, "class")= chr "hclust" 
    [email protected] measures : num [1:3, 1:9, 1] 3.874 4.095 0.959 3.874 0.881 ... 
    .. ..- attr(*, "dimnames")=List of 3 
    .. .. ..$ : chr [1:3] "Connectivity" "Dunn" "Silhouette" 
    .. .. ..$ : chr [1:9] "2" "3" "4" "5" ... 
    .. .. ..$ : chr "hierarchical" 
    [email protected] measNames : chr [1:3] "Connectivity" "Dunn" "Silhouette" 
    [email protected] clMethods : chr "hierarchical" 
    [email protected] labels  : chr [1:2174] "out_M_aacald_c_boundary" "out_M_12ppd_DASH_R_e_boundary" "out_M_12ppd_DASH_S_e_boundary" "in_M_14glucan_e_boundary" ... 
    [email protected] nClust  : num [1:9] 2 3 4 5 6 7 8 9 10 
    [email protected] validation : chr "internal" 
    [email protected] metric  : chr "euclidean" 
    [email protected] method  : chr "average" 
    [email protected] neighbSize : num 10 
    [email protected] annotation : NULL 
    [email protected] GOcategory : chr "all" 
    [email protected] goTermFreq : num 0.05 
    [email protected] call  : language clValid(obj = primaryDataSource, nClust = 2:10, clMethods = c("Hierarchical"), validation = "internal",  maxitems = 2200) 

は、私は以下の結果を得た>[email protected]を実行する際の重要な部分は、

@ measures : num [1:3, 1:9, 1] 3.874 4.095 0.959 3.874 0.881 ... 
     .. ..- attr(*, "dimnames")=List of 3 
     .. .. ..$ : chr [1:3] "Connectivity" "Dunn" "Silhouette" 
     .. .. ..$ : chr [1:9] "2" "3" "4" "5" ... 
     .. .. ..$ : chr "hierarchical" 

だと思います。

     2   3   4   5   6   7   8   9 
Connectivity 3.8738095 3.8738095 8.2563492 10.9452381 16.0285714 18.6452381 20.6452381 22.645238 
Dunn   4.0948837 0.8810494 0.6568857 0.8694067 0.8808228 1.0415614 1.0230197 1.026192 
Silhouette 0.9591803 0.9879153 0.9784684 0.9751393 0.9727454 0.9728736 0.9727153 0.972622 
        10 
Connectivity 24.6452381 
Dunn   1.3724494 
Silhouette 0.9725379 

インデックスに基づいて最大個数とアクセス個数を得ることができます。私はシルエットの最大値を得たいと思う。

[email protected][1] 
max([email protected]) 
+0

を割り当ててください。 'x < - 概要(インターン)'。 – MichaelChirico

+0

要約から必要な要素を調べるには、 'str(summary(intern)) 'を使用することができます。 – Stereo

+0

私は前に割り当てを試してみましたが、うまくいきませんでした。変数xはnullです。 – YSWJ

答えて

1

str()@兆候を示していくつかのadditionnal説明、これはあなたが検査されているオブジェクトが属性を持つS4クラスであることを指摘します。私はclValidに精通していませんが、source codeを簡単に見てみると、clValidクラスはS4から継承されています。

[email protected]を使用してアクセスできます。通常、これらの属性は何でもかまいません。

functionclValidについては、便宜機能measures(object)を使用して対策にアクセスできるようです。 clValidの残りのソースコードを見ると、utility functionsがあります。 optimalScores()を確認してください。

関連する問題