Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions examples/manifold/plot_t_sne_perplexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@
from sklearn import manifold, datasets
from time import time

n_samples = 300
n_samples = 150
n_components = 2
(fig, subplots) = plt.subplots(3, 5, figsize=(15, 8))
perplexities = [5, 30, 50, 100]

X, y = datasets.make_circles(n_samples=n_samples, factor=0.5, noise=0.05)
X, y = datasets.make_circles(
n_samples=n_samples, factor=0.5, noise=0.05, random_state=0
)

red = y == 0
green = y == 1
Expand All @@ -56,7 +58,12 @@

t0 = time()
tsne = manifold.TSNE(
n_components=n_components, init="random", random_state=0, perplexity=perplexity
n_components=n_components,
init="random",
random_state=0,
perplexity=perplexity,
learning_rate="auto",
n_iter=300,
)
Y = tsne.fit_transform(X)
t1 = time()
Expand All @@ -81,7 +88,12 @@

t0 = time()
tsne = manifold.TSNE(
n_components=n_components, init="random", random_state=0, perplexity=perplexity
n_components=n_components,
init="random",
random_state=0,
perplexity=perplexity,
learning_rate="auto",
n_iter=300,
)
Y = tsne.fit_transform(X)
t1 = time()
Expand Down Expand Up @@ -114,7 +126,12 @@

t0 = time()
tsne = manifold.TSNE(
n_components=n_components, init="random", random_state=0, perplexity=perplexity
n_components=n_components,
init="random",
random_state=0,
perplexity=perplexity,
learning_rate="auto",
n_iter=400,
)
Y = tsne.fit_transform(X)
t1 = time()
Expand Down