Skip to content

Commit 41cdc33

Browse files
committed
Pushing the docs to dev/ for branch: master, commit 226e5c478db07495b3ba4f4640e21f11c55f2444
1 parent 96e539f commit 41cdc33

File tree

1,187 files changed

+3703
-3706
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,187 files changed

+3703
-3706
lines changed
Binary file not shown.

dev/_downloads/a7c27f28286fa6da608d31eabd4a2e8c/plot_pca_3d.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-
"print(__doc__)\n\n# Authors: Gael Varoquaux\n# Jaques Grobler\n# Kevin Hughes\n# License: BSD 3 clause\n\nfrom sklearn.decomposition import PCA\n\nfrom mpl_toolkits.mplot3d import Axes3D\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy import stats\n\n\n# #############################################################################\n# Create the data\n\ne = np.exp(1)\nnp.random.seed(4)\n\n\ndef pdf(x):\n return 0.5 * (stats.norm(scale=0.25 / e).pdf(x)\n + stats.norm(scale=4 / e).pdf(x))\n\ny = np.random.normal(scale=0.5, size=(30000))\nx = np.random.normal(scale=0.5, size=(30000))\nz = np.random.normal(scale=0.1, size=len(x))\n\ndensity = pdf(x) * pdf(y)\npdf_z = pdf(5 * z)\n\ndensity *= pdf_z\n\na = x + y\nb = 2 * y\nc = a - b + z\n\nnorm = np.sqrt(a.var() + b.var())\na /= norm\nb /= norm\n\n\n# #############################################################################\n# Plot the figures\ndef plot_figs(fig_num, elev, azim):\n fig = plt.figure(fig_num, figsize=(4, 3))\n plt.clf()\n ax = Axes3D(fig, rect=[0, 0, .95, 1], elev=elev, azim=azim)\n\n ax.scatter(a[::10], b[::10], c[::10], c=density[::10], marker='+', alpha=.4)\n Y = np.c_[a, b, c]\n\n # Using SciPy's SVD, this would be:\n # _, pca_score, V = scipy.linalg.svd(Y, full_matrices=False)\n\n pca = PCA(n_components=3)\n pca.fit(Y)\n pca_score = pca.explained_variance_ratio_\n V = pca.components_\n\n x_pca_axis, y_pca_axis, z_pca_axis = 3 * V.T\n x_pca_plane = np.r_[x_pca_axis[:2], - x_pca_axis[1::-1]]\n y_pca_plane = np.r_[y_pca_axis[:2], - y_pca_axis[1::-1]]\n z_pca_plane = np.r_[z_pca_axis[:2], - z_pca_axis[1::-1]]\n x_pca_plane.shape = (2, 2)\n y_pca_plane.shape = (2, 2)\n z_pca_plane.shape = (2, 2)\n ax.plot_surface(x_pca_plane, y_pca_plane, z_pca_plane)\n ax.w_xaxis.set_ticklabels([])\n ax.w_yaxis.set_ticklabels([])\n ax.w_zaxis.set_ticklabels([])\n\n\nelev = -40\nazim = -80\nplot_figs(1, elev, azim)\n\nelev = 30\nazim = 20\nplot_figs(2, elev, azim)\n\nplt.show()"
29+
"print(__doc__)\n\n# Authors: Gael Varoquaux\n# Jaques Grobler\n# Kevin Hughes\n# License: BSD 3 clause\n\nfrom sklearn.decomposition import PCA\n\nfrom mpl_toolkits.mplot3d import Axes3D\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy import stats\n\n\n# #############################################################################\n# Create the data\n\ne = np.exp(1)\nnp.random.seed(4)\n\n\ndef pdf(x):\n return 0.5 * (stats.norm(scale=0.25 / e).pdf(x)\n + stats.norm(scale=4 / e).pdf(x))\n\ny = np.random.normal(scale=0.5, size=(30000))\nx = np.random.normal(scale=0.5, size=(30000))\nz = np.random.normal(scale=0.1, size=len(x))\n\ndensity = pdf(x) * pdf(y)\npdf_z = pdf(5 * z)\n\ndensity *= pdf_z\n\na = x + y\nb = 2 * y\nc = a - b + z\n\nnorm = np.sqrt(a.var() + b.var())\na /= norm\nb /= norm\n\n\n# #############################################################################\n# Plot the figures\ndef plot_figs(fig_num, elev, azim):\n fig = plt.figure(fig_num, figsize=(4, 3))\n plt.clf()\n ax = Axes3D(fig, rect=[0, 0, .95, 1], elev=elev, azim=azim)\n\n ax.scatter(a[::10], b[::10], c[::10], c=density[::10], marker='+', alpha=.4)\n Y = np.c_[a, b, c]\n\n # Using SciPy's SVD, this would be:\n # _, pca_score, Vt = scipy.linalg.svd(Y, full_matrices=False)\n\n pca = PCA(n_components=3)\n pca.fit(Y)\n V = pca.components_.T\n\n x_pca_axis, y_pca_axis, z_pca_axis = 3 * V\n x_pca_plane = np.r_[x_pca_axis[:2], - x_pca_axis[1::-1]]\n y_pca_plane = np.r_[y_pca_axis[:2], - y_pca_axis[1::-1]]\n z_pca_plane = np.r_[z_pca_axis[:2], - z_pca_axis[1::-1]]\n x_pca_plane.shape = (2, 2)\n y_pca_plane.shape = (2, 2)\n z_pca_plane.shape = (2, 2)\n ax.plot_surface(x_pca_plane, y_pca_plane, z_pca_plane)\n ax.w_xaxis.set_ticklabels([])\n ax.w_yaxis.set_ticklabels([])\n ax.w_zaxis.set_ticklabels([])\n\n\nelev = -40\nazim = -80\nplot_figs(1, elev, azim)\n\nelev = 30\nazim = 20\nplot_figs(2, elev, azim)\n\nplt.show()"
3030
]
3131
}
3232
],

dev/_downloads/b9aff1ce21730fc6838775c9db2aa099/plot_pca_3d.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,13 @@ def plot_figs(fig_num, elev, azim):
6666
Y = np.c_[a, b, c]
6767

6868
# Using SciPy's SVD, this would be:
69-
# _, pca_score, V = scipy.linalg.svd(Y, full_matrices=False)
69+
# _, pca_score, Vt = scipy.linalg.svd(Y, full_matrices=False)
7070

7171
pca = PCA(n_components=3)
7272
pca.fit(Y)
73-
pca_score = pca.explained_variance_ratio_
74-
V = pca.components_
73+
V = pca.components_.T
7574

76-
x_pca_axis, y_pca_axis, z_pca_axis = 3 * V.T
75+
x_pca_axis, y_pca_axis, z_pca_axis = 3 * V
7776
x_pca_plane = np.r_[x_pca_axis[:2], - x_pca_axis[1::-1]]
7877
y_pca_plane = np.r_[y_pca_axis[:2], - y_pca_axis[1::-1]]
7978
z_pca_plane = np.r_[z_pca_axis[:2], - z_pca_axis[1::-1]]
Binary file not shown.

dev/_downloads/scikit-learn-docs.pdf

841 Bytes
Binary file not shown.

dev/_images/iris.png

0 Bytes
573 Bytes
573 Bytes
567 Bytes
567 Bytes

0 commit comments

Comments
 (0)