回答編集履歴
1
修正
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
import numpy as np
|
8
8
|
|
9
|
-
from scipy.cluster.hierarchy import linkage, fcluster
|
9
|
+
from scipy.cluster.hierarchy import linkage, fcluster, dendrogram
|
10
10
|
|
11
11
|
import random
|
12
12
|
|
@@ -32,7 +32,17 @@
|
|
32
32
|
|
33
33
|
Z = linkage(X, method='ward', metric='euclidean')
|
34
34
|
|
35
|
+
dendrogram(Z)
|
36
|
+
|
37
|
+
plt.show()
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
# クラスタ分け
|
42
|
+
|
35
43
|
threshold = 0.7 * np.max(Z[:, 2])
|
44
|
+
|
45
|
+
print(threshold) # 約2.9
|
36
46
|
|
37
47
|
C = fcluster(Z, threshold, criterion='distance')
|
38
48
|
|
@@ -48,4 +58,6 @@
|
|
48
58
|
|
49
59
|
```
|
50
60
|
|
61
|
+
![イメージ説明](deb1aa9e9e572771094012f03fc51fb7.png)
|
62
|
+
|
51
63
|
![イメージ説明](6f8c88a540537b3da201cbfa86ec3c01.png)
|