Skip to content

Commit 04d74bb

Browse files
Fang-Chieh Chouamueller
Fang-Chieh Chou
authored andcommitted
Update partial_dependence.py (#9434)
Minor fix on the _grid_from_X function. The emp_percentiles variable is computed in the loop but not does not actually change, so it should be pulled out of the loop
1 parent e14c682 commit 04d74bb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sklearn/ensemble/partial_dependence.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ def _grid_from_X(X, percentiles=(0.05, 0.95), grid_resolution=100):
5353
raise ValueError('percentile values must be in [0, 1]')
5454

5555
axes = []
56+
emp_percentiles = mquantiles(X, prob=percentiles, axis=0)
5657
for col in range(X.shape[1]):
5758
uniques = np.unique(X[:, col])
5859
if uniques.shape[0] < grid_resolution:
5960
# feature has low resolution use unique vals
6061
axis = uniques
6162
else:
62-
emp_percentiles = mquantiles(X, prob=percentiles, axis=0)
6363
# create axis based on percentiles and grid resolution
6464
axis = np.linspace(emp_percentiles[0, col],
6565
emp_percentiles[1, col],

0 commit comments

Comments
 (0)