Skip to content

Commit 6cbb938

Browse files
committed
Pushing the docs to dev/ for branch: main, commit efede4b1864492c18238f60ffc39e9729672382c
1 parent 5a40d17 commit 6cbb938

File tree

1,217 files changed

+4091
-4082
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,217 files changed

+4091
-4082
lines changed
Binary file not shown.

dev/_downloads/1f682002d8b68c290d9d03599368e83d/plot_lasso_coordinate_descent_path.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,59 +31,59 @@
3131
eps = 5e-3 # the smaller it is the longer is the path
3232

3333
print("Computing regularization path using the lasso...")
34-
alphas_lasso, coefs_lasso, _ = lasso_path(X, y, eps=eps, fit_intercept=False)
34+
alphas_lasso, coefs_lasso, _ = lasso_path(X, y, eps=eps)
3535

3636
print("Computing regularization path using the positive lasso...")
3737
alphas_positive_lasso, coefs_positive_lasso, _ = lasso_path(
38-
X, y, eps=eps, positive=True, fit_intercept=False)
38+
X, y, eps=eps, positive=True
39+
)
3940
print("Computing regularization path using the elastic net...")
40-
alphas_enet, coefs_enet, _ = enet_path(
41-
X, y, eps=eps, l1_ratio=0.8, fit_intercept=False)
41+
alphas_enet, coefs_enet, _ = enet_path(X, y, eps=eps, l1_ratio=0.8)
4242

4343
print("Computing regularization path using the positive elastic net...")
4444
alphas_positive_enet, coefs_positive_enet, _ = enet_path(
45-
X, y, eps=eps, l1_ratio=0.8, positive=True, fit_intercept=False)
45+
X, y, eps=eps, l1_ratio=0.8, positive=True
46+
)
4647

4748
# Display results
4849

4950
plt.figure(1)
50-
colors = cycle(['b', 'r', 'g', 'c', 'k'])
51+
colors = cycle(["b", "r", "g", "c", "k"])
5152
neg_log_alphas_lasso = -np.log10(alphas_lasso)
5253
neg_log_alphas_enet = -np.log10(alphas_enet)
5354
for coef_l, coef_e, c in zip(coefs_lasso, coefs_enet, colors):
5455
l1 = plt.plot(neg_log_alphas_lasso, coef_l, c=c)
55-
l2 = plt.plot(neg_log_alphas_enet, coef_e, linestyle='--', c=c)
56+
l2 = plt.plot(neg_log_alphas_enet, coef_e, linestyle="--", c=c)
5657

57-
plt.xlabel('-Log(alpha)')
58-
plt.ylabel('coefficients')
59-
plt.title('Lasso and Elastic-Net Paths')
60-
plt.legend((l1[-1], l2[-1]), ('Lasso', 'Elastic-Net'), loc='lower left')
61-
plt.axis('tight')
58+
plt.xlabel("-Log(alpha)")
59+
plt.ylabel("coefficients")
60+
plt.title("Lasso and Elastic-Net Paths")
61+
plt.legend((l1[-1], l2[-1]), ("Lasso", "Elastic-Net"), loc="lower left")
62+
plt.axis("tight")
6263

6364

6465
plt.figure(2)
6566
neg_log_alphas_positive_lasso = -np.log10(alphas_positive_lasso)
6667
for coef_l, coef_pl, c in zip(coefs_lasso, coefs_positive_lasso, colors):
6768
l1 = plt.plot(neg_log_alphas_lasso, coef_l, c=c)
68-
l2 = plt.plot(neg_log_alphas_positive_lasso, coef_pl, linestyle='--', c=c)
69+
l2 = plt.plot(neg_log_alphas_positive_lasso, coef_pl, linestyle="--", c=c)
6970

70-
plt.xlabel('-Log(alpha)')
71-
plt.ylabel('coefficients')
72-
plt.title('Lasso and positive Lasso')
73-
plt.legend((l1[-1], l2[-1]), ('Lasso', 'positive Lasso'), loc='lower left')
74-
plt.axis('tight')
71+
plt.xlabel("-Log(alpha)")
72+
plt.ylabel("coefficients")
73+
plt.title("Lasso and positive Lasso")
74+
plt.legend((l1[-1], l2[-1]), ("Lasso", "positive Lasso"), loc="lower left")
75+
plt.axis("tight")
7576

7677

7778
plt.figure(3)
7879
neg_log_alphas_positive_enet = -np.log10(alphas_positive_enet)
7980
for (coef_e, coef_pe, c) in zip(coefs_enet, coefs_positive_enet, colors):
8081
l1 = plt.plot(neg_log_alphas_enet, coef_e, c=c)
81-
l2 = plt.plot(neg_log_alphas_positive_enet, coef_pe, linestyle='--', c=c)
82-
83-
plt.xlabel('-Log(alpha)')
84-
plt.ylabel('coefficients')
85-
plt.title('Elastic-Net and positive Elastic-Net')
86-
plt.legend((l1[-1], l2[-1]), ('Elastic-Net', 'positive Elastic-Net'),
87-
loc='lower left')
88-
plt.axis('tight')
82+
l2 = plt.plot(neg_log_alphas_positive_enet, coef_pe, linestyle="--", c=c)
83+
84+
plt.xlabel("-Log(alpha)")
85+
plt.ylabel("coefficients")
86+
plt.title("Elastic-Net and positive Elastic-Net")
87+
plt.legend((l1[-1], l2[-1]), ("Elastic-Net", "positive Elastic-Net"), loc="lower left")
88+
plt.axis("tight")
8989
plt.show()

dev/_downloads/4c4c075dc14e39d30d982d0b2818ea95/plot_lasso_coordinate_descent_path.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# Author: Alexandre Gramfort <[email protected]>\n# License: BSD 3 clause\n\nfrom itertools import cycle\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom sklearn.linear_model import lasso_path, enet_path\nfrom sklearn import datasets\n\n\nX, y = datasets.load_diabetes(return_X_y=True)\n\n\nX /= X.std(axis=0) # Standardize data (easier to set the l1_ratio parameter)\n\n# Compute paths\n\neps = 5e-3 # the smaller it is the longer is the path\n\nprint(\"Computing regularization path using the lasso...\")\nalphas_lasso, coefs_lasso, _ = lasso_path(X, y, eps=eps, fit_intercept=False)\n\nprint(\"Computing regularization path using the positive lasso...\")\nalphas_positive_lasso, coefs_positive_lasso, _ = lasso_path(\n X, y, eps=eps, positive=True, fit_intercept=False)\nprint(\"Computing regularization path using the elastic net...\")\nalphas_enet, coefs_enet, _ = enet_path(\n X, y, eps=eps, l1_ratio=0.8, fit_intercept=False)\n\nprint(\"Computing regularization path using the positive elastic net...\")\nalphas_positive_enet, coefs_positive_enet, _ = enet_path(\n X, y, eps=eps, l1_ratio=0.8, positive=True, fit_intercept=False)\n\n# Display results\n\nplt.figure(1)\ncolors = cycle(['b', 'r', 'g', 'c', 'k'])\nneg_log_alphas_lasso = -np.log10(alphas_lasso)\nneg_log_alphas_enet = -np.log10(alphas_enet)\nfor coef_l, coef_e, c in zip(coefs_lasso, coefs_enet, colors):\n l1 = plt.plot(neg_log_alphas_lasso, coef_l, c=c)\n l2 = plt.plot(neg_log_alphas_enet, coef_e, linestyle='--', c=c)\n\nplt.xlabel('-Log(alpha)')\nplt.ylabel('coefficients')\nplt.title('Lasso and Elastic-Net Paths')\nplt.legend((l1[-1], l2[-1]), ('Lasso', 'Elastic-Net'), loc='lower left')\nplt.axis('tight')\n\n\nplt.figure(2)\nneg_log_alphas_positive_lasso = -np.log10(alphas_positive_lasso)\nfor coef_l, coef_pl, c in zip(coefs_lasso, coefs_positive_lasso, colors):\n l1 = plt.plot(neg_log_alphas_lasso, coef_l, c=c)\n l2 = plt.plot(neg_log_alphas_positive_lasso, coef_pl, linestyle='--', c=c)\n\nplt.xlabel('-Log(alpha)')\nplt.ylabel('coefficients')\nplt.title('Lasso and positive Lasso')\nplt.legend((l1[-1], l2[-1]), ('Lasso', 'positive Lasso'), loc='lower left')\nplt.axis('tight')\n\n\nplt.figure(3)\nneg_log_alphas_positive_enet = -np.log10(alphas_positive_enet)\nfor (coef_e, coef_pe, c) in zip(coefs_enet, coefs_positive_enet, colors):\n l1 = plt.plot(neg_log_alphas_enet, coef_e, c=c)\n l2 = plt.plot(neg_log_alphas_positive_enet, coef_pe, linestyle='--', c=c)\n\nplt.xlabel('-Log(alpha)')\nplt.ylabel('coefficients')\nplt.title('Elastic-Net and positive Elastic-Net')\nplt.legend((l1[-1], l2[-1]), ('Elastic-Net', 'positive Elastic-Net'),\n loc='lower left')\nplt.axis('tight')\nplt.show()"
29+
"print(__doc__)\n\n# Author: Alexandre Gramfort <[email protected]>\n# License: BSD 3 clause\n\nfrom itertools import cycle\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nfrom sklearn.linear_model import lasso_path, enet_path\nfrom sklearn import datasets\n\n\nX, y = datasets.load_diabetes(return_X_y=True)\n\n\nX /= X.std(axis=0) # Standardize data (easier to set the l1_ratio parameter)\n\n# Compute paths\n\neps = 5e-3 # the smaller it is the longer is the path\n\nprint(\"Computing regularization path using the lasso...\")\nalphas_lasso, coefs_lasso, _ = lasso_path(X, y, eps=eps)\n\nprint(\"Computing regularization path using the positive lasso...\")\nalphas_positive_lasso, coefs_positive_lasso, _ = lasso_path(\n X, y, eps=eps, positive=True\n)\nprint(\"Computing regularization path using the elastic net...\")\nalphas_enet, coefs_enet, _ = enet_path(X, y, eps=eps, l1_ratio=0.8)\n\nprint(\"Computing regularization path using the positive elastic net...\")\nalphas_positive_enet, coefs_positive_enet, _ = enet_path(\n X, y, eps=eps, l1_ratio=0.8, positive=True\n)\n\n# Display results\n\nplt.figure(1)\ncolors = cycle([\"b\", \"r\", \"g\", \"c\", \"k\"])\nneg_log_alphas_lasso = -np.log10(alphas_lasso)\nneg_log_alphas_enet = -np.log10(alphas_enet)\nfor coef_l, coef_e, c in zip(coefs_lasso, coefs_enet, colors):\n l1 = plt.plot(neg_log_alphas_lasso, coef_l, c=c)\n l2 = plt.plot(neg_log_alphas_enet, coef_e, linestyle=\"--\", c=c)\n\nplt.xlabel(\"-Log(alpha)\")\nplt.ylabel(\"coefficients\")\nplt.title(\"Lasso and Elastic-Net Paths\")\nplt.legend((l1[-1], l2[-1]), (\"Lasso\", \"Elastic-Net\"), loc=\"lower left\")\nplt.axis(\"tight\")\n\n\nplt.figure(2)\nneg_log_alphas_positive_lasso = -np.log10(alphas_positive_lasso)\nfor coef_l, coef_pl, c in zip(coefs_lasso, coefs_positive_lasso, colors):\n l1 = plt.plot(neg_log_alphas_lasso, coef_l, c=c)\n l2 = plt.plot(neg_log_alphas_positive_lasso, coef_pl, linestyle=\"--\", c=c)\n\nplt.xlabel(\"-Log(alpha)\")\nplt.ylabel(\"coefficients\")\nplt.title(\"Lasso and positive Lasso\")\nplt.legend((l1[-1], l2[-1]), (\"Lasso\", \"positive Lasso\"), loc=\"lower left\")\nplt.axis(\"tight\")\n\n\nplt.figure(3)\nneg_log_alphas_positive_enet = -np.log10(alphas_positive_enet)\nfor (coef_e, coef_pe, c) in zip(coefs_enet, coefs_positive_enet, colors):\n l1 = plt.plot(neg_log_alphas_enet, coef_e, c=c)\n l2 = plt.plot(neg_log_alphas_positive_enet, coef_pe, linestyle=\"--\", c=c)\n\nplt.xlabel(\"-Log(alpha)\")\nplt.ylabel(\"coefficients\")\nplt.title(\"Elastic-Net and positive Elastic-Net\")\nplt.legend((l1[-1], l2[-1]), (\"Elastic-Net\", \"positive Elastic-Net\"), loc=\"lower left\")\nplt.axis(\"tight\")\nplt.show()"
3030
]
3131
}
3232
],
Binary file not shown.

dev/_downloads/scikit-learn-docs.zip

7.02 KB
Binary file not shown.
81 Bytes
220 Bytes
-167 Bytes
106 Bytes
28 Bytes

0 commit comments

Comments
 (0)