|
34 | 34 | from sklearn import manifold, datasets
|
35 | 35 | from time import time
|
36 | 36 |
|
37 |
| -n_samples = 300 |
| 37 | +n_samples = 150 |
38 | 38 | n_components = 2
|
39 | 39 | (fig, subplots) = plt.subplots(3, 5, figsize=(15, 8))
|
40 | 40 | perplexities = [5, 30, 50, 100]
|
41 | 41 |
|
42 |
| -X, y = datasets.make_circles(n_samples=n_samples, factor=0.5, noise=0.05) |
| 42 | +X, y = datasets.make_circles( |
| 43 | + n_samples=n_samples, factor=0.5, noise=0.05, random_state=0 |
| 44 | +) |
43 | 45 |
|
44 | 46 | red = y == 0
|
45 | 47 | green = y == 1
|
|
56 | 58 |
|
57 | 59 | t0 = time()
|
58 | 60 | tsne = manifold.TSNE(
|
59 |
| - n_components=n_components, init="random", random_state=0, perplexity=perplexity |
| 61 | + n_components=n_components, |
| 62 | + init="random", |
| 63 | + random_state=0, |
| 64 | + perplexity=perplexity, |
| 65 | + learning_rate="auto", |
| 66 | + n_iter=300, |
60 | 67 | )
|
61 | 68 | Y = tsne.fit_transform(X)
|
62 | 69 | t1 = time()
|
|
81 | 88 |
|
82 | 89 | t0 = time()
|
83 | 90 | tsne = manifold.TSNE(
|
84 |
| - n_components=n_components, init="random", random_state=0, perplexity=perplexity |
| 91 | + n_components=n_components, |
| 92 | + init="random", |
| 93 | + random_state=0, |
| 94 | + perplexity=perplexity, |
| 95 | + learning_rate="auto", |
| 96 | + n_iter=300, |
85 | 97 | )
|
86 | 98 | Y = tsne.fit_transform(X)
|
87 | 99 | t1 = time()
|
|
114 | 126 |
|
115 | 127 | t0 = time()
|
116 | 128 | tsne = manifold.TSNE(
|
117 |
| - n_components=n_components, init="random", random_state=0, perplexity=perplexity |
| 129 | + n_components=n_components, |
| 130 | + init="random", |
| 131 | + random_state=0, |
| 132 | + perplexity=perplexity, |
| 133 | + learning_rate="auto", |
| 134 | + n_iter=400, |
118 | 135 | )
|
119 | 136 | Y = tsne.fit_transform(X)
|
120 | 137 | t1 = time()
|
|
0 commit comments