|
4 | 4 | # License: BSD 3 clause |
5 | 5 |
|
6 | 6 | from itertools import count |
7 | | - |
8 | | -from sklearn.externals.six.moves import zip |
9 | | - |
10 | 7 | import numbers |
11 | 8 |
|
12 | 9 | import numpy as np |
13 | | - |
14 | 10 | from scipy.stats.mstats import mquantiles |
15 | 11 |
|
16 | 12 | from ..utils.extmath import cartesian |
17 | 13 | from ..externals.joblib import Parallel, delayed |
18 | 14 | from ..externals import six |
19 | | -from ..externals.six.moves import xrange |
| 15 | +from ..externals.six.moves import map, range, zip |
20 | 16 | from ..utils import array2d |
21 | 17 | from ..tree._tree import DTYPE |
22 | 18 |
|
@@ -52,7 +48,7 @@ def _grid_from_X(X, percentiles=(0.05, 0.95), grid_resolution=100): |
52 | 48 | """ |
53 | 49 | if len(percentiles) != 2: |
54 | 50 | 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): |
56 | 52 | raise ValueError('percentile values must be in [0, 1]') |
57 | 53 |
|
58 | 54 | axes = [] |
@@ -157,7 +153,7 @@ def partial_dependence(gbrt, target_variables, grid=None, X=None, |
157 | 153 | n_estimators = gbrt.estimators_.shape[0] |
158 | 154 | pdp = np.zeros((n_trees_per_stage, grid.shape[0],), dtype=np.float64, |
159 | 155 | order='C') |
160 | | - for stage in xrange(n_estimators): |
| 156 | + for stage in range(n_estimators): |
161 | 157 | for k in range(n_trees_per_stage): |
162 | 158 | tree = gbrt.estimators_[stage, k].tree_ |
163 | 159 | _partial_dependence_tree(tree, grid, target_variables, |
@@ -268,7 +264,7 @@ def plot_partial_dependence(gbrt, X, features, feature_names=None, |
268 | 264 | # convert feature_names to list |
269 | 265 | if feature_names is None: |
270 | 266 | # 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)] |
272 | 268 | elif isinstance(feature_names, np.ndarray): |
273 | 269 | feature_names = feature_names.tolist() |
274 | 270 |
|
|
0 commit comments