@@ -183,10 +183,14 @@ def plot_partial_dependence(gbrt, X, features, feature_names=None,
183
183
A fitted gradient boosting model.
184
184
X : array-like, shape=(n_samples, n_features)
185
185
The data on which ``gbrt`` was trained.
186
- features : seq of tuples or ints
186
+ features : seq of ints, strings, or tuples of ints or strings
187
187
If seq[i] is an int or a tuple with one int value, a one-way
188
188
PDP is created; if seq[i] is a tuple of two ints, a two-way
189
189
PDP is created.
190
+ If feature_names is specified and seq[i] is an int, seq[i]
191
+ must be < len(feature_names).
192
+ If seq[i] is a string, feature_names must be specified, and
193
+ seq[i] must be in feature_names.
190
194
feature_names : seq of str
191
195
Name of each feature; feature_names[i] holds
192
196
the name of the feature with index i.
@@ -306,8 +310,9 @@ def convert_feature(fx):
306
310
l .append (feature_names [i ])
307
311
names .append (l )
308
312
except IndexError :
309
- raise ValueError ('features[i] must be in [0, n_features) '
310
- 'but was %d' % i )
313
+ raise ValueError ('All entries of features must be less than '
314
+ 'len(feature_names) = {0}, got {1}.'
315
+ .format (len (feature_names ), i ))
311
316
312
317
# compute PD functions
313
318
pd_result = Parallel (n_jobs = n_jobs , verbose = verbose )(
0 commit comments