Skip to content

Commit 5fcad7c

Browse files
Fixing sparse max for older scipy
1 parent 84ee88d commit 5fcad7c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sklearn/preprocessing/data.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
from ..utils.fixes import isclose
2323
from ..utils.sparsefuncs_fast import (inplace_csr_row_normalize_l1,
2424
inplace_csr_row_normalize_l2)
25-
from ..utils.sparsefuncs import (inplace_column_scale, mean_variance_axis)
25+
from ..utils.sparsefuncs import (inplace_column_scale, mean_variance_axis,
26+
min_max_axis)
2627
from ..utils.validation import check_is_fitted
2728

2829
zip = six.moves.zip
@@ -610,7 +611,7 @@ def normalize(X, norm='l2', axis=1, copy=True):
610611
elif norm == 'l2':
611612
inplace_csr_row_normalize_l2(X)
612613
elif norm == 'max':
613-
norms = X.max(axis=1).toarray()
614+
_, norms = min_max_axis(X, 1)
614615
norms = norms.repeat(np.diff(X.indptr))
615616
mask = norms != 0
616617
X.data[mask] /= norms[mask]

0 commit comments

Comments
 (0)