Skip to content

Commit 76998b0

Browse files
committed
Pushing the docs to dev/ for branch: main, commit f6951474459793ea4f7d1b4d325360924f2e6521
1 parent 46bb17f commit 76998b0

File tree

1,238 files changed

+4223
-4220
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,238 files changed

+4223
-4220
lines changed
Binary file not shown.
Binary file not shown.

dev/_downloads/8b98cea0e0ec1ca3cc503c13ddac0537/plot_t_sne_perplexity.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"# Author: Narine Kokhlikyan <[email protected]>\n# License: BSD\n\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom matplotlib.ticker import NullFormatter\nfrom sklearn import manifold, datasets\nfrom time import time\n\nn_samples = 300\nn_components = 2\n(fig, subplots) = plt.subplots(3, 5, figsize=(15, 8))\nperplexities = [5, 30, 50, 100]\n\nX, y = datasets.make_circles(n_samples=n_samples, factor=0.5, noise=0.05)\n\nred = y == 0\ngreen = y == 1\n\nax = subplots[0][0]\nax.scatter(X[red, 0], X[red, 1], c=\"r\")\nax.scatter(X[green, 0], X[green, 1], c=\"g\")\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\nplt.axis(\"tight\")\n\nfor i, perplexity in enumerate(perplexities):\n ax = subplots[0][i + 1]\n\n t0 = time()\n tsne = manifold.TSNE(\n n_components=n_components, init=\"random\", random_state=0, perplexity=perplexity\n )\n Y = tsne.fit_transform(X)\n t1 = time()\n print(\"circles, perplexity=%d in %.2g sec\" % (perplexity, t1 - t0))\n ax.set_title(\"Perplexity=%d\" % perplexity)\n ax.scatter(Y[red, 0], Y[red, 1], c=\"r\")\n ax.scatter(Y[green, 0], Y[green, 1], c=\"g\")\n ax.xaxis.set_major_formatter(NullFormatter())\n ax.yaxis.set_major_formatter(NullFormatter())\n ax.axis(\"tight\")\n\n# Another example using s-curve\nX, color = datasets.make_s_curve(n_samples, random_state=0)\n\nax = subplots[1][0]\nax.scatter(X[:, 0], X[:, 2], c=color)\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\n\nfor i, perplexity in enumerate(perplexities):\n ax = subplots[1][i + 1]\n\n t0 = time()\n tsne = manifold.TSNE(\n n_components=n_components, init=\"random\", random_state=0, perplexity=perplexity\n )\n Y = tsne.fit_transform(X)\n t1 = time()\n print(\"S-curve, perplexity=%d in %.2g sec\" % (perplexity, t1 - t0))\n\n ax.set_title(\"Perplexity=%d\" % perplexity)\n ax.scatter(Y[:, 0], Y[:, 1], c=color)\n ax.xaxis.set_major_formatter(NullFormatter())\n ax.yaxis.set_major_formatter(NullFormatter())\n ax.axis(\"tight\")\n\n\n# Another example using a 2D uniform grid\nx = np.linspace(0, 1, int(np.sqrt(n_samples)))\nxx, yy = np.meshgrid(x, x)\nX = np.hstack(\n [\n xx.ravel().reshape(-1, 1),\n yy.ravel().reshape(-1, 1),\n ]\n)\ncolor = xx.ravel()\nax = subplots[2][0]\nax.scatter(X[:, 0], X[:, 1], c=color)\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\n\nfor i, perplexity in enumerate(perplexities):\n ax = subplots[2][i + 1]\n\n t0 = time()\n tsne = manifold.TSNE(\n n_components=n_components, init=\"random\", random_state=0, perplexity=perplexity\n )\n Y = tsne.fit_transform(X)\n t1 = time()\n print(\"uniform grid, perplexity=%d in %.2g sec\" % (perplexity, t1 - t0))\n\n ax.set_title(\"Perplexity=%d\" % perplexity)\n ax.scatter(Y[:, 0], Y[:, 1], c=color)\n ax.xaxis.set_major_formatter(NullFormatter())\n ax.yaxis.set_major_formatter(NullFormatter())\n ax.axis(\"tight\")\n\n\nplt.show()"
29+
"# Author: Narine Kokhlikyan <[email protected]>\n# License: BSD\n\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom matplotlib.ticker import NullFormatter\nfrom sklearn import manifold, datasets\nfrom time import time\n\nn_samples = 150\nn_components = 2\n(fig, subplots) = plt.subplots(3, 5, figsize=(15, 8))\nperplexities = [5, 30, 50, 100]\n\nX, y = datasets.make_circles(\n n_samples=n_samples, factor=0.5, noise=0.05, random_state=0\n)\n\nred = y == 0\ngreen = y == 1\n\nax = subplots[0][0]\nax.scatter(X[red, 0], X[red, 1], c=\"r\")\nax.scatter(X[green, 0], X[green, 1], c=\"g\")\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\nplt.axis(\"tight\")\n\nfor i, perplexity in enumerate(perplexities):\n ax = subplots[0][i + 1]\n\n t0 = time()\n tsne = manifold.TSNE(\n n_components=n_components,\n init=\"random\",\n random_state=0,\n perplexity=perplexity,\n learning_rate=\"auto\",\n n_iter=300,\n )\n Y = tsne.fit_transform(X)\n t1 = time()\n print(\"circles, perplexity=%d in %.2g sec\" % (perplexity, t1 - t0))\n ax.set_title(\"Perplexity=%d\" % perplexity)\n ax.scatter(Y[red, 0], Y[red, 1], c=\"r\")\n ax.scatter(Y[green, 0], Y[green, 1], c=\"g\")\n ax.xaxis.set_major_formatter(NullFormatter())\n ax.yaxis.set_major_formatter(NullFormatter())\n ax.axis(\"tight\")\n\n# Another example using s-curve\nX, color = datasets.make_s_curve(n_samples, random_state=0)\n\nax = subplots[1][0]\nax.scatter(X[:, 0], X[:, 2], c=color)\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\n\nfor i, perplexity in enumerate(perplexities):\n ax = subplots[1][i + 1]\n\n t0 = time()\n tsne = manifold.TSNE(\n n_components=n_components,\n init=\"random\",\n random_state=0,\n perplexity=perplexity,\n learning_rate=\"auto\",\n n_iter=300,\n )\n Y = tsne.fit_transform(X)\n t1 = time()\n print(\"S-curve, perplexity=%d in %.2g sec\" % (perplexity, t1 - t0))\n\n ax.set_title(\"Perplexity=%d\" % perplexity)\n ax.scatter(Y[:, 0], Y[:, 1], c=color)\n ax.xaxis.set_major_formatter(NullFormatter())\n ax.yaxis.set_major_formatter(NullFormatter())\n ax.axis(\"tight\")\n\n\n# Another example using a 2D uniform grid\nx = np.linspace(0, 1, int(np.sqrt(n_samples)))\nxx, yy = np.meshgrid(x, x)\nX = np.hstack(\n [\n xx.ravel().reshape(-1, 1),\n yy.ravel().reshape(-1, 1),\n ]\n)\ncolor = xx.ravel()\nax = subplots[2][0]\nax.scatter(X[:, 0], X[:, 1], c=color)\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\n\nfor i, perplexity in enumerate(perplexities):\n ax = subplots[2][i + 1]\n\n t0 = time()\n tsne = manifold.TSNE(\n n_components=n_components,\n init=\"random\",\n random_state=0,\n perplexity=perplexity,\n learning_rate=\"auto\",\n n_iter=400,\n )\n Y = tsne.fit_transform(X)\n t1 = time()\n print(\"uniform grid, perplexity=%d in %.2g sec\" % (perplexity, t1 - t0))\n\n ax.set_title(\"Perplexity=%d\" % perplexity)\n ax.scatter(Y[:, 0], Y[:, 1], c=color)\n ax.xaxis.set_major_formatter(NullFormatter())\n ax.yaxis.set_major_formatter(NullFormatter())\n ax.axis(\"tight\")\n\n\nplt.show()"
3030
]
3131
}
3232
],

dev/_downloads/dec20a8d5f622301132b632f5e0bd532/plot_t_sne_perplexity.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@
3434
from sklearn import manifold, datasets
3535
from time import time
3636

37-
n_samples = 300
37+
n_samples = 150
3838
n_components = 2
3939
(fig, subplots) = plt.subplots(3, 5, figsize=(15, 8))
4040
perplexities = [5, 30, 50, 100]
4141

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+
)
4345

4446
red = y == 0
4547
green = y == 1
@@ -56,7 +58,12 @@
5658

5759
t0 = time()
5860
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,
6067
)
6168
Y = tsne.fit_transform(X)
6269
t1 = time()
@@ -81,7 +88,12 @@
8188

8289
t0 = time()
8390
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,
8597
)
8698
Y = tsne.fit_transform(X)
8799
t1 = time()
@@ -114,7 +126,12 @@
114126

115127
t0 = time()
116128
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,
118135
)
119136
Y = tsne.fit_transform(X)
120137
t1 = time()

dev/_downloads/scikit-learn-docs.zip

-36.7 KB
Binary file not shown.
4 Bytes
8 Bytes
-23 Bytes
106 Bytes
-1 Bytes

0 commit comments

Comments
 (0)