Spaces:
Runtime error
Runtime error
Benjamin Bossan
commited on
Commit
·
9be4332
1
Parent(s):
5444690
Add spiral dataset
Browse files
app.py
CHANGED
@@ -88,10 +88,24 @@ def get_varied(n_clusters):
|
|
88 |
return normalize(X), labels
|
89 |
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
DATA_MAPPING = {
|
92 |
'regular': get_regular,
|
93 |
'circles': get_circles,
|
94 |
'moons': get_moons,
|
|
|
95 |
'noise': get_noise,
|
96 |
'anisotropic': get_anisotropic,
|
97 |
'varied': get_varied,
|
|
|
88 |
return normalize(X), labels
|
89 |
|
90 |
|
91 |
+
def get_spiral(n_clusters):
|
92 |
+
# from https://scikit-learn.org/stable/auto_examples/cluster/plot_agglomerative_clustering.html
|
93 |
+
t = 1.5 * np.pi * (1 + 3 * np.random.rand(1, N_SAMPLES))
|
94 |
+
x = t * np.cos(t)
|
95 |
+
y = t * np.sin(t)
|
96 |
+
X = np.concatenate((x, y))
|
97 |
+
X += 0.7 * np.random.randn(2, N_SAMPLES)
|
98 |
+
X = X.T
|
99 |
+
|
100 |
+
labels = np.zeros(N_SAMPLES, dtype=int)
|
101 |
+
return normalize(X), labels
|
102 |
+
|
103 |
+
|
104 |
DATA_MAPPING = {
|
105 |
'regular': get_regular,
|
106 |
'circles': get_circles,
|
107 |
'moons': get_moons,
|
108 |
+
'spiral': get_spiral,
|
109 |
'noise': get_noise,
|
110 |
'anisotropic': get_anisotropic,
|
111 |
'varied': get_varied,
|