@@ -103,7 +103,7 @@ def scale(X, axis=0, with_mean=True, with_std=True, copy=True):
103
103
copy : boolean, optional, default True
104
104
set to False to perform inplace row normalization and avoid a
105
105
copy (if the input is already a numpy array or a scipy.sparse
106
- CSR matrix and if axis is 1).
106
+ CSC matrix and if axis is 1).
107
107
108
108
Notes
109
109
-----
@@ -113,18 +113,18 @@ def scale(X, axis=0, with_mean=True, with_std=True, copy=True):
113
113
114
114
Instead the caller is expected to either set explicitly
115
115
`with_mean=False` (in that case, only variance scaling will be
116
- performed on the features of the CSR matrix) or to call `X.toarray()`
116
+ performed on the features of the CSC matrix) or to call `X.toarray()`
117
117
if he/she expects the materialized dense array to fit in memory.
118
118
119
- To avoid memory copy the caller should pass a CSR matrix.
119
+ To avoid memory copy the caller should pass a CSC matrix.
120
120
121
121
See also
122
122
--------
123
123
:class:`sklearn.preprocessing.StandardScaler` to perform centering and
124
124
scaling using the ``Transformer`` API (e.g. as part of a preprocessing
125
125
:class:`sklearn.pipeline.Pipeline`)
126
126
"""
127
- X = check_array (X , accept_sparse = 'csr ' , copy = copy , ensure_2d = False ,
127
+ X = check_array (X , accept_sparse = 'csc ' , copy = copy , ensure_2d = False ,
128
128
warn_on_dtype = True , estimator = 'the scale function' ,
129
129
dtype = FLOAT_DTYPES )
130
130
if sparse .issparse (X ):
@@ -135,11 +135,6 @@ def scale(X, axis=0, with_mean=True, with_std=True, copy=True):
135
135
if axis != 0 :
136
136
raise ValueError ("Can only scale sparse matrix on axis=0, "
137
137
" got axis=%d" % axis )
138
- if not sparse .isspmatrix_csr (X ):
139
- X = X .tocsr ()
140
- copy = False
141
- if copy :
142
- X = X .copy ()
143
138
if with_std :
144
139
_ , var = mean_variance_axis (X , axis = 0 )
145
140
var = _handle_zeros_in_scale (var , copy = False )
@@ -150,8 +145,6 @@ def scale(X, axis=0, with_mean=True, with_std=True, copy=True):
150
145
mean_ = np .mean (X , axis )
151
146
if with_std :
152
147
scale_ = np .std (X , axis )
153
- if copy :
154
- X = X .copy ()
155
148
# Xr is a view on the original array that enables easy use of
156
149
# broadcasting on the axis in which we are interested in
157
150
Xr = np .rollaxis (X , axis )
0 commit comments