LoginSignup
0
0

More than 1 year has passed since last update.

Octave でクラスター分析

Last updated at Posted at 2022-07-15

Octave でクラスター分析

クラスター分析を行う。

usage:
y = linkage (x, method)

x: データ行列
method: "single"(デフォルト), "complete", "average",
        "weighted", "centroid", "median", "ward"

[h, t, perm] = dendrogram (tree, p, prop, val )
tree は linkage() の戻り値
p はデンドログラムの leaf の数。全部描くには 0 を指定する
prop, val はプロパティーと値のペア
"Orientation" はデンドログラムの描き方 "top"(デフォルト), "bottom", "right", "left"
perm は leaf のベクトル

使用例

pkg load statistics % statistics が必要
format long % 表示精度を高くする(任意)
iris = csvread("iris.csv")(2:151, 2:5);
y = linkage(iris, "ward");
gh = figure(1, 'position',[0,0,500,5000]); # 一定以上の大きさにはできないようだ
set(gca, 'TickDir','out') # tickmark を外側に付ける
[h, t, perm] = dendrogram(y, 0, "Orientation", "right");

output_5_0.png

perm
perm =

    36
    13
     2
    46
    26
    10
    35
     7
     3
     4
    48
    25
    12
    30
    31
    42
    23
    14
    43
     9
    39
     5
    38
    50
     8
    40
    28
    29
    41
     1
    18
    44
    24
    27
    45
    47
    20
    22
    33
    34
    15
    16
     6
    19
    21
    32
    17
    37
    11
    49
   141
   145
   125
   121
   144
   101
   116
   137
   149
   112
   104
   117
   138
   109
   105
   129
   133
    78
   111
   148
   113
   140
   142
   146
   108
   131
   103
   126
   130
   119
   106
   123
   118
   132
   110
   136
    61
    99
    58
    94
    63
    68
    83
    93
    65
    80
    60
    54
    90
    70
    81
    82
   107
    95
   100
    89
    96
    97
    67
    85
    56
    91
   115
   122
   114
   102
   120
    69
    88
   135
   147
   124
   127
    73
    84
   134
    87
    51
    53
    66
    76
    77
    55
    59
    74
    79
    64
    92
    75
    98
    62
    72
   150
    71
   128
   139
    86
    52
    57
     0
t
t =

 Columns 1 through 13:

     1     2     3     4     5     6     7     8     9    10    11    12    13

 Columns 14 through 26:

    14    15    16    17    18    19    20    21    22    23    24    25    26

 Columns 27 through 39:

    27    28    29    30    31    32    33    34    35    36    37    38    39

 Columns 40 through 52:

    40    41    42    43    44    45    46    47    48    49    50    51    52

 Columns 53 through 65:

    53    54    55    56    57    58    59    60    61    62    63    64    65

 Columns 66 through 78:

    66    67    68    69    70    71    72    73    74    75    76    77    78

 Columns 79 through 91:

    79    80    81    82    83    84    85    86    87    88    89    90    91

 Columns 92 through 104:

    92    93    94    95    96    97    98    99   100   101   102   103   104

 Columns 105 through 117:

   105   106   107   108   109   110   111   112   113   114   115   116   117

 Columns 118 through 130:

   118   119   120   121   122   123   124   125   126   127   128   129   130

 Columns 131 through 143:

   131   132   133   134   135   136   137   138   139   140   141   142   143

 Columns 144 through 150:

   144   145   146   147   148   149   150
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0