Skip to content

Commit 4d15cb6

Browse files
committed
Pushing the docs to dev/ for branch: main, commit 845b1fac9e8bcfc146e7b38119ce6c500e00a10b
1 parent 9395a41 commit 4d15cb6

File tree

1,261 files changed

+4482
-4470
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,261 files changed

+4482
-4470
lines changed
Binary file not shown.

dev/_downloads/21b82d82985712b5de6347f382c77c86/plot_partial_dependence.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
},
5252
"outputs": [],
5353
"source": [
54-
"from time import time\nfrom sklearn.pipeline import make_pipeline\nfrom sklearn.preprocessing import QuantileTransformer\nfrom sklearn.neural_network import MLPRegressor\n\nprint(\"Training MLPRegressor...\")\ntic = time()\nest = make_pipeline(\n QuantileTransformer(),\n MLPRegressor(\n hidden_layer_sizes=(50, 50), learning_rate_init=0.01, early_stopping=True\n ),\n)\nest.fit(X_train, y_train)\nprint(f\"done in {time() - tic:.3f}s\")\nprint(f\"Test R2 score: {est.score(X_test, y_test):.2f}\")"
54+
"from time import time\nfrom sklearn.pipeline import make_pipeline\nfrom sklearn.preprocessing import QuantileTransformer\nfrom sklearn.neural_network import MLPRegressor\n\nprint(\"Training MLPRegressor...\")\ntic = time()\nest = make_pipeline(\n QuantileTransformer(),\n MLPRegressor(\n hidden_layer_sizes=(30, 15),\n learning_rate_init=0.01,\n early_stopping=True,\n random_state=0,\n ),\n)\nest.fit(X_train, y_train)\nprint(f\"done in {time() - tic:.3f}s\")\nprint(f\"Test R2 score: {est.score(X_test, y_test):.2f}\")"
5555
]
5656
},
5757
{
@@ -87,7 +87,7 @@
8787
},
8888
"outputs": [],
8989
"source": [
90-
"from sklearn.ensemble import HistGradientBoostingRegressor\n\nprint(\"Training HistGradientBoostingRegressor...\")\ntic = time()\nest = HistGradientBoostingRegressor()\nest.fit(X_train, y_train)\nprint(f\"done in {time() - tic:.3f}s\")\nprint(f\"Test R2 score: {est.score(X_test, y_test):.2f}\")"
90+
"from sklearn.ensemble import HistGradientBoostingRegressor\n\nprint(\"Training HistGradientBoostingRegressor...\")\ntic = time()\nest = HistGradientBoostingRegressor(random_state=0)\nest.fit(X_train, y_train)\nprint(f\"done in {time() - tic:.3f}s\")\nprint(f\"Test R2 score: {est.score(X_test, y_test):.2f}\")"
9191
]
9292
},
9393
{
@@ -130,7 +130,7 @@
130130
},
131131
"outputs": [],
132132
"source": [
133-
"features = [\"AveOccup\", \"HouseAge\", (\"AveOccup\", \"HouseAge\")]\nprint(\"Computing partial dependence plots...\")\ntic = time()\n_, ax = plt.subplots(ncols=3, figsize=(9, 4))\ndisplay = PartialDependenceDisplay.from_estimator(\n est,\n X_train,\n features,\n kind=\"average\",\n n_jobs=3,\n grid_resolution=20,\n ax=ax,\n)\nprint(f\"done in {time() - tic:.3f}s\")\ndisplay.figure_.suptitle(\n \"Partial dependence of house value on non-___location features\\n\"\n \"for the California housing dataset, with Gradient Boosting\"\n)\ndisplay.figure_.subplots_adjust(wspace=0.4, hspace=0.3)"
133+
"features = [\"AveOccup\", \"HouseAge\", (\"AveOccup\", \"HouseAge\")]\nprint(\"Computing partial dependence plots...\")\ntic = time()\n_, ax = plt.subplots(ncols=3, figsize=(9, 4))\ndisplay = PartialDependenceDisplay.from_estimator(\n est,\n X_train,\n features,\n kind=\"average\",\n n_jobs=2,\n grid_resolution=10,\n ax=ax,\n)\nprint(f\"done in {time() - tic:.3f}s\")\ndisplay.figure_.suptitle(\n \"Partial dependence of house value on non-___location features\\n\"\n \"for the California housing dataset, with Gradient Boosting\"\n)\ndisplay.figure_.subplots_adjust(wspace=0.4, hspace=0.3)"
134134
]
135135
},
136136
{
@@ -148,7 +148,7 @@
148148
},
149149
"outputs": [],
150150
"source": [
151-
"import numpy as np\nfrom mpl_toolkits.mplot3d import Axes3D\n\nfig = plt.figure()\n\nfeatures = (\"AveOccup\", \"HouseAge\")\npdp = partial_dependence(\n est, X_train, features=features, kind=\"average\", grid_resolution=20\n)\nXX, YY = np.meshgrid(pdp[\"values\"][0], pdp[\"values\"][1])\nZ = pdp.average[0].T\nax = Axes3D(fig)\nfig.add_axes(ax)\nsurf = ax.plot_surface(XX, YY, Z, rstride=1, cstride=1, cmap=plt.cm.BuPu, edgecolor=\"k\")\nax.set_xlabel(features[0])\nax.set_ylabel(features[1])\nax.set_zlabel(\"Partial dependence\")\n# pretty init view\nax.view_init(elev=22, azim=122)\nplt.colorbar(surf)\nplt.suptitle(\n \"Partial dependence of house value on median\\n\"\n \"age and average occupancy, with Gradient Boosting\"\n)\nplt.subplots_adjust(top=0.9)\nplt.show()"
151+
"import numpy as np\nfrom mpl_toolkits.mplot3d import Axes3D\n\nfig = plt.figure()\n\nfeatures = (\"AveOccup\", \"HouseAge\")\npdp = partial_dependence(\n est, X_train, features=features, kind=\"average\", grid_resolution=10\n)\nXX, YY = np.meshgrid(pdp[\"values\"][0], pdp[\"values\"][1])\nZ = pdp.average[0].T\nax = Axes3D(fig)\nfig.add_axes(ax)\n\nsurf = ax.plot_surface(XX, YY, Z, rstride=1, cstride=1, cmap=plt.cm.BuPu, edgecolor=\"k\")\nax.set_xlabel(features[0])\nax.set_ylabel(features[1])\nax.set_zlabel(\"Partial dependence\")\n# pretty init view\nax.view_init(elev=22, azim=122)\nplt.colorbar(surf)\nplt.suptitle(\n \"Partial dependence of house value on median\\n\"\n \"age and average occupancy, with Gradient Boosting\"\n)\nplt.subplots_adjust(top=0.9)\nplt.show()"
152152
]
153153
}
154154
],
Binary file not shown.

dev/_downloads/bcd609cfe29c9da1f51c848e18b89c76/plot_partial_dependence.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@
8080
est = make_pipeline(
8181
QuantileTransformer(),
8282
MLPRegressor(
83-
hidden_layer_sizes=(50, 50), learning_rate_init=0.01, early_stopping=True
83+
hidden_layer_sizes=(30, 15),
84+
learning_rate_init=0.01,
85+
early_stopping=True,
86+
random_state=0,
8487
),
8588
)
8689
est.fit(X_train, y_train)
@@ -145,7 +148,7 @@
145148

146149
print("Training HistGradientBoostingRegressor...")
147150
tic = time()
148-
est = HistGradientBoostingRegressor()
151+
est = HistGradientBoostingRegressor(random_state=0)
149152
est.fit(X_train, y_train)
150153
print(f"done in {time() - tic:.3f}s")
151154
print(f"Test R2 score: {est.score(X_test, y_test):.2f}")
@@ -233,8 +236,8 @@
233236
X_train,
234237
features,
235238
kind="average",
236-
n_jobs=3,
237-
grid_resolution=20,
239+
n_jobs=2,
240+
grid_resolution=10,
238241
ax=ax,
239242
)
240243
print(f"done in {time() - tic:.3f}s")
@@ -265,12 +268,13 @@
265268

266269
features = ("AveOccup", "HouseAge")
267270
pdp = partial_dependence(
268-
est, X_train, features=features, kind="average", grid_resolution=20
271+
est, X_train, features=features, kind="average", grid_resolution=10
269272
)
270273
XX, YY = np.meshgrid(pdp["values"][0], pdp["values"][1])
271274
Z = pdp.average[0].T
272275
ax = Axes3D(fig)
273276
fig.add_axes(ax)
277+
274278
surf = ax.plot_surface(XX, YY, Z, rstride=1, cstride=1, cmap=plt.cm.BuPu, edgecolor="k")
275279
ax.set_xlabel(features[0])
276280
ax.set_ylabel(features[1])

dev/_downloads/scikit-learn-docs.zip

-49.3 KB
Binary file not shown.
-153 Bytes
3 Bytes
-243 Bytes
-161 Bytes
-48 Bytes

0 commit comments

Comments
 (0)