Skip to content

Commit db95619

Browse files
committed
Pushing the docs to dev/ for branch: main, commit 974cd7739879ffa29c93276cbd1e46869d181545
1 parent b6afba7 commit db95619

File tree

1,227 files changed

+4442
-4442
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

+4442
-4442
lines changed
Binary file not shown.

dev/_downloads/53e76f761ef04e8d06fa5757554513b0/plot_select_from_model_diabetes.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
# ------------------------------------
3737
#
3838
# To get an idea of the importance of the features, we are going to use the
39-
# :class:`~sklearn.linear_model.LassoCV` estimator. The features with the
39+
# :class:`~sklearn.linear_model.RidgeCV` estimator. The features with the
4040
# highest absolute `coef_` value are considered the most important.
4141
# We can observe the coefficients directly without needing to scale them (or
4242
# scale the data) because from the description above, we know that the features
@@ -46,10 +46,10 @@
4646
# :ref:`sphx_glr_auto_examples_inspection_plot_linear_model_coefficient_interpretation.py`.
4747
import matplotlib.pyplot as plt
4848
import numpy as np
49-
from sklearn.linear_model import LassoCV
49+
from sklearn.linear_model import RidgeCV
5050

51-
lasso = LassoCV().fit(X, y)
52-
importance = np.abs(lasso.coef_)
51+
ridge = RidgeCV(alphas=np.logspace(-6, 6, num=5)).fit(X, y)
52+
importance = np.abs(ridge.coef_)
5353
feature_names = np.array(diabetes.feature_names)
5454
plt.bar(height=importance, x=feature_names)
5555
plt.title("Feature importances via coefficients")
@@ -73,7 +73,7 @@
7373
threshold = np.sort(importance)[-3] + 0.01
7474

7575
tic = time()
76-
sfm = SelectFromModel(lasso, threshold=threshold).fit(X, y)
76+
sfm = SelectFromModel(ridge, threshold=threshold).fit(X, y)
7777
toc = time()
7878
print(f"Features selected by SelectFromModel: {feature_names[sfm.get_support()]}")
7979
print(f"Done in {toc - tic:.3f}s")
@@ -98,13 +98,13 @@
9898

9999
tic_fwd = time()
100100
sfs_forward = SequentialFeatureSelector(
101-
lasso, n_features_to_select=2, direction="forward"
101+
ridge, n_features_to_select=2, direction="forward"
102102
).fit(X, y)
103103
toc_fwd = time()
104104

105105
tic_bwd = time()
106106
sfs_backward = SequentialFeatureSelector(
107-
lasso, n_features_to_select=2, direction="backward"
107+
ridge, n_features_to_select=2, direction="backward"
108108
).fit(X, y)
109109
toc_bwd = time()
110110

Binary file not shown.

dev/_downloads/f1e887db7b101f4c858db7db12e9c7e2/plot_select_from_model_diabetes.ipynb

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"cell_type": "markdown",
4141
"metadata": {},
4242
"source": [
43-
"## Feature importance from coefficients\n\nTo get an idea of the importance of the features, we are going to use the\n:class:`~sklearn.linear_model.LassoCV` estimator. The features with the\nhighest absolute `coef_` value are considered the most important.\nWe can observe the coefficients directly without needing to scale them (or\nscale the data) because from the description above, we know that the features\nwere already standardized.\nFor a more complete example on the interpretations of the coefficients of\nlinear models, you may refer to\n`sphx_glr_auto_examples_inspection_plot_linear_model_coefficient_interpretation.py`.\n\n"
43+
"## Feature importance from coefficients\n\nTo get an idea of the importance of the features, we are going to use the\n:class:`~sklearn.linear_model.RidgeCV` estimator. The features with the\nhighest absolute `coef_` value are considered the most important.\nWe can observe the coefficients directly without needing to scale them (or\nscale the data) because from the description above, we know that the features\nwere already standardized.\nFor a more complete example on the interpretations of the coefficients of\nlinear models, you may refer to\n`sphx_glr_auto_examples_inspection_plot_linear_model_coefficient_interpretation.py`.\n\n"
4444
]
4545
},
4646
{
@@ -51,7 +51,7 @@
5151
},
5252
"outputs": [],
5353
"source": [
54-
"import matplotlib.pyplot as plt\nimport numpy as np\nfrom sklearn.linear_model import LassoCV\n\nlasso = LassoCV().fit(X, y)\nimportance = np.abs(lasso.coef_)\nfeature_names = np.array(diabetes.feature_names)\nplt.bar(height=importance, x=feature_names)\nplt.title(\"Feature importances via coefficients\")\nplt.show()"
54+
"import matplotlib.pyplot as plt\nimport numpy as np\nfrom sklearn.linear_model import RidgeCV\n\nridge = RidgeCV(alphas=np.logspace(-6, 6, num=5)).fit(X, y)\nimportance = np.abs(ridge.coef_)\nfeature_names = np.array(diabetes.feature_names)\nplt.bar(height=importance, x=feature_names)\nplt.title(\"Feature importances via coefficients\")\nplt.show()"
5555
]
5656
},
5757
{
@@ -69,7 +69,7 @@
6969
},
7070
"outputs": [],
7171
"source": [
72-
"from sklearn.feature_selection import SelectFromModel\nfrom time import time\n\nthreshold = np.sort(importance)[-3] + 0.01\n\ntic = time()\nsfm = SelectFromModel(lasso, threshold=threshold).fit(X, y)\ntoc = time()\nprint(f\"Features selected by SelectFromModel: {feature_names[sfm.get_support()]}\")\nprint(f\"Done in {toc - tic:.3f}s\")"
72+
"from sklearn.feature_selection import SelectFromModel\nfrom time import time\n\nthreshold = np.sort(importance)[-3] + 0.01\n\ntic = time()\nsfm = SelectFromModel(ridge, threshold=threshold).fit(X, y)\ntoc = time()\nprint(f\"Features selected by SelectFromModel: {feature_names[sfm.get_support()]}\")\nprint(f\"Done in {toc - tic:.3f}s\")"
7373
]
7474
},
7575
{
@@ -87,7 +87,7 @@
8787
},
8888
"outputs": [],
8989
"source": [
90-
"from sklearn.feature_selection import SequentialFeatureSelector\n\ntic_fwd = time()\nsfs_forward = SequentialFeatureSelector(\n lasso, n_features_to_select=2, direction=\"forward\"\n).fit(X, y)\ntoc_fwd = time()\n\ntic_bwd = time()\nsfs_backward = SequentialFeatureSelector(\n lasso, n_features_to_select=2, direction=\"backward\"\n).fit(X, y)\ntoc_bwd = time()\n\nprint(\n \"Features selected by forward sequential selection: \"\n f\"{feature_names[sfs_forward.get_support()]}\"\n)\nprint(f\"Done in {toc_fwd - tic_fwd:.3f}s\")\nprint(\n \"Features selected by backward sequential selection: \"\n f\"{feature_names[sfs_backward.get_support()]}\"\n)\nprint(f\"Done in {toc_bwd - tic_bwd:.3f}s\")"
90+
"from sklearn.feature_selection import SequentialFeatureSelector\n\ntic_fwd = time()\nsfs_forward = SequentialFeatureSelector(\n ridge, n_features_to_select=2, direction=\"forward\"\n).fit(X, y)\ntoc_fwd = time()\n\ntic_bwd = time()\nsfs_backward = SequentialFeatureSelector(\n ridge, n_features_to_select=2, direction=\"backward\"\n).fit(X, y)\ntoc_bwd = time()\n\nprint(\n \"Features selected by forward sequential selection: \"\n f\"{feature_names[sfs_forward.get_support()]}\"\n)\nprint(f\"Done in {toc_fwd - tic_fwd:.3f}s\")\nprint(\n \"Features selected by backward sequential selection: \"\n f\"{feature_names[sfs_backward.get_support()]}\"\n)\nprint(f\"Done in {toc_bwd - tic_bwd:.3f}s\")"
9191
]
9292
},
9393
{

dev/_downloads/scikit-learn-docs.zip

16.3 KB
Binary file not shown.
-21 Bytes
132 Bytes
129 Bytes
350 Bytes
-109 Bytes
-11 Bytes
-41 Bytes
-12 Bytes
-19 Bytes
110 Bytes
175 Bytes
-108 Bytes
1.52 KB
610 Bytes
-1 Bytes
-78 Bytes
36 Bytes
1 Byte
10 Bytes

dev/_sources/auto_examples/applications/plot_cyclical_feature_engineering.rst.txt

+1-1

dev/_sources/auto_examples/applications/plot_digits_denoising.rst.txt

+1-1

dev/_sources/auto_examples/applications/plot_face_recognition.rst.txt

+5-5

dev/_sources/auto_examples/applications/plot_model_complexity_influence.rst.txt

+15-15

0 commit comments

Comments
 (0)