Skip to content

Commit 134f60e

Browse files
committed
Pushing the docs to dev/ for branch: master, commit 3339d802402fd2f2ed5e954434c637bf7a68124d
1 parent 177123c commit 134f60e

File tree

1,201 files changed

+4201
-4334
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,201 files changed

+4201
-4334
lines changed
Binary file not shown.

dev/_downloads/50620cb5a6bfe6c3bcb899f31a3348a3/plot_compare_methods.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: Jake Vanderplas -- <[email protected]>\n\nprint(__doc__)\n\nfrom time import time\n\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\nfrom matplotlib.ticker import NullFormatter\n\nfrom sklearn import manifold, datasets\n\n# Next line to silence pyflakes. This import is needed.\nAxes3D\n\nn_points = 1000\nX, color = datasets.make_s_curve(n_points, random_state=0)\nn_neighbors = 10\nn_components = 2\n\nfig = plt.figure(figsize=(15, 8))\nplt.suptitle(\"Manifold Learning with %i points, %i neighbors\"\n % (1000, n_neighbors), fontsize=14)\n\n\nax = fig.add_subplot(251, projection='3d')\nax.scatter(X[:, 0], X[:, 1], X[:, 2], c=color, cmap=plt.cm.Spectral)\nax.view_init(4, -72)\n\nmethods = ['standard', 'ltsa', 'hessian', 'modified']\nlabels = ['LLE', 'LTSA', 'Hessian LLE', 'Modified LLE']\n\nfor i, method in enumerate(methods):\n t0 = time()\n Y = manifold.LocallyLinearEmbedding(n_neighbors, n_components,\n eigen_solver='auto',\n method=method).fit_transform(X)\n t1 = time()\n print(\"%s: %.2g sec\" % (methods[i], t1 - t0))\n\n ax = fig.add_subplot(252 + i)\n plt.scatter(Y[:, 0], Y[:, 1], c=color, cmap=plt.cm.Spectral)\n plt.title(\"%s (%.2g sec)\" % (labels[i], t1 - t0))\n ax.xaxis.set_major_formatter(NullFormatter())\n ax.yaxis.set_major_formatter(NullFormatter())\n plt.axis('tight')\n\nt0 = time()\nY = manifold.Isomap(n_neighbors, n_components).fit_transform(X)\nt1 = time()\nprint(\"Isomap: %.2g sec\" % (t1 - t0))\nax = fig.add_subplot(257)\nplt.scatter(Y[:, 0], Y[:, 1], c=color, cmap=plt.cm.Spectral)\nplt.title(\"Isomap (%.2g sec)\" % (t1 - t0))\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\nplt.axis('tight')\n\n\nt0 = time()\nmds = manifold.MDS(n_components, max_iter=100, n_init=1)\nY = mds.fit_transform(X)\nt1 = time()\nprint(\"MDS: %.2g sec\" % (t1 - t0))\nax = fig.add_subplot(258)\nplt.scatter(Y[:, 0], Y[:, 1], c=color, cmap=plt.cm.Spectral)\nplt.title(\"MDS (%.2g sec)\" % (t1 - t0))\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\nplt.axis('tight')\n\n\nt0 = time()\nse = manifold.SpectralEmbedding(n_components=n_components,\n n_neighbors=n_neighbors)\nY = se.fit_transform(X)\nt1 = time()\nprint(\"SpectralEmbedding: %.2g sec\" % (t1 - t0))\nax = fig.add_subplot(259)\nplt.scatter(Y[:, 0], Y[:, 1], c=color, cmap=plt.cm.Spectral)\nplt.title(\"SpectralEmbedding (%.2g sec)\" % (t1 - t0))\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\nplt.axis('tight')\n\nt0 = time()\ntsne = manifold.TSNE(n_components=n_components, init='pca', random_state=0)\nY = tsne.fit_transform(X)\nt1 = time()\nprint(\"t-SNE: %.2g sec\" % (t1 - t0))\nax = fig.add_subplot(2, 5, 10)\nplt.scatter(Y[:, 0], Y[:, 1], c=color, cmap=plt.cm.Spectral)\nplt.title(\"t-SNE (%.2g sec)\" % (t1 - t0))\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\nplt.axis('tight')\n\nplt.show()"
29+
"# Author: Jake Vanderplas -- <[email protected]>\n\nprint(__doc__)\n\nfrom collections import OrderedDict\nfrom functools import partial\nfrom time import time\n\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\nfrom matplotlib.ticker import NullFormatter\n\nfrom sklearn import manifold, datasets\n\n# Next line to silence pyflakes. This import is needed.\nAxes3D\n\nn_points = 1000\nX, color = datasets.make_s_curve(n_points, random_state=0)\nn_neighbors = 10\nn_components = 2\n\n# Create figure\nfig = plt.figure(figsize=(15, 8))\nfig.suptitle(\"Manifold Learning with %i points, %i neighbors\"\n % (1000, n_neighbors), fontsize=14)\n\n# Add 3d scatter plot\nax = fig.add_subplot(251, projection='3d')\nax.scatter(X[:, 0], X[:, 1], X[:, 2], c=color, cmap=plt.cm.Spectral)\nax.view_init(4, -72)\n\n# Set-up manifold methods\nLLE = partial(manifold.LocallyLinearEmbedding,\n n_neighbors, n_components, eigen_solver='auto')\n\nmethods = OrderedDict()\nmethods['LLE'] = LLE(method='standard')\nmethods['LTSA'] = LLE(method='ltsa')\nmethods['Hessian LLE'] = LLE(method='hessian')\nmethods['Modified LLE'] = LLE(method='modified')\nmethods['Isomap'] = manifold.Isomap(n_neighbors, n_components)\nmethods['MDS'] = manifold.MDS(n_components, max_iter=100, n_init=1)\nmethods['SE'] = manifold.SpectralEmbedding(n_components=n_components,\n n_neighbors=n_neighbors)\nmethods['t-SNE'] = manifold.TSNE(n_components=n_components, init='pca',\n random_state=0)\n\n# Plot results\nfor i, (label, method) in enumerate(methods.items()):\n t0 = time()\n Y = method.fit_transform(X)\n t1 = time()\n print(\"%s: %.2g sec\" % (label, t1 - t0))\n ax = fig.add_subplot(2, 5, 2 + i + (i > 3))\n ax.scatter(Y[:, 0], Y[:, 1], c=color, cmap=plt.cm.Spectral)\n ax.set_title(\"%s (%.2g sec)\" % (label, t1 - t0))\n ax.xaxis.set_major_formatter(NullFormatter())\n ax.yaxis.set_major_formatter(NullFormatter())\n ax.axis('tight')\n\nplt.show()"
3030
]
3131
}
3232
],

dev/_downloads/740595efac9c4748f29248cd940dc12e/plot_compare_methods.py

Lines changed: 29 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
print(__doc__)
2525

26+
from collections import OrderedDict
27+
from functools import partial
2628
from time import time
2729

2830
import matplotlib.pyplot as plt
@@ -39,81 +41,43 @@
3941
n_neighbors = 10
4042
n_components = 2
4143

44+
# Create figure
4245
fig = plt.figure(figsize=(15, 8))
43-
plt.suptitle("Manifold Learning with %i points, %i neighbors"
46+
fig.suptitle("Manifold Learning with %i points, %i neighbors"
4447
% (1000, n_neighbors), fontsize=14)
4548

46-
49+
# Add 3d scatter plot
4750
ax = fig.add_subplot(251, projection='3d')
4851
ax.scatter(X[:, 0], X[:, 1], X[:, 2], c=color, cmap=plt.cm.Spectral)
4952
ax.view_init(4, -72)
5053

51-
methods = ['standard', 'ltsa', 'hessian', 'modified']
52-
labels = ['LLE', 'LTSA', 'Hessian LLE', 'Modified LLE']
53-
54-
for i, method in enumerate(methods):
54+
# Set-up manifold methods
55+
LLE = partial(manifold.LocallyLinearEmbedding,
56+
n_neighbors, n_components, eigen_solver='auto')
57+
58+
methods = OrderedDict()
59+
methods['LLE'] = LLE(method='standard')
60+
methods['LTSA'] = LLE(method='ltsa')
61+
methods['Hessian LLE'] = LLE(method='hessian')
62+
methods['Modified LLE'] = LLE(method='modified')
63+
methods['Isomap'] = manifold.Isomap(n_neighbors, n_components)
64+
methods['MDS'] = manifold.MDS(n_components, max_iter=100, n_init=1)
65+
methods['SE'] = manifold.SpectralEmbedding(n_components=n_components,
66+
n_neighbors=n_neighbors)
67+
methods['t-SNE'] = manifold.TSNE(n_components=n_components, init='pca',
68+
random_state=0)
69+
70+
# Plot results
71+
for i, (label, method) in enumerate(methods.items()):
5572
t0 = time()
56-
Y = manifold.LocallyLinearEmbedding(n_neighbors, n_components,
57-
eigen_solver='auto',
58-
method=method).fit_transform(X)
73+
Y = method.fit_transform(X)
5974
t1 = time()
60-
print("%s: %.2g sec" % (methods[i], t1 - t0))
61-
62-
ax = fig.add_subplot(252 + i)
63-
plt.scatter(Y[:, 0], Y[:, 1], c=color, cmap=plt.cm.Spectral)
64-
plt.title("%s (%.2g sec)" % (labels[i], t1 - t0))
75+
print("%s: %.2g sec" % (label, t1 - t0))
76+
ax = fig.add_subplot(2, 5, 2 + i + (i > 3))
77+
ax.scatter(Y[:, 0], Y[:, 1], c=color, cmap=plt.cm.Spectral)
78+
ax.set_title("%s (%.2g sec)" % (label, t1 - t0))
6579
ax.xaxis.set_major_formatter(NullFormatter())
6680
ax.yaxis.set_major_formatter(NullFormatter())
67-
plt.axis('tight')
68-
69-
t0 = time()
70-
Y = manifold.Isomap(n_neighbors, n_components).fit_transform(X)
71-
t1 = time()
72-
print("Isomap: %.2g sec" % (t1 - t0))
73-
ax = fig.add_subplot(257)
74-
plt.scatter(Y[:, 0], Y[:, 1], c=color, cmap=plt.cm.Spectral)
75-
plt.title("Isomap (%.2g sec)" % (t1 - t0))
76-
ax.xaxis.set_major_formatter(NullFormatter())
77-
ax.yaxis.set_major_formatter(NullFormatter())
78-
plt.axis('tight')
79-
80-
81-
t0 = time()
82-
mds = manifold.MDS(n_components, max_iter=100, n_init=1)
83-
Y = mds.fit_transform(X)
84-
t1 = time()
85-
print("MDS: %.2g sec" % (t1 - t0))
86-
ax = fig.add_subplot(258)
87-
plt.scatter(Y[:, 0], Y[:, 1], c=color, cmap=plt.cm.Spectral)
88-
plt.title("MDS (%.2g sec)" % (t1 - t0))
89-
ax.xaxis.set_major_formatter(NullFormatter())
90-
ax.yaxis.set_major_formatter(NullFormatter())
91-
plt.axis('tight')
92-
93-
94-
t0 = time()
95-
se = manifold.SpectralEmbedding(n_components=n_components,
96-
n_neighbors=n_neighbors)
97-
Y = se.fit_transform(X)
98-
t1 = time()
99-
print("SpectralEmbedding: %.2g sec" % (t1 - t0))
100-
ax = fig.add_subplot(259)
101-
plt.scatter(Y[:, 0], Y[:, 1], c=color, cmap=plt.cm.Spectral)
102-
plt.title("SpectralEmbedding (%.2g sec)" % (t1 - t0))
103-
ax.xaxis.set_major_formatter(NullFormatter())
104-
ax.yaxis.set_major_formatter(NullFormatter())
105-
plt.axis('tight')
106-
107-
t0 = time()
108-
tsne = manifold.TSNE(n_components=n_components, init='pca', random_state=0)
109-
Y = tsne.fit_transform(X)
110-
t1 = time()
111-
print("t-SNE: %.2g sec" % (t1 - t0))
112-
ax = fig.add_subplot(2, 5, 10)
113-
plt.scatter(Y[:, 0], Y[:, 1], c=color, cmap=plt.cm.Spectral)
114-
plt.title("t-SNE (%.2g sec)" % (t1 - t0))
115-
ax.xaxis.set_major_formatter(NullFormatter())
116-
ax.yaxis.set_major_formatter(NullFormatter())
117-
plt.axis('tight')
81+
ax.axis('tight')
11882

11983
plt.show()
Binary file not shown.

dev/_downloads/scikit-learn-docs.pdf

51.2 KB
Binary file not shown.

dev/_images/iris.png

0 Bytes

0 commit comments

Comments
 (0)