Skip to content

Commit a19f19a

Browse files
committed
Pushing the docs to dev/ for branch: main, commit c26000ed263c4c85b0959ec384d2ead3cf39e113
1 parent 2522c5e commit a19f19a

File tree

1,227 files changed

+4351
-4243
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

+4351
-4243
lines changed
Binary file not shown.

dev/_downloads/6caa16249d07b4f3e57d5f3bf102b137/plot_ridge_path.ipynb

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,43 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"# Author: Fabian Pedregosa -- <[email protected]>\n# License: BSD 3 clause\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn import linear_model\n\n# X is the 10x10 Hilbert matrix\nX = 1.0 / (np.arange(1, 11) + np.arange(0, 10)[:, np.newaxis])\ny = np.ones(10)\n\n# #############################################################################\n# Compute paths\n\nn_alphas = 200\nalphas = np.logspace(-10, -2, n_alphas)\n\ncoefs = []\nfor a in alphas:\n ridge = linear_model.Ridge(alpha=a, fit_intercept=False)\n ridge.fit(X, y)\n coefs.append(ridge.coef_)\n\n# #############################################################################\n# Display results\n\nax = plt.gca()\n\nax.plot(alphas, coefs)\nax.set_xscale(\"log\")\nax.set_xlim(ax.get_xlim()[::-1]) # reverse axis\nplt.xlabel(\"alpha\")\nplt.ylabel(\"weights\")\nplt.title(\"Ridge coefficients as a function of the regularization\")\nplt.axis(\"tight\")\nplt.show()"
29+
"# Author: Fabian Pedregosa -- <[email protected]>\n# License: BSD 3 clause\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn import linear_model\n\n# X is the 10x10 Hilbert matrix\nX = 1.0 / (np.arange(1, 11) + np.arange(0, 10)[:, np.newaxis])\ny = np.ones(10)"
30+
]
31+
},
32+
{
33+
"cell_type": "markdown",
34+
"metadata": {},
35+
"source": [
36+
"## Compute paths\n\n"
37+
]
38+
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": null,
42+
"metadata": {
43+
"collapsed": false
44+
},
45+
"outputs": [],
46+
"source": [
47+
"n_alphas = 200\nalphas = np.logspace(-10, -2, n_alphas)\n\ncoefs = []\nfor a in alphas:\n ridge = linear_model.Ridge(alpha=a, fit_intercept=False)\n ridge.fit(X, y)\n coefs.append(ridge.coef_)"
48+
]
49+
},
50+
{
51+
"cell_type": "markdown",
52+
"metadata": {},
53+
"source": [
54+
"## Display results\n\n"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": null,
60+
"metadata": {
61+
"collapsed": false
62+
},
63+
"outputs": [],
64+
"source": [
65+
"ax = plt.gca()\n\nax.plot(alphas, coefs)\nax.set_xscale(\"log\")\nax.set_xlim(ax.get_xlim()[::-1]) # reverse axis\nplt.xlabel(\"alpha\")\nplt.ylabel(\"weights\")\nplt.title(\"Ridge coefficients as a function of the regularization\")\nplt.axis(\"tight\")\nplt.show()"
3066
]
3167
}
3268
],
Binary file not shown.

dev/_downloads/9d5a4167bc60f250de65fe21497c1eb6/plot_ridge_path.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@
3838
X = 1.0 / (np.arange(1, 11) + np.arange(0, 10)[:, np.newaxis])
3939
y = np.ones(10)
4040

41-
# #############################################################################
41+
# %%
4242
# Compute paths
43+
# -------------
4344

4445
n_alphas = 200
4546
alphas = np.logspace(-10, -2, n_alphas)
@@ -50,8 +51,9 @@
5051
ridge.fit(X, y)
5152
coefs.append(ridge.coef_)
5253

53-
# #############################################################################
54+
# %%
5455
# Display results
56+
# ---------------
5557

5658
ax = plt.gca()
5759

dev/_downloads/scikit-learn-docs.zip

16.6 KB
Binary file not shown.
-27 Bytes
-42 Bytes
-16 Bytes
59 Bytes
14 Bytes

0 commit comments

Comments
 (0)