Skip to content

Commit 7c140a1

Browse files
committed
COSMIT six.{map,range} usage in partial_dependence
1 parent aac2f4e commit 7c140a1

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

sklearn/ensemble/partial_dependence.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,15 @@
44
# License: BSD 3 clause
55

66
from itertools import count
7-
8-
from sklearn.externals.six.moves import zip
9-
107
import numbers
118

129
import numpy as np
13-
1410
from scipy.stats.mstats import mquantiles
1511

1612
from ..utils.extmath import cartesian
1713
from ..externals.joblib import Parallel, delayed
1814
from ..externals import six
19-
from ..externals.six.moves import xrange
15+
from ..externals.six.moves import map, range, zip
2016
from ..utils import array2d
2117
from ..tree._tree import DTYPE
2218

@@ -52,7 +48,7 @@ def _grid_from_X(X, percentiles=(0.05, 0.95), grid_resolution=100):
5248
"""
5349
if len(percentiles) != 2:
5450
raise ValueError('percentile must be tuple of len 2')
55-
if not all(map(lambda x: 0.0 <= x <= 1.0, percentiles)):
51+
if not all(0. <= x <= 1. for x in percentiles):
5652
raise ValueError('percentile values must be in [0, 1]')
5753

5854
axes = []
@@ -157,7 +153,7 @@ def partial_dependence(gbrt, target_variables, grid=None, X=None,
157153
n_estimators = gbrt.estimators_.shape[0]
158154
pdp = np.zeros((n_trees_per_stage, grid.shape[0],), dtype=np.float64,
159155
order='C')
160-
for stage in xrange(n_estimators):
156+
for stage in range(n_estimators):
161157
for k in range(n_trees_per_stage):
162158
tree = gbrt.estimators_[stage, k].tree_
163159
_partial_dependence_tree(tree, grid, target_variables,
@@ -268,7 +264,7 @@ def plot_partial_dependence(gbrt, X, features, feature_names=None,
268264
# convert feature_names to list
269265
if feature_names is None:
270266
# if not feature_names use fx indices as name
271-
feature_names = list(map(str, range(gbrt.n_features)))
267+
feature_names = [str(i) for i in range(gbrt.n_features)]
272268
elif isinstance(feature_names, np.ndarray):
273269
feature_names = feature_names.tolist()
274270

0 commit comments

Comments
 (0)