Skip to content

Commit d66ab30

Browse files
committed
Pushing the docs to 1.2/ for branch: 1.2.X, commit dc580a8ef5ee2a8aea80498388690e2213118efd
1 parent c47ce1e commit d66ab30

File tree

1,421 files changed

+6680
-6625
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,421 files changed

+6680
-6625
lines changed

1.2/.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: ee66a46362debe0a1889a563899a7be7
3+
config: e03f48e4a7a8954c4c5c39af4d86b428
44
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.

1.2/_downloads/138e7c706c17949c3098ff8074b03ce7/plot_release_highlights_1_2_0.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,49 @@
9393
hist_no_interact, X, y, cv=5, n_jobs=2, train_sizes=np.linspace(0.1, 1, 5)
9494
)
9595

96+
# %%
97+
# :class:`~inspection.PartialDependenceDisplay` exposes a new parameter
98+
# `categorical_features` to display partial dependence for categorical features
99+
# using bar plots and heatmaps.
100+
from sklearn.datasets import fetch_openml
101+
102+
X, y = fetch_openml(
103+
"titanic", version=1, as_frame=True, return_X_y=True, parser="pandas"
104+
)
105+
X = X.select_dtypes(["number", "category"]).drop(columns=["body"])
106+
107+
# %%
108+
from sklearn.preprocessing import OrdinalEncoder
109+
from sklearn.pipeline import make_pipeline
110+
111+
categorical_features = ["pclass", "sex", "embarked"]
112+
model = make_pipeline(
113+
ColumnTransformer(
114+
transformers=[("cat", OrdinalEncoder(), categorical_features)],
115+
remainder="passthrough",
116+
),
117+
HistGradientBoostingRegressor(random_state=0),
118+
).fit(X, y)
119+
120+
# %%
121+
from sklearn.inspection import PartialDependenceDisplay
122+
123+
fig, ax = plt.subplots(figsize=(14, 4), constrained_layout=True)
124+
_ = PartialDependenceDisplay.from_estimator(
125+
model,
126+
X,
127+
features=["age", "sex", ("pclass", "sex")],
128+
categorical_features=categorical_features,
129+
ax=ax,
130+
)
131+
96132
# %%
97133
# Faster parser in :func:`~datasets.fetch_openml`
98134
# -----------------------------------------------
99135
# :func:`~datasets.fetch_openml` now supports a new `"pandas"` parser that is
100136
# more memory and CPU efficient. In v1.4, the default will change to
101137
# `parser="auto"` which will automatically use the `"pandas"` parser for dense
102138
# data and `"liac-arff"` for sparse data.
103-
from sklearn.datasets import fetch_openml
104-
105139
X, y = fetch_openml(
106140
"titanic", version=1, as_frame=True, return_X_y=True, parser="pandas"
107141
)
Binary file not shown.

1.2/_downloads/df1b185d030fd32d53b4b2303d64816c/plot_release_highlights_1_2_0.ipynb

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,46 @@
9090
"from sklearn.model_selection import LearningCurveDisplay\n\n_ = LearningCurveDisplay.from_estimator(\n hist_no_interact, X, y, cv=5, n_jobs=2, train_sizes=np.linspace(0.1, 1, 5)\n)"
9191
]
9292
},
93+
{
94+
"cell_type": "markdown",
95+
"metadata": {},
96+
"source": [
97+
":class:`~inspection.PartialDependenceDisplay` exposes a new parameter\n`categorical_features` to display partial dependence for categorical features\nusing bar plots and heatmaps.\n\n"
98+
]
99+
},
100+
{
101+
"cell_type": "code",
102+
"execution_count": null,
103+
"metadata": {
104+
"collapsed": false
105+
},
106+
"outputs": [],
107+
"source": [
108+
"from sklearn.datasets import fetch_openml\n\nX, y = fetch_openml(\n \"titanic\", version=1, as_frame=True, return_X_y=True, parser=\"pandas\"\n)\nX = X.select_dtypes([\"number\", \"category\"]).drop(columns=[\"body\"])"
109+
]
110+
},
111+
{
112+
"cell_type": "code",
113+
"execution_count": null,
114+
"metadata": {
115+
"collapsed": false
116+
},
117+
"outputs": [],
118+
"source": [
119+
"from sklearn.preprocessing import OrdinalEncoder\nfrom sklearn.pipeline import make_pipeline\n\ncategorical_features = [\"pclass\", \"sex\", \"embarked\"]\nmodel = make_pipeline(\n ColumnTransformer(\n transformers=[(\"cat\", OrdinalEncoder(), categorical_features)],\n remainder=\"passthrough\",\n ),\n HistGradientBoostingRegressor(random_state=0),\n).fit(X, y)"
120+
]
121+
},
122+
{
123+
"cell_type": "code",
124+
"execution_count": null,
125+
"metadata": {
126+
"collapsed": false
127+
},
128+
"outputs": [],
129+
"source": [
130+
"from sklearn.inspection import PartialDependenceDisplay\n\nfig, ax = plt.subplots(figsize=(14, 4), constrained_layout=True)\n_ = PartialDependenceDisplay.from_estimator(\n model,\n X,\n features=[\"age\", \"sex\", (\"pclass\", \"sex\")],\n categorical_features=categorical_features,\n ax=ax,\n)"
131+
]
132+
},
93133
{
94134
"cell_type": "markdown",
95135
"metadata": {},
@@ -105,7 +145,7 @@
105145
},
106146
"outputs": [],
107147
"source": [
108-
"from sklearn.datasets import fetch_openml\n\nX, y = fetch_openml(\n \"titanic\", version=1, as_frame=True, return_X_y=True, parser=\"pandas\"\n)\nX.head()"
148+
"X, y = fetch_openml(\n \"titanic\", version=1, as_frame=True, return_X_y=True, parser=\"pandas\"\n)\nX.head()"
109149
]
110150
},
111151
{

1.2/_downloads/scikit-learn-docs.zip

26 KB
Binary file not shown.
-212 Bytes
160 Bytes
167 Bytes
-62 Bytes

0 commit comments

Comments
 (0)