MAINT accelerate plot_partial_dependence.py
@@ -80,7 +80,10 @@ tic = time()
est = make_pipeline(
QuantileTransformer(),
MLPRegressor(
- hidden_layer_sizes=(50, 50), learning_rate_init=0.01, early_stopping=True
+ hidden_layer_sizes=(30, 15),
+ learning_rate_init=0.01,
+ early_stopping=True,
+ random_state=0,
),
)
est.fit(X_train, y_train)
@@ -145,7 +148,7 @@ from sklearn.ensemble import HistGradientBoostingRegressor
print("Training HistGradientBoostingRegressor...")
tic = time()
-est = HistGradientBoostingRegressor()
+est = HistGradientBoostingRegressor(random_state=0)
est.fit(X_train, y_train)
print(f"done in {time() - tic:.3f}s")
print(f"Test R2 score: {est.score(X_test, y_test):.2f}")
@@ -233,8 +236,8 @@ display = PartialDependenceDisplay.from_estimator(
X_train,
features,
kind="average",
- n_jobs=3,
- grid_resolution=20,
+ n_jobs=2,
+ grid_resolution=10,
ax=ax,
)
print(f"done in {time() - tic:.3f}s")
@@ -265,12 +268,13 @@ fig = plt.figure()
features = ("AveOccup", "HouseAge")
pdp = partial_dependence(
- est, X_train, features=features, kind="average", grid_resolution=20
+ est, X_train, features=features, kind="average", grid_resolution=10
)
XX, YY = np.meshgrid(pdp["values"][0], pdp["values"][1])
Z = pdp.average[0].T
ax = Axes3D(fig)
fig.add_axes(ax)
+
surf = ax.plot_surface(XX, YY, Z, rstride=1, cstride=1, cmap=plt.cm.BuPu, edgecolor="k")
ax.set_xlabel(features[0])
ax.set_ylabel(features[1])
