Skip to content

Commit 971cf9c

Browse files
committed
Pushing the docs to dev/ for branch: main, commit 0ff613e8dd1e340784d49e2a2308b26eec6c7ff4
1 parent 6ca5eb3 commit 971cf9c

File tree

1,227 files changed

+4281
-4274
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,227 files changed

+4281
-4274
lines changed
Binary file not shown.

dev/_downloads/604c0a9de0e1b80dae9e6754fdb27014/plot_manifold_sphere.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: Jaques Grobler <[email protected]>\n# License: BSD 3 clause\n\nfrom time import time\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\nfrom matplotlib.ticker import NullFormatter\n\nfrom sklearn import manifold\nfrom sklearn.utils import check_random_state\n\n# Next line to silence pyflakes.\nAxes3D\n\n# Variables for manifold learning.\nn_neighbors = 10\nn_samples = 1000\n\n# Create our sphere.\nrandom_state = check_random_state(0)\np = random_state.rand(n_samples) * (2 * np.pi - 0.55)\nt = random_state.rand(n_samples) * np.pi\n\n# Sever the poles from the sphere.\nindices = (t < (np.pi - (np.pi / 8))) & (t > ((np.pi / 8)))\ncolors = p[indices]\nx, y, z = (\n np.sin(t[indices]) * np.cos(p[indices]),\n np.sin(t[indices]) * np.sin(p[indices]),\n np.cos(t[indices]),\n)\n\n# Plot our dataset.\nfig = plt.figure(figsize=(15, 8))\nplt.suptitle(\n \"Manifold Learning with %i points, %i neighbors\" % (1000, n_neighbors), fontsize=14\n)\n\nax = fig.add_subplot(251, projection=\"3d\")\nax.scatter(x, y, z, c=p[indices], cmap=plt.cm.rainbow)\nax.view_init(40, -10)\n\nsphere_data = np.array([x, y, z]).T\n\n# Perform Locally Linear Embedding Manifold learning\nmethods = [\"standard\", \"ltsa\", \"hessian\", \"modified\"]\nlabels = [\"LLE\", \"LTSA\", \"Hessian LLE\", \"Modified LLE\"]\n\nfor i, method in enumerate(methods):\n t0 = time()\n trans_data = (\n manifold.LocallyLinearEmbedding(\n n_neighbors=n_neighbors, n_components=2, method=method\n )\n .fit_transform(sphere_data)\n .T\n )\n t1 = time()\n print(\"%s: %.2g sec\" % (methods[i], t1 - t0))\n\n ax = fig.add_subplot(252 + i)\n plt.scatter(trans_data[0], trans_data[1], c=colors, cmap=plt.cm.rainbow)\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\n# Perform Isomap Manifold learning.\nt0 = time()\ntrans_data = (\n manifold.Isomap(n_neighbors=n_neighbors, n_components=2)\n .fit_transform(sphere_data)\n .T\n)\nt1 = time()\nprint(\"%s: %.2g sec\" % (\"ISO\", t1 - t0))\n\nax = fig.add_subplot(257)\nplt.scatter(trans_data[0], trans_data[1], c=colors, cmap=plt.cm.rainbow)\nplt.title(\"%s (%.2g sec)\" % (\"Isomap\", t1 - t0))\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\nplt.axis(\"tight\")\n\n# Perform Multi-dimensional scaling.\nt0 = time()\nmds = manifold.MDS(2, max_iter=100, n_init=1)\ntrans_data = mds.fit_transform(sphere_data).T\nt1 = time()\nprint(\"MDS: %.2g sec\" % (t1 - t0))\n\nax = fig.add_subplot(258)\nplt.scatter(trans_data[0], trans_data[1], c=colors, cmap=plt.cm.rainbow)\nplt.title(\"MDS (%.2g sec)\" % (t1 - t0))\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\nplt.axis(\"tight\")\n\n# Perform Spectral Embedding.\nt0 = time()\nse = manifold.SpectralEmbedding(n_components=2, n_neighbors=n_neighbors)\ntrans_data = se.fit_transform(sphere_data).T\nt1 = time()\nprint(\"Spectral Embedding: %.2g sec\" % (t1 - t0))\n\nax = fig.add_subplot(259)\nplt.scatter(trans_data[0], trans_data[1], c=colors, cmap=plt.cm.rainbow)\nplt.title(\"Spectral Embedding (%.2g sec)\" % (t1 - t0))\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\nplt.axis(\"tight\")\n\n# Perform t-distributed stochastic neighbor embedding.\nt0 = time()\ntsne = manifold.TSNE(n_components=2, init=\"pca\", random_state=0)\ntrans_data = tsne.fit_transform(sphere_data).T\nt1 = time()\nprint(\"t-SNE: %.2g sec\" % (t1 - t0))\n\nax = fig.add_subplot(2, 5, 10)\nplt.scatter(trans_data[0], trans_data[1], c=colors, cmap=plt.cm.rainbow)\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: Jaques Grobler <[email protected]>\n# License: BSD 3 clause\n\nfrom time import time\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom matplotlib.ticker import NullFormatter\nfrom sklearn import manifold\nfrom sklearn.utils import check_random_state\n\n# Unused but required import for doing 3d projections with matplotlib < 3.2\nimport mpl_toolkits.mplot3d # noqa: F401\nimport warnings\n\n# Variables for manifold learning.\nn_neighbors = 10\nn_samples = 1000\n\n# Create our sphere.\nrandom_state = check_random_state(0)\np = random_state.rand(n_samples) * (2 * np.pi - 0.55)\nt = random_state.rand(n_samples) * np.pi\n\n# Sever the poles from the sphere.\nindices = (t < (np.pi - (np.pi / 8))) & (t > ((np.pi / 8)))\ncolors = p[indices]\nx, y, z = (\n np.sin(t[indices]) * np.cos(p[indices]),\n np.sin(t[indices]) * np.sin(p[indices]),\n np.cos(t[indices]),\n)\n\n# Plot our dataset.\nfig = plt.figure(figsize=(15, 8))\nplt.suptitle(\n \"Manifold Learning with %i points, %i neighbors\" % (1000, n_neighbors), fontsize=14\n)\n\nax = fig.add_subplot(251, projection=\"3d\")\nax.scatter(x, y, z, c=p[indices], cmap=plt.cm.rainbow)\nax.view_init(40, -10)\n\nsphere_data = np.array([x, y, z]).T\n\n# Perform Locally Linear Embedding Manifold learning\nmethods = [\"standard\", \"ltsa\", \"hessian\", \"modified\"]\nlabels = [\"LLE\", \"LTSA\", \"Hessian LLE\", \"Modified LLE\"]\n\nfor i, method in enumerate(methods):\n t0 = time()\n trans_data = (\n manifold.LocallyLinearEmbedding(\n n_neighbors=n_neighbors, n_components=2, method=method\n )\n .fit_transform(sphere_data)\n .T\n )\n t1 = time()\n print(\"%s: %.2g sec\" % (methods[i], t1 - t0))\n\n ax = fig.add_subplot(252 + i)\n plt.scatter(trans_data[0], trans_data[1], c=colors, cmap=plt.cm.rainbow)\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\n# Perform Isomap Manifold learning.\nt0 = time()\ntrans_data = (\n manifold.Isomap(n_neighbors=n_neighbors, n_components=2)\n .fit_transform(sphere_data)\n .T\n)\nt1 = time()\nprint(\"%s: %.2g sec\" % (\"ISO\", t1 - t0))\n\nax = fig.add_subplot(257)\nplt.scatter(trans_data[0], trans_data[1], c=colors, cmap=plt.cm.rainbow)\nplt.title(\"%s (%.2g sec)\" % (\"Isomap\", t1 - t0))\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\nplt.axis(\"tight\")\n\n# Perform Multi-dimensional scaling.\nt0 = time()\nmds = manifold.MDS(2, max_iter=100, n_init=1)\ntrans_data = mds.fit_transform(sphere_data).T\nt1 = time()\nprint(\"MDS: %.2g sec\" % (t1 - t0))\n\nax = fig.add_subplot(258)\nplt.scatter(trans_data[0], trans_data[1], c=colors, cmap=plt.cm.rainbow)\nplt.title(\"MDS (%.2g sec)\" % (t1 - t0))\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\nplt.axis(\"tight\")\n\n# Perform Spectral Embedding.\nt0 = time()\nse = manifold.SpectralEmbedding(n_components=2, n_neighbors=n_neighbors)\ntrans_data = se.fit_transform(sphere_data).T\nt1 = time()\nprint(\"Spectral Embedding: %.2g sec\" % (t1 - t0))\n\nax = fig.add_subplot(259)\nplt.scatter(trans_data[0], trans_data[1], c=colors, cmap=plt.cm.rainbow)\nplt.title(\"Spectral Embedding (%.2g sec)\" % (t1 - t0))\nax.xaxis.set_major_formatter(NullFormatter())\nax.yaxis.set_major_formatter(NullFormatter())\nplt.axis(\"tight\")\n\n# Perform t-distributed stochastic neighbor embedding.\n# TODO(1.2) Remove warning handling.\nwith warnings.catch_warnings():\n warnings.filterwarnings(\n \"ignore\", message=\"The PCA initialization\", category=FutureWarning\n )\n t0 = time()\n tsne = manifold.TSNE(\n n_components=2, init=\"pca\", random_state=0, learning_rate=\"auto\"\n )\n trans_data = tsne.fit_transform(sphere_data).T\n t1 = time()\nprint(\"t-SNE: %.2g sec\" % (t1 - t0))\n\nax = fig.add_subplot(2, 5, 10)\nplt.scatter(trans_data[0], trans_data[1], c=colors, cmap=plt.cm.rainbow)\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()"
3030
]
3131
}
3232
],
Binary file not shown.

dev/_downloads/9846b34238b553e03157c49723da2b04/plot_manifold_sphere.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,15 @@
3030
# License: BSD 3 clause
3131

3232
from time import time
33-
3433
import numpy as np
3534
import matplotlib.pyplot as plt
36-
from mpl_toolkits.mplot3d import Axes3D
3735
from matplotlib.ticker import NullFormatter
38-
3936
from sklearn import manifold
4037
from sklearn.utils import check_random_state
4138

42-
# Next line to silence pyflakes.
43-
Axes3D
39+
# Unused but required import for doing 3d projections with matplotlib < 3.2
40+
import mpl_toolkits.mplot3d # noqa: F401
41+
import warnings
4442

4543
# Variables for manifold learning.
4644
n_neighbors = 10
@@ -141,10 +139,17 @@
141139
plt.axis("tight")
142140

143141
# Perform t-distributed stochastic neighbor embedding.
144-
t0 = time()
145-
tsne = manifold.TSNE(n_components=2, init="pca", random_state=0)
146-
trans_data = tsne.fit_transform(sphere_data).T
147-
t1 = time()
142+
# TODO(1.2) Remove warning handling.
143+
with warnings.catch_warnings():
144+
warnings.filterwarnings(
145+
"ignore", message="The PCA initialization", category=FutureWarning
146+
)
147+
t0 = time()
148+
tsne = manifold.TSNE(
149+
n_components=2, init="pca", random_state=0, learning_rate="auto"
150+
)
151+
trans_data = tsne.fit_transform(sphere_data).T
152+
t1 = time()
148153
print("t-SNE: %.2g sec" % (t1 - t0))
149154

150155
ax = fig.add_subplot(2, 5, 10)

dev/_downloads/b7e32fe54d613dce0d3c376377af061d/plot_outlier_detection_bench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
# %%
2525
# Define a data preprocessing function
26-
# ----------------------------------
26+
# ------------------------------------
2727
#
2828
# The example uses real-world datasets available in
2929
# :class:`sklearn.datasets` and the sample size of some datasets is reduced

dev/_downloads/scikit-learn-docs.zip

-8.54 KB
Binary file not shown.
-185 Bytes
204 Bytes
80 Bytes
135 Bytes

0 commit comments

Comments
 (0)