Skip to content

Commit 15cd69a

Browse files
committed
Pushing the docs to dev/ for branch: main, commit 13a179113a61573c45b3e657f1f74f9b106b3f7f
1 parent 3852ac9 commit 15cd69a

File tree

1,267 files changed

+6199
-6106
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,267 files changed

+6199
-6106
lines changed
Binary file not shown.

Diff for: dev/_downloads/4941b506cc56c9cec00d40992e2a4207/plot_permutation_importance_multicollinear.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"outputs": [],
2424
"source": [
25-
"from sklearn.inspection import permutation_importance\n\n\ndef plot_permutation_importance(clf, X, y, ax):\n result = permutation_importance(clf, X, y, n_repeats=10, random_state=42, n_jobs=2)\n perm_sorted_idx = result.importances_mean.argsort()\n\n ax.boxplot(\n result.importances[perm_sorted_idx].T,\n vert=False,\n labels=X.columns[perm_sorted_idx],\n )\n ax.axvline(x=0, color=\"k\", linestyle=\"--\")\n return ax"
25+
"import matplotlib\n\nfrom sklearn.inspection import permutation_importance\nfrom sklearn.utils.fixes import parse_version\n\n\ndef plot_permutation_importance(clf, X, y, ax):\n result = permutation_importance(clf, X, y, n_repeats=10, random_state=42, n_jobs=2)\n perm_sorted_idx = result.importances_mean.argsort()\n\n # `labels` argument in boxplot is deprecated in matplotlib 3.9 and has been\n # renamed to `tick_labels`. The following code handles this, but as a\n # scikit-learn user you probably can write simpler code by using `labels=...`\n # (matplotlib < 3.9) or `tick_labels=...` (matplotlib >= 3.9).\n tick_labels_parameter_name = (\n \"tick_labels\"\n if parse_version(matplotlib.__version__) >= parse_version(\"3.9\")\n else \"labels\"\n )\n tick_labels_dict = {tick_labels_parameter_name: X.columns[perm_sorted_idx]}\n ax.boxplot(result.importances[perm_sorted_idx].T, vert=False, **tick_labels_dict)\n ax.axvline(x=0, color=\"k\", linestyle=\"--\")\n return ax"
2626
]
2727
},
2828
{

Diff for: dev/_downloads/50040ae12dd16e7d2e79135d7793c17e/plot_release_highlights_0_22_0.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
# `plot_confusion_matrix`. Read more about this new API in the
3535
# :ref:`User Guide <visualizations>`.
3636

37+
import matplotlib
3738
import matplotlib.pyplot as plt
3839

3940
from sklearn.datasets import make_classification
@@ -43,6 +44,7 @@
4344
from sklearn.metrics import RocCurveDisplay
4445
from sklearn.model_selection import train_test_split
4546
from sklearn.svm import SVC
47+
from sklearn.utils.fixes import parse_version
4648

4749
X, y = make_classification(random_state=0)
4850
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
@@ -117,9 +119,18 @@
117119

118120
fig, ax = plt.subplots()
119121
sorted_idx = result.importances_mean.argsort()
120-
ax.boxplot(
121-
result.importances[sorted_idx].T, vert=False, labels=feature_names[sorted_idx]
122+
123+
# `labels` argument in boxplot is deprecated in matplotlib 3.9 and has been
124+
# renamed to `tick_labels`. The following code handles this, but as a
125+
# scikit-learn user you probably can write simpler code by using `labels=...`
126+
# (matplotlib < 3.9) or `tick_labels=...` (matplotlib >= 3.9).
127+
tick_labels_parameter_name = (
128+
"tick_labels"
129+
if parse_version(matplotlib.__version__) >= parse_version("3.9")
130+
else "labels"
122131
)
132+
tick_labels_dict = {tick_labels_parameter_name: feature_names[sorted_idx]}
133+
ax.boxplot(result.importances[sorted_idx].T, vert=False, **tick_labels_dict)
123134
ax.set_title("Permutation Importance of each feature")
124135
ax.set_ylabel("Features")
125136
fig.tight_layout()
Binary file not shown.

Diff for: dev/_downloads/756be88c4ccd4c7bba02ab13f0d3258a/plot_permutation_importance_multicollinear.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,27 @@
2626
# ------------------------------------------------------
2727
#
2828
# First, we define a function to ease the plotting:
29+
import matplotlib
30+
2931
from sklearn.inspection import permutation_importance
32+
from sklearn.utils.fixes import parse_version
3033

3134

3235
def plot_permutation_importance(clf, X, y, ax):
3336
result = permutation_importance(clf, X, y, n_repeats=10, random_state=42, n_jobs=2)
3437
perm_sorted_idx = result.importances_mean.argsort()
3538

36-
ax.boxplot(
37-
result.importances[perm_sorted_idx].T,
38-
vert=False,
39-
labels=X.columns[perm_sorted_idx],
39+
# `labels` argument in boxplot is deprecated in matplotlib 3.9 and has been
40+
# renamed to `tick_labels`. The following code handles this, but as a
41+
# scikit-learn user you probably can write simpler code by using `labels=...`
42+
# (matplotlib < 3.9) or `tick_labels=...` (matplotlib >= 3.9).
43+
tick_labels_parameter_name = (
44+
"tick_labels"
45+
if parse_version(matplotlib.__version__) >= parse_version("3.9")
46+
else "labels"
4047
)
48+
tick_labels_dict = {tick_labels_parameter_name: X.columns[perm_sorted_idx]}
49+
ax.boxplot(result.importances[perm_sorted_idx].T, vert=False, **tick_labels_dict)
4150
ax.axvline(x=0, color="k", linestyle="--")
4251
return ax
4352

Diff for: dev/_downloads/c536eb92f539255e80e2b3ef5200e7a1/plot_gradient_boosting_regression.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"outputs": [],
1717
"source": [
18-
"# Authors: The scikit-learn developers\n# SPDX-License-Identifier: BSD-3-Clause\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nfrom sklearn import datasets, ensemble\nfrom sklearn.inspection import permutation_importance\nfrom sklearn.metrics import mean_squared_error\nfrom sklearn.model_selection import train_test_split"
18+
"# Authors: The scikit-learn developers\n# SPDX-License-Identifier: BSD-3-Clause\n\nimport matplotlib\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nfrom sklearn import datasets, ensemble\nfrom sklearn.inspection import permutation_importance\nfrom sklearn.metrics import mean_squared_error\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.utils.fixes import parse_version"
1919
]
2020
},
2121
{
@@ -105,7 +105,7 @@
105105
},
106106
"outputs": [],
107107
"source": [
108-
"feature_importance = reg.feature_importances_\nsorted_idx = np.argsort(feature_importance)\npos = np.arange(sorted_idx.shape[0]) + 0.5\nfig = plt.figure(figsize=(12, 6))\nplt.subplot(1, 2, 1)\nplt.barh(pos, feature_importance[sorted_idx], align=\"center\")\nplt.yticks(pos, np.array(diabetes.feature_names)[sorted_idx])\nplt.title(\"Feature Importance (MDI)\")\n\nresult = permutation_importance(\n reg, X_test, y_test, n_repeats=10, random_state=42, n_jobs=2\n)\nsorted_idx = result.importances_mean.argsort()\nplt.subplot(1, 2, 2)\nplt.boxplot(\n result.importances[sorted_idx].T,\n vert=False,\n labels=np.array(diabetes.feature_names)[sorted_idx],\n)\nplt.title(\"Permutation Importance (test set)\")\nfig.tight_layout()\nplt.show()"
108+
"feature_importance = reg.feature_importances_\nsorted_idx = np.argsort(feature_importance)\npos = np.arange(sorted_idx.shape[0]) + 0.5\nfig = plt.figure(figsize=(12, 6))\nplt.subplot(1, 2, 1)\nplt.barh(pos, feature_importance[sorted_idx], align=\"center\")\nplt.yticks(pos, np.array(diabetes.feature_names)[sorted_idx])\nplt.title(\"Feature Importance (MDI)\")\n\nresult = permutation_importance(\n reg, X_test, y_test, n_repeats=10, random_state=42, n_jobs=2\n)\nsorted_idx = result.importances_mean.argsort()\nplt.subplot(1, 2, 2)\n\n# `labels` argument in boxplot is deprecated in matplotlib 3.9 and has been\n# renamed to `tick_labels`. The following code handles this, but as a\n# scikit-learn user you probably can write simpler code by using `labels=...`\n# (matplotlib < 3.9) or `tick_labels=...` (matplotlib >= 3.9).\ntick_labels_parameter_name = (\n \"tick_labels\"\n if parse_version(matplotlib.__version__) >= parse_version(\"3.9\")\n else \"labels\"\n)\ntick_labels_dict = {\n tick_labels_parameter_name: np.array(diabetes.feature_names)[sorted_idx]\n}\nplt.boxplot(result.importances[sorted_idx].T, vert=False, **tick_labels_dict)\nplt.title(\"Permutation Importance (test set)\")\nfig.tight_layout()\nplt.show()"
109109
]
110110
}
111111
],

Diff for: dev/_downloads/df790541d4c6bdebcc75018a2459467a/plot_release_highlights_0_22_0.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"outputs": [],
2424
"source": [
25-
"import matplotlib.pyplot as plt\n\nfrom sklearn.datasets import make_classification\nfrom sklearn.ensemble import RandomForestClassifier\n\n# from sklearn.metrics import plot_roc_curve\nfrom sklearn.metrics import RocCurveDisplay\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.svm import SVC\n\nX, y = make_classification(random_state=0)\nX_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)\n\nsvc = SVC(random_state=42)\nsvc.fit(X_train, y_train)\nrfc = RandomForestClassifier(random_state=42)\nrfc.fit(X_train, y_train)\n\n# plot_roc_curve has been removed in version 1.2. From 1.2, use RocCurveDisplay instead.\n# svc_disp = plot_roc_curve(svc, X_test, y_test)\n# rfc_disp = plot_roc_curve(rfc, X_test, y_test, ax=svc_disp.ax_)\nsvc_disp = RocCurveDisplay.from_estimator(svc, X_test, y_test)\nrfc_disp = RocCurveDisplay.from_estimator(rfc, X_test, y_test, ax=svc_disp.ax_)\nrfc_disp.figure_.suptitle(\"ROC curve comparison\")\n\nplt.show()"
25+
"import matplotlib\nimport matplotlib.pyplot as plt\n\nfrom sklearn.datasets import make_classification\nfrom sklearn.ensemble import RandomForestClassifier\n\n# from sklearn.metrics import plot_roc_curve\nfrom sklearn.metrics import RocCurveDisplay\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.svm import SVC\nfrom sklearn.utils.fixes import parse_version\n\nX, y = make_classification(random_state=0)\nX_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)\n\nsvc = SVC(random_state=42)\nsvc.fit(X_train, y_train)\nrfc = RandomForestClassifier(random_state=42)\nrfc.fit(X_train, y_train)\n\n# plot_roc_curve has been removed in version 1.2. From 1.2, use RocCurveDisplay instead.\n# svc_disp = plot_roc_curve(svc, X_test, y_test)\n# rfc_disp = plot_roc_curve(rfc, X_test, y_test, ax=svc_disp.ax_)\nsvc_disp = RocCurveDisplay.from_estimator(svc, X_test, y_test)\nrfc_disp = RocCurveDisplay.from_estimator(rfc, X_test, y_test, ax=svc_disp.ax_)\nrfc_disp.figure_.suptitle(\"ROC curve comparison\")\n\nplt.show()"
2626
]
2727
},
2828
{
@@ -58,7 +58,7 @@
5858
},
5959
"outputs": [],
6060
"source": [
61-
"import matplotlib.pyplot as plt\nimport numpy as np\n\nfrom sklearn.datasets import make_classification\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.inspection import permutation_importance\n\nX, y = make_classification(random_state=0, n_features=5, n_informative=3)\nfeature_names = np.array([f\"x_{i}\" for i in range(X.shape[1])])\n\nrf = RandomForestClassifier(random_state=0).fit(X, y)\nresult = permutation_importance(rf, X, y, n_repeats=10, random_state=0, n_jobs=2)\n\nfig, ax = plt.subplots()\nsorted_idx = result.importances_mean.argsort()\nax.boxplot(\n result.importances[sorted_idx].T, vert=False, labels=feature_names[sorted_idx]\n)\nax.set_title(\"Permutation Importance of each feature\")\nax.set_ylabel(\"Features\")\nfig.tight_layout()\nplt.show()"
61+
"import matplotlib.pyplot as plt\nimport numpy as np\n\nfrom sklearn.datasets import make_classification\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.inspection import permutation_importance\n\nX, y = make_classification(random_state=0, n_features=5, n_informative=3)\nfeature_names = np.array([f\"x_{i}\" for i in range(X.shape[1])])\n\nrf = RandomForestClassifier(random_state=0).fit(X, y)\nresult = permutation_importance(rf, X, y, n_repeats=10, random_state=0, n_jobs=2)\n\nfig, ax = plt.subplots()\nsorted_idx = result.importances_mean.argsort()\n\n# `labels` argument in boxplot is deprecated in matplotlib 3.9 and has been\n# renamed to `tick_labels`. The following code handles this, but as a\n# scikit-learn user you probably can write simpler code by using `labels=...`\n# (matplotlib < 3.9) or `tick_labels=...` (matplotlib >= 3.9).\ntick_labels_parameter_name = (\n \"tick_labels\"\n if parse_version(matplotlib.__version__) >= parse_version(\"3.9\")\n else \"labels\"\n)\ntick_labels_dict = {tick_labels_parameter_name: feature_names[sorted_idx]}\nax.boxplot(result.importances[sorted_idx].T, vert=False, **tick_labels_dict)\nax.set_title(\"Permutation Importance of each feature\")\nax.set_ylabel(\"Features\")\nfig.tight_layout()\nplt.show()"
6262
]
6363
},
6464
{

Diff for: dev/_downloads/e0186b37c52cdb964f7759aac5fbb9b9/plot_gradient_boosting_regression.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
# Authors: The scikit-learn developers
2222
# SPDX-License-Identifier: BSD-3-Clause
2323

24+
import matplotlib
2425
import matplotlib.pyplot as plt
2526
import numpy as np
2627

2728
from sklearn import datasets, ensemble
2829
from sklearn.inspection import permutation_importance
2930
from sklearn.metrics import mean_squared_error
3031
from sklearn.model_selection import train_test_split
32+
from sklearn.utils.fixes import parse_version
3133

3234
# %%
3335
# Load the data
@@ -145,11 +147,20 @@
145147
)
146148
sorted_idx = result.importances_mean.argsort()
147149
plt.subplot(1, 2, 2)
148-
plt.boxplot(
149-
result.importances[sorted_idx].T,
150-
vert=False,
151-
labels=np.array(diabetes.feature_names)[sorted_idx],
150+
151+
# `labels` argument in boxplot is deprecated in matplotlib 3.9 and has been
152+
# renamed to `tick_labels`. The following code handles this, but as a
153+
# scikit-learn user you probably can write simpler code by using `labels=...`
154+
# (matplotlib < 3.9) or `tick_labels=...` (matplotlib >= 3.9).
155+
tick_labels_parameter_name = (
156+
"tick_labels"
157+
if parse_version(matplotlib.__version__) >= parse_version("3.9")
158+
else "labels"
152159
)
160+
tick_labels_dict = {
161+
tick_labels_parameter_name: np.array(diabetes.feature_names)[sorted_idx]
162+
}
163+
plt.boxplot(result.importances[sorted_idx].T, vert=False, **tick_labels_dict)
153164
plt.title("Permutation Importance (test set)")
154165
fig.tight_layout()
155166
plt.show()

Diff for: dev/_downloads/scikit-learn-docs.zip

6.67 KB
Binary file not shown.
19 Bytes
-37 Bytes
-34 Bytes
-141 Bytes
2 Bytes
1.5 KB
313 Bytes

Diff for: dev/_images/sphx_glr_plot_cluster_comparison_001.png

309 Bytes
1 Byte

Diff for: dev/_images/sphx_glr_plot_coin_segmentation_001.png

26 Bytes

Diff for: dev/_images/sphx_glr_plot_coin_segmentation_002.png

-132 Bytes

Diff for: dev/_images/sphx_glr_plot_coin_segmentation_003.png

-92 Bytes
21 Bytes
0 Bytes
92 Bytes

Diff for: dev/_images/sphx_glr_plot_gmm_init_001.png

7 Bytes

Diff for: dev/_images/sphx_glr_plot_gmm_init_thumb.png

3 Bytes
-51 Bytes
819 Bytes
69 Bytes
-18 Bytes
11 Bytes

Diff for: dev/_images/sphx_glr_plot_hgbt_regression_001.png

-518 Bytes

Diff for: dev/_images/sphx_glr_plot_hgbt_regression_thumb.png

-179 Bytes

Diff for: dev/_images/sphx_glr_plot_image_denoising_002.png

-35 Bytes

Diff for: dev/_images/sphx_glr_plot_image_denoising_004.png

-124 Bytes

Diff for: dev/_images/sphx_glr_plot_image_denoising_005.png

74 Bytes
334 Bytes
-13 Bytes
100 Bytes
-103 Bytes
-1 Bytes
64 Bytes

Diff for: dev/_images/sphx_glr_plot_learning_curve_002.png

1.79 KB

Diff for: dev/_images/sphx_glr_plot_learning_curve_003.png

3.89 KB

Diff for: dev/_images/sphx_glr_plot_linkage_comparison_001.png

-896 Bytes
0 Bytes

Diff for: dev/_images/sphx_glr_plot_lle_digits_002.png

-75 Bytes

Diff for: dev/_images/sphx_glr_plot_lle_digits_003.png

-22 Bytes

Diff for: dev/_images/sphx_glr_plot_lle_digits_005.png

71 Bytes

Diff for: dev/_images/sphx_glr_plot_lle_digits_006.png

-45 Bytes

Diff for: dev/_images/sphx_glr_plot_lle_digits_007.png

-108 Bytes

Diff for: dev/_images/sphx_glr_plot_lle_digits_008.png

52 Bytes

Diff for: dev/_images/sphx_glr_plot_lle_digits_009.png

257 Bytes

Diff for: dev/_images/sphx_glr_plot_lle_digits_010.png

-168 Bytes

Diff for: dev/_images/sphx_glr_plot_lle_digits_011.png

51 Bytes

Diff for: dev/_images/sphx_glr_plot_lle_digits_012.png

-28 Bytes

Diff for: dev/_images/sphx_glr_plot_lle_digits_013.png

132 Bytes

Diff for: dev/_images/sphx_glr_plot_lle_digits_014.png

68 Bytes

Diff for: dev/_images/sphx_glr_plot_manifold_sphere_001.png

766 Bytes

Diff for: dev/_images/sphx_glr_plot_manifold_sphere_thumb.png

69 Bytes
520 Bytes
55 Bytes
293 Bytes
279 Bytes
-1.1 KB
-917 Bytes
-658 Bytes
154 Bytes
-254 Bytes
-925 Bytes

Diff for: dev/_images/sphx_glr_plot_prediction_latency_001.png

-700 Bytes

Diff for: dev/_images/sphx_glr_plot_prediction_latency_002.png

348 Bytes

Diff for: dev/_images/sphx_glr_plot_prediction_latency_003.png

-749 Bytes

Diff for: dev/_images/sphx_glr_plot_prediction_latency_004.png

-26 Bytes
-230 Bytes
247 Bytes
-46 Bytes
-163 Bytes
-149 Bytes
177 Bytes
59 Bytes

Diff for: dev/_images/sphx_glr_plot_sgd_early_stopping_002.png

-5.2 KB

Diff for: dev/_images/sphx_glr_plot_stack_predictors_001.png

-26 Bytes

Diff for: dev/_images/sphx_glr_plot_stack_predictors_thumb.png

4 Bytes
-15 Bytes
-16 Bytes

Diff for: dev/_images/sphx_glr_plot_svm_scale_c_001.png

-5 Bytes

Diff for: dev/_images/sphx_glr_plot_svm_scale_c_thumb.png

-3 Bytes

Diff for: dev/_images/sphx_glr_plot_theilsen_002.png

24 Bytes

Diff for: dev/_sources/auto_examples/applications/plot_cyclical_feature_engineering.rst.txt

+1-1

Diff for: dev/_sources/auto_examples/applications/plot_digits_denoising.rst.txt

+1-1

Diff for: dev/_sources/auto_examples/applications/plot_face_recognition.rst.txt

+4-4

Diff for: dev/_sources/auto_examples/applications/plot_model_complexity_influence.rst.txt

+15-15

0 commit comments

Comments
 (0)