Skip to content

Commit 4728483

Browse files
committed
Pushing the docs to dev/ for branch: master, commit 546c42d3a06eceb34c577dd8babc191571b74b87
1 parent 484e2d3 commit 4728483

File tree

1,205 files changed

+3725
-3716
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,205 files changed

+3725
-3716
lines changed

dev/_downloads/011c2aab5cd3d93243e79f99b7fbad5d/plot_digits_pipe.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242

4343
# Parameters of pipelines can be set using ‘__’ separated parameter names:
4444
param_grid = {
45-
'pca__n_components': [5, 20, 30, 40, 50, 64],
46-
'logistic__C': np.logspace(-4, 4, 5),
45+
'pca__n_components': [5, 15, 30, 45, 64],
46+
'logistic__C': np.logspace(-4, 4, 4),
4747
}
4848
search = GridSearchCV(pipe, param_grid, n_jobs=-1)
4949
search.fit(X_digits, y_digits)
@@ -54,8 +54,9 @@
5454
pca.fit(X_digits)
5555

5656
fig, (ax0, ax1) = plt.subplots(nrows=2, sharex=True, figsize=(6, 6))
57-
ax0.plot(pca.explained_variance_ratio_, linewidth=2)
58-
ax0.set_ylabel('PCA explained variance')
57+
ax0.plot(np.arange(1, pca.n_components_ + 1),
58+
pca.explained_variance_ratio_, '+', linewidth=2)
59+
ax0.set_ylabel('PCA explained variance ratio')
5960

6061
ax0.axvline(search.best_estimator_.named_steps['pca'].n_components,
6162
linestyle=':', label='n_components chosen')
@@ -72,5 +73,7 @@
7273
ax1.set_ylabel('Classification accuracy (val)')
7374
ax1.set_xlabel('n_components')
7475

76+
plt.xlim(-1, 70)
77+
7578
plt.tight_layout()
7679
plt.show()
Binary file not shown.

dev/_downloads/5e9406fab7c5aff29fd9e6fe349eac25/plot_digits_pipe.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\n# Code source: Ga\u00ebl Varoquaux\n# Modified for documentation by Jaques Grobler\n# License: BSD 3 clause\n\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport pandas as pd\n\nfrom sklearn import datasets\nfrom sklearn.decomposition import PCA\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.pipeline import Pipeline\nfrom sklearn.model_selection import GridSearchCV\n\n\n# Define a pipeline to search for the best combination of PCA truncation\n# and classifier regularization.\npca = PCA()\n# set the tolerance to a large value to make the example faster\nlogistic = LogisticRegression(max_iter=10000, tol=0.1)\npipe = Pipeline(steps=[('pca', pca), ('logistic', logistic)])\n\nX_digits, y_digits = datasets.load_digits(return_X_y=True)\n\n# Parameters of pipelines can be set using \u2018__\u2019 separated parameter names:\nparam_grid = {\n 'pca__n_components': [5, 20, 30, 40, 50, 64],\n 'logistic__C': np.logspace(-4, 4, 5),\n}\nsearch = GridSearchCV(pipe, param_grid, n_jobs=-1)\nsearch.fit(X_digits, y_digits)\nprint(\"Best parameter (CV score=%0.3f):\" % search.best_score_)\nprint(search.best_params_)\n\n# Plot the PCA spectrum\npca.fit(X_digits)\n\nfig, (ax0, ax1) = plt.subplots(nrows=2, sharex=True, figsize=(6, 6))\nax0.plot(pca.explained_variance_ratio_, linewidth=2)\nax0.set_ylabel('PCA explained variance')\n\nax0.axvline(search.best_estimator_.named_steps['pca'].n_components,\n linestyle=':', label='n_components chosen')\nax0.legend(prop=dict(size=12))\n\n# For each number of components, find the best classifier results\nresults = pd.DataFrame(search.cv_results_)\ncomponents_col = 'param_pca__n_components'\nbest_clfs = results.groupby(components_col).apply(\n lambda g: g.nlargest(1, 'mean_test_score'))\n\nbest_clfs.plot(x=components_col, y='mean_test_score', yerr='std_test_score',\n legend=False, ax=ax1)\nax1.set_ylabel('Classification accuracy (val)')\nax1.set_xlabel('n_components')\n\nplt.tight_layout()\nplt.show()"
29+
"print(__doc__)\n\n\n# Code source: Ga\u00ebl Varoquaux\n# Modified for documentation by Jaques Grobler\n# License: BSD 3 clause\n\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport pandas as pd\n\nfrom sklearn import datasets\nfrom sklearn.decomposition import PCA\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.pipeline import Pipeline\nfrom sklearn.model_selection import GridSearchCV\n\n\n# Define a pipeline to search for the best combination of PCA truncation\n# and classifier regularization.\npca = PCA()\n# set the tolerance to a large value to make the example faster\nlogistic = LogisticRegression(max_iter=10000, tol=0.1)\npipe = Pipeline(steps=[('pca', pca), ('logistic', logistic)])\n\nX_digits, y_digits = datasets.load_digits(return_X_y=True)\n\n# Parameters of pipelines can be set using \u2018__\u2019 separated parameter names:\nparam_grid = {\n 'pca__n_components': [5, 15, 30, 45, 64],\n 'logistic__C': np.logspace(-4, 4, 4),\n}\nsearch = GridSearchCV(pipe, param_grid, n_jobs=-1)\nsearch.fit(X_digits, y_digits)\nprint(\"Best parameter (CV score=%0.3f):\" % search.best_score_)\nprint(search.best_params_)\n\n# Plot the PCA spectrum\npca.fit(X_digits)\n\nfig, (ax0, ax1) = plt.subplots(nrows=2, sharex=True, figsize=(6, 6))\nax0.plot(np.arange(1, pca.n_components_ + 1),\n pca.explained_variance_ratio_, '+', linewidth=2)\nax0.set_ylabel('PCA explained variance ratio')\n\nax0.axvline(search.best_estimator_.named_steps['pca'].n_components,\n linestyle=':', label='n_components chosen')\nax0.legend(prop=dict(size=12))\n\n# For each number of components, find the best classifier results\nresults = pd.DataFrame(search.cv_results_)\ncomponents_col = 'param_pca__n_components'\nbest_clfs = results.groupby(components_col).apply(\n lambda g: g.nlargest(1, 'mean_test_score'))\n\nbest_clfs.plot(x=components_col, y='mean_test_score', yerr='std_test_score',\n legend=False, ax=ax1)\nax1.set_ylabel('Classification accuracy (val)')\nax1.set_xlabel('n_components')\n\nplt.xlim(-1, 70)\n\nplt.tight_layout()\nplt.show()"
3030
]
3131
}
3232
],
Binary file not shown.

dev/_downloads/scikit-learn-docs.pdf

6.71 KB
Binary file not shown.

dev/_images/iris.png

0 Bytes
684 Bytes
684 Bytes
-197 Bytes
-197 Bytes

0 commit comments

Comments
 (0)