Skip to content

Commit

Permalink
[MRG + 1] Clarified error msg in plot_partial_dependence (scikit-lear…
Browse files Browse the repository at this point in the history
…n#7673)

* Clarified error msg in plot_partial_dependence

* Changed err msg for feature[i] out of range. Updated docs.

* Error message shows invalid value.
  • Loading branch information
kgilliam125 authored and NelleV committed Oct 25, 2016
1 parent 8f4ebb5 commit 4ddb744
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sklearn/ensemble/partial_dependence.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,14 @@ def plot_partial_dependence(gbrt, X, features, feature_names=None,
A fitted gradient boosting model.
X : array-like, shape=(n_samples, n_features)
The data on which ``gbrt`` was trained.
features : seq of tuples or ints
features : seq of ints, strings, or tuples of ints or strings
If seq[i] is an int or a tuple with one int value, a one-way
PDP is created; if seq[i] is a tuple of two ints, a two-way
PDP is created.
If feature_names is specified and seq[i] is an int, seq[i]
must be < len(feature_names).
If seq[i] is a string, feature_names must be specified, and
seq[i] must be in feature_names.
feature_names : seq of str
Name of each feature; feature_names[i] holds
the name of the feature with index i.
Expand Down Expand Up @@ -306,8 +310,9 @@ def convert_feature(fx):
l.append(feature_names[i])
names.append(l)
except IndexError:
raise ValueError('features[i] must be in [0, n_features) '
'but was %d' % i)
raise ValueError('All entries of features must be less than '
'len(feature_names) = {0}, got {1}.'
.format(len(feature_names), i))

# compute PD functions
pd_result = Parallel(n_jobs=n_jobs, verbose=verbose)(
Expand Down

0 comments on commit 4ddb744

Please sign in to comment.