@@ -35,10 +35,11 @@ def inplace_csr_column_scale(X, scale):
3535
3636 Parameters
3737 ----------
38- X : CSR matrix with shape (n_samples, n_features)
38+ X : sparse matrix of shape (n_samples, n_features)
3939 Matrix to normalize using the variance of the features.
40+ It should be of CSR format.
4041
41- scale : float array with shape (n_features,)
42+ scale : ndarray of shape (n_features,), dtype={np.float32, np.float64}
4243 Array of precomputed feature-wise values to use for scaling.
4344 """
4445 assert scale .shape [0 ] == X .shape [1 ]
@@ -53,25 +54,25 @@ def inplace_csr_row_scale(X, scale):
5354
5455 Parameters
5556 ----------
56- X : CSR sparse matrix, shape (n_samples, n_features)
57- Matrix to be scaled.
57+ X : sparse matrix of shape (n_samples, n_features)
58+ Matrix to be scaled. It should be of CSR format.
5859
59- scale : float array with shape (n_samples,)
60+ scale : ndarray of float of shape (n_samples,)
6061 Array of precomputed sample-wise values to use for scaling.
6162 """
6263 assert scale .shape [0 ] == X .shape [0 ]
6364 X .data *= np .repeat (scale , np .diff (X .indptr ))
6465
6566
6667def mean_variance_axis (X , axis , weights = None , return_sum_weights = False ):
67- """Compute mean and variance along an axix on a CSR or CSC matrix
68+ """Compute mean and variance along an axis on a CSR or CSC matrix.
6869
6970 Parameters
7071 ----------
71- X : CSR or CSC sparse matrix, shape (n_samples, n_features)
72- Input data.
72+ X : sparse matrix of shape (n_samples, n_features)
73+ Input data. It can be of CSR or CSC format.
7374
74- axis : int (either 0 or 1)
75+ axis : {0, 1}
7576 Axis along which the axis should be computed.
7677
7778 weights : ndarray of shape (n_samples,) or (n_features,), default=None
@@ -91,10 +92,10 @@ def mean_variance_axis(X, axis, weights=None, return_sum_weights=False):
9192 -------
9293
9394 means : ndarray of shape (n_features,), dtype=floating
94- Feature-wise means
95+ Feature-wise means.
9596
9697 variances : ndarray of shape (n_features,), dtype=floating
97- Feature-wise variances
98+ Feature-wise variances.
9899
99100 sum_weights : ndarray of shape (n_features,), dtype=floating
100101 Returned if `return_sum_weights` is `True`.
@@ -122,7 +123,7 @@ def mean_variance_axis(X, axis, weights=None, return_sum_weights=False):
122123@_deprecate_positional_args
123124def incr_mean_variance_axis (X , * , axis , last_mean , last_var , last_n ,
124125 weights = None ):
125- """Compute incremental mean and variance along an axix on a CSR or
126+ """Compute incremental mean and variance along an axis on a CSR or
126127 CSC matrix.
127128
128129 last_mean, last_var are the statistics computed at the last step by this
@@ -132,10 +133,10 @@ def incr_mean_variance_axis(X, *, axis, last_mean, last_var, last_n,
132133
133134 Parameters
134135 ----------
135- X : CSR or CSC sparse matrix, shape (n_samples, n_features)
136+ X : CSR or CSC sparse matrix of shape (n_samples, n_features)
136137 Input data.
137138
138- axis : int (either 0 or 1)
139+ axis : {0, 1}
139140 Axis along which the axis should be computed.
140141
141142 last_mean : ndarray of shape (n_features,) or (n_samples,), dtype=floating
@@ -226,10 +227,11 @@ def inplace_column_scale(X, scale):
226227
227228 Parameters
228229 ----------
229- X : CSC or CSR matrix with shape (n_samples, n_features)
230- Matrix to normalize using the variance of the features.
230+ X : sparse matrix of shape (n_samples, n_features)
231+ Matrix to normalize using the variance of the features. It should be
232+ of CSC or CSR format.
231233
232- scale : float array with shape (n_features,)
234+ scale : ndarray of shape (n_features,), dtype={np.float32, np.float64}
233235 Array of precomputed feature-wise values to use for scaling.
234236 """
235237 if isinstance (X , sp .csc_matrix ):
@@ -248,10 +250,10 @@ def inplace_row_scale(X, scale):
248250
249251 Parameters
250252 ----------
251- X : CSR or CSC sparse matrix, shape (n_samples, n_features)
252- Matrix to be scaled.
253+ X : sparse matrix of shape (n_samples, n_features)
254+ Matrix to be scaled. It should be of CSR or CSC format.
253255
254- scale : float array with shape (n_features,)
256+ scale : ndarray of shape (n_features,), dtype={np.float32, np.float64}
255257 Array of precomputed sample-wise values to use for scaling.
256258 """
257259 if isinstance (X , sp .csc_matrix ):
@@ -268,8 +270,9 @@ def inplace_swap_row_csc(X, m, n):
268270
269271 Parameters
270272 ----------
271- X : scipy.sparse.csc_matrix, shape=(n_samples, n_features)
272- Matrix whose two rows are to be swapped.
273+ X : sparse matrix of shape (n_samples, n_features)
274+ Matrix whose two rows are to be swapped. It should be of
275+ CSC format.
273276
274277 m : int
275278 Index of the row of X to be swapped.
@@ -297,8 +300,9 @@ def inplace_swap_row_csr(X, m, n):
297300
298301 Parameters
299302 ----------
300- X : scipy.sparse.csr_matrix, shape=(n_samples, n_features)
301- Matrix whose two rows are to be swapped.
303+ X : sparse matrix of shape (n_samples, n_features)
304+ Matrix whose two rows are to be swapped. It should be of
305+ CSR format.
302306
303307 m : int
304308 Index of the row of X to be swapped.
@@ -352,8 +356,9 @@ def inplace_swap_row(X, m, n):
352356
353357 Parameters
354358 ----------
355- X : CSR or CSC sparse matrix, shape=(n_samples, n_features)
356- Matrix whose two rows are to be swapped.
359+ X : sparse matrix of shape (n_samples, n_features)
360+ Matrix whose two rows are to be swapped. It should be of CSR or
361+ CSC format.
357362
358363 m : int
359364 Index of the row of X to be swapped.
@@ -375,8 +380,9 @@ def inplace_swap_column(X, m, n):
375380
376381 Parameters
377382 ----------
378- X : CSR or CSC sparse matrix, shape=(n_samples, n_features)
379- Matrix whose two columns are to be swapped.
383+ X : sparse matrix of shape (n_samples, n_features)
384+ Matrix whose two columns are to be swapped. It should be of
385+ CSR or CSC format.
380386
381387 m : int
382388 Index of the column of X to be swapped.
@@ -465,10 +471,10 @@ def min_max_axis(X, axis, ignore_nan=False):
465471
466472 Parameters
467473 ----------
468- X : CSR or CSC sparse matrix, shape (n_samples, n_features)
469- Input data.
474+ X : sparse matrix of shape (n_samples, n_features)
475+ Input data. It should be of CSR or CSC format.
470476
471- axis : int (either 0 or 1)
477+ axis : {0, 1}
472478 Axis along which the axis should be computed.
473479
474480 ignore_nan : bool, default=False
@@ -479,11 +485,11 @@ def min_max_axis(X, axis, ignore_nan=False):
479485 Returns
480486 -------
481487
482- mins : float array with shape (n_features,)
483- Feature-wise minima
488+ mins : ndarray of shape (n_features,), dtype={np.float32, np.float64}
489+ Feature-wise minima.
484490
485- maxs : float array with shape (n_features,)
486- Feature-wise maxima
491+ maxs : ndarray of shape (n_features,), dtype={np.float32, np.float64}
492+ Feature-wise maxima.
487493 """
488494 if isinstance (X , sp .csr_matrix ) or isinstance (X , sp .csc_matrix ):
489495 if ignore_nan :
@@ -501,10 +507,10 @@ def count_nonzero(X, axis=None, sample_weight=None):
501507
502508 Parameters
503509 ----------
504- X : CSR sparse matrix of shape (n_samples, n_labels)
505- Input data.
510+ X : sparse matrix of shape (n_samples, n_labels)
511+ Input data. It should be of CSR format.
506512
507- axis : None, 0 or 1
513+ axis : {0, 1}, default=None
508514 The axis on which the data is aggregated.
509515
510516 sample_weight : array-like of shape (n_samples,), default=None
@@ -546,7 +552,8 @@ def count_nonzero(X, axis=None, sample_weight=None):
546552def _get_median (data , n_zeros ):
547553 """Compute the median of data with n_zeros additional zeros.
548554
549- This function is used to support sparse matrices; it modifies data in-place
555+ This function is used to support sparse matrices; it modifies data
556+ in-place.
550557 """
551558 n_elems = len (data ) + n_zeros
552559 if not n_elems :
@@ -577,12 +584,12 @@ def csc_median_axis_0(X):
577584
578585 Parameters
579586 ----------
580- X : CSC sparse matrix, shape (n_samples, n_features)
581- Input data.
587+ X : sparse matrix of shape (n_samples, n_features)
588+ Input data. It should be of CSC format.
582589
583590 Returns
584591 -------
585- median : ndarray, shape (n_features,)
592+ median : ndarray of shape (n_features,)
586593 Median.
587594
588595 """
0 commit comments