Skip to content

Commit 9c3c5e6

Browse files
committed
Pushing the docs for revision for branch: master, commit 41035a0f198172e23a90d1f6a99147c640ba68b4
1 parent b43216e commit 9c3c5e6

File tree

746 files changed

+2629
-2639
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

746 files changed

+2629
-2639
lines changed

dev/_downloads/plot_partial_dependence.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@
4444
.. [2] For classification you can think of it as the regression score before
4545
the link function.
4646
"""
47+
from __future__ import print_function
4748
print(__doc__)
4849

4950
import numpy as np
5051
import matplotlib.pyplot as plt
5152

5253
from mpl_toolkits.mplot3d import Axes3D
53-
from six.moves.urllib.error import HTTPError
5454

5555
from sklearn.model_selection import train_test_split
5656
from sklearn.ensemble import GradientBoostingRegressor
@@ -69,17 +69,14 @@ def main():
6969
random_state=1)
7070
names = cal_housing.feature_names
7171

72-
print('_' * 80)
73-
print("Training GBRT...")
72+
print("Training GBRT...", flush=True, end='')
7473
clf = GradientBoostingRegressor(n_estimators=100, max_depth=4,
7574
learning_rate=0.1, loss='huber',
7675
random_state=1)
7776
clf.fit(X_train, y_train)
78-
print("done.")
77+
print(" done.")
7978

80-
print('_' * 80)
8179
print('Convenience plot with ``partial_dependence_plots``')
82-
print
8380

8481
features = [0, 5, 1, 2, (5, 1)]
8582
fig, axs = plot_partial_dependence(clf, X_train, features,
@@ -89,16 +86,14 @@ def main():
8986
'for the California housing dataset')
9087
plt.subplots_adjust(top=0.9) # tight_layout causes overlap with suptitle
9188

92-
print('_' * 80)
9389
print('Custom 3d plot via ``partial_dependence``')
94-
print
9590
fig = plt.figure()
9691

9792
target_feature = (1, 5)
98-
pdp, (x_axis, y_axis) = partial_dependence(clf, target_feature,
99-
X=X_train, grid_resolution=50)
100-
XX, YY = np.meshgrid(x_axis, y_axis)
101-
Z = pdp.T.reshape(XX.shape).T
93+
pdp, axes = partial_dependence(clf, target_feature,
94+
X=X_train, grid_resolution=50)
95+
XX, YY = np.meshgrid(axes[0], axes[1])
96+
Z = pdp[0].reshape(list(map(np.size, axes))).T
10297
ax = Axes3D(fig)
10398
surf = ax.plot_surface(XX, YY, Z, rstride=1, cstride=1, cmap=plt.cm.BuPu)
10499
ax.set_xlabel(names[target_feature[0]])
49 Bytes
49 Bytes
735 Bytes
735 Bytes
762 Bytes
762 Bytes
-340 Bytes
-340 Bytes

0 commit comments

Comments
 (0)