Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 064168b

Browse files
committed
Clarify RobustScaler behavior with sparse input
1 parent b7bb8b5 commit 064168b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

doc/modules/preprocessing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ matrices as input, as long as ``with_mean=False`` is explicitly passed
191191
to the constructor. Otherwise a ``ValueError`` will be raised as
192192
silently centering would break the sparsity and would often crash the
193193
execution by allocating excessive amounts of memory unintentionally.
194-
:class:`RobustScaler` cannot be fited to sparse inputs, but you can use
194+
:class:`RobustScaler` cannot be fitted to sparse inputs, but you can use
195195
the ``transform`` method on sparse inputs.
196196

197197
Note that the scalers accept both Compressed Sparse Rows and Compressed

sklearn/preprocessing/data.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -844,9 +844,9 @@ class RobustScaler(BaseEstimator, TransformerMixin):
844844
and the 3rd quartile (75th quantile).
845845
846846
Centering and scaling happen independently on each feature (or each
847-
sample, depending on the `axis` argument) by computing the relevant
847+
sample, depending on the ``axis`` argument) by computing the relevant
848848
statistics on the samples in the training set. Median and interquartile
849-
range are then stored to be used on later data using the `transform`
849+
range are then stored to be used on later data using the ``transform``
850850
method.
851851
852852
Standardization of a dataset is a common requirement for many
@@ -863,7 +863,7 @@ class RobustScaler(BaseEstimator, TransformerMixin):
863863
----------
864864
with_centering : boolean, True by default
865865
If True, center the data before scaling.
866-
This does not work (and will raise an exception) when attempted on
866+
This will cause ``transform`` to raise an exception when attempted on
867867
sparse matrices, because centering them entails building a dense
868868
matrix which in common use cases is likely to be too large to fit in
869869
memory.
@@ -930,7 +930,8 @@ def _check_array(self, X, copy):
930930
return X
931931

932932
def fit(self, X, y=None):
933-
"""Compute the median and quantiles to be used for scaling.
933+
"""Compute the median and quantiles to be used for scaling. Note that
934+
RobustScaler cannot be fitted to sparse inputs.
934935
935936
Parameters
936937
----------

0 commit comments

Comments
 (0)