@@ -1352,7 +1352,7 @@ class RobustScaler(_OneToOneFeatureMixin, TransformerMixin, BaseEstimator):
1352
1352
Centering and scaling happen independently on each feature by
1353
1353
computing the relevant statistics on the samples in the training
1354
1354
set. Median and interquartile range are then stored to be used on
1355
- later data using the `` transform` ` method.
1355
+ later data using the :meth:` transform` method.
1356
1356
1357
1357
Standardization of a dataset is a common requirement for many
1358
1358
machine learning estimators. Typically this is done by removing the mean
@@ -1367,31 +1367,33 @@ class RobustScaler(_OneToOneFeatureMixin, TransformerMixin, BaseEstimator):
1367
1367
Parameters
1368
1368
----------
1369
1369
with_centering : bool, default=True
1370
- If True, center the data before scaling.
1371
- This will cause `` transform`` to raise an exception when attempted on
1372
- sparse matrices, because centering them entails building a dense
1370
+ If ` True` , center the data before scaling.
1371
+ This will cause :meth:` transform` to raise an exception when attempted
1372
+ on sparse matrices, because centering them entails building a dense
1373
1373
matrix which in common use cases is likely to be too large to fit in
1374
1374
memory.
1375
1375
1376
1376
with_scaling : bool, default=True
1377
- If True, scale the data to interquartile range.
1377
+ If ` True` , scale the data to interquartile range.
1378
1378
1379
1379
quantile_range : tuple (q_min, q_max), 0.0 < q_min < q_max < 100.0, \
1380
- default=(25.0, 75.0), == (1st quantile, 3rd quantile), == IQR
1381
- Quantile range used to calculate ``scale_``.
1380
+ default=(25.0, 75.0)
1381
+ Quantile range used to calculate `scale_`. By default this is equal to
1382
+ the IQR, i.e., `q_min` is the first quantile and `q_max` is the third
1383
+ quantile.
1382
1384
1383
1385
.. versionadded:: 0.18
1384
1386
1385
1387
copy : bool, default=True
1386
- If False, try to avoid a copy and do inplace scaling instead.
1388
+ If ` False` , try to avoid a copy and do inplace scaling instead.
1387
1389
This is not guaranteed to always work inplace; e.g. if the data is
1388
1390
not a NumPy array or scipy.sparse CSR matrix, a copy may still be
1389
1391
returned.
1390
1392
1391
1393
unit_variance : bool, default=False
1392
- If True, scale data so that normally distributed features have a
1394
+ If ` True` , scale data so that normally distributed features have a
1393
1395
variance of 1. In general, if the difference between the x-values of
1394
- `` q_max`` and `` q_min` ` for a standard normal distribution is greater
1396
+ `q_max` and `q_min` for a standard normal distribution is greater
1395
1397
than 1, the dataset will be scaled down. If less than 1, the dataset
1396
1398
will be scaled up.
1397
1399
@@ -1419,6 +1421,21 @@ class RobustScaler(_OneToOneFeatureMixin, TransformerMixin, BaseEstimator):
1419
1421
1420
1422
.. versionadded:: 1.0
1421
1423
1424
+ See Also
1425
+ --------
1426
+ robust_scale : Equivalent function without the estimator API.
1427
+ sklearn.decomposition.PCA : Further removes the linear correlation across
1428
+ features with 'whiten=True'.
1429
+
1430
+ Notes
1431
+ -----
1432
+ For a comparison of the different scalers, transformers, and normalizers,
1433
+ see :ref:`examples/preprocessing/plot_all_scaling.py
1434
+ <sphx_glr_auto_examples_preprocessing_plot_all_scaling.py>`.
1435
+
1436
+ https://en.wikipedia.org/wiki/Median
1437
+ https://en.wikipedia.org/wiki/Interquartile_range
1438
+
1422
1439
Examples
1423
1440
--------
1424
1441
>>> from sklearn.preprocessing import RobustScaler
@@ -1432,23 +1449,6 @@ class RobustScaler(_OneToOneFeatureMixin, TransformerMixin, BaseEstimator):
1432
1449
array([[ 0. , -2. , 0. ],
1433
1450
[-1. , 0. , 0.4],
1434
1451
[ 1. , 0. , -1.6]])
1435
-
1436
- See Also
1437
- --------
1438
- robust_scale : Equivalent function without the estimator API.
1439
-
1440
- :class:`~sklearn.decomposition.PCA`
1441
- Further removes the linear correlation across features with
1442
- 'whiten=True'.
1443
-
1444
- Notes
1445
- -----
1446
- For a comparison of the different scalers, transformers, and normalizers,
1447
- see :ref:`examples/preprocessing/plot_all_scaling.py
1448
- <sphx_glr_auto_examples_preprocessing_plot_all_scaling.py>`.
1449
-
1450
- https://en.wikipedia.org/wiki/Median
1451
- https://en.wikipedia.org/wiki/Interquartile_range
1452
1452
"""
1453
1453
1454
1454
def __init__ (
@@ -1475,8 +1475,8 @@ def fit(self, X, y=None):
1475
1475
The data used to compute the median and quantiles
1476
1476
used for later scaling along the features axis.
1477
1477
1478
- y : None
1479
- Ignored .
1478
+ y : Ignored
1479
+ Not used, present here for API consistency by convention .
1480
1480
1481
1481
Returns
1482
1482
-------
@@ -1627,32 +1627,34 @@ def robust_scale(
1627
1627
The data to center and scale.
1628
1628
1629
1629
axis : int, default=0
1630
- axis used to compute the medians and IQR along. If 0,
1630
+ Axis used to compute the medians and IQR along. If 0,
1631
1631
independently scale each feature, otherwise (if 1) scale
1632
1632
each sample.
1633
1633
1634
1634
with_centering : bool, default=True
1635
- If True, center the data before scaling.
1635
+ If ` True` , center the data before scaling.
1636
1636
1637
1637
with_scaling : bool, default=True
1638
- If True, scale the data to unit variance (or equivalently,
1638
+ If ` True` , scale the data to unit variance (or equivalently,
1639
1639
unit standard deviation).
1640
1640
1641
- quantile_range : tuple (q_min, q_max), 0.0 < q_min < q_max < 100.0
1642
- default=(25.0, 75.0), == (1st quantile, 3rd quantile), == IQR
1643
- Quantile range used to calculate ``scale_``.
1641
+ quantile_range : tuple (q_min, q_max), 0.0 < q_min < q_max < 100.0,\
1642
+ default=(25.0, 75.0)
1643
+ Quantile range used to calculate `scale_`. By default this is equal to
1644
+ the IQR, i.e., `q_min` is the first quantile and `q_max` is the third
1645
+ quantile.
1644
1646
1645
1647
..
9052
versionadded:: 0.18
1646
1648
1647
1649
copy : bool, default=True
1648
- set to False to perform inplace row normalization and avoid a
1650
+ Set to ` False` to perform inplace row normalization and avoid a
1649
1651
copy (if the input is already a numpy array or a scipy.sparse
1650
1652
CSR matrix and if axis is 1).
1651
1653
1652
1654
unit_variance : bool, default=False
1653
- If True, scale data so that normally distributed features have a
1655
+ If ` True` , scale data so that normally distributed features have a
1654
1656
variance of 1. In general, if the difference between the x-values of
1655
- `` q_max`` and `` q_min` ` for a standard normal distribution is greater
1657
+ `q_max` and `q_min` for a standard normal distribution is greater
1656
1658
than 1, the dataset will be scaled down. If less than 1, the dataset
1657
1659
will be scaled up.
1658
1660
0 commit comments