Scale features using statistics that are robust to outliers. This Scaler removes the median and scales the data according to the quantile range (defaults to IQR: Interquartile Range). The IQR is the range between the 1st quartile (25th quantile) and the 3rd quartile (75th quantile).
| 1550 | |
| 1551 | |
| 1552 | class RobustScaler(OneToOneFeatureMixin, TransformerMixin, BaseEstimator): |
| 1553 | """Scale features using statistics that are robust to outliers. |
| 1554 | |
| 1555 | This Scaler removes the median and scales the data according to |
| 1556 | the quantile range (defaults to IQR: Interquartile Range). |
| 1557 | The IQR is the range between the 1st quartile (25th quantile) |
| 1558 | and the 3rd quartile (75th quantile). |
| 1559 | |
| 1560 | Centering and scaling happen independently on each feature by |
| 1561 | computing the relevant statistics on the samples in the training |
| 1562 | set. Median and interquartile range are then stored to be used on |
| 1563 | later data using the :meth:`transform` method. |
| 1564 | |
| 1565 | Standardization of a dataset is a common preprocessing for many machine |
| 1566 | learning estimators. Typically this is done by removing the mean and |
| 1567 | scaling to unit variance. However, outliers can often influence the sample |
| 1568 | mean / variance in a negative way. In such cases, using the median and the |
| 1569 | interquartile range often give better results. For an example visualization |
| 1570 | and comparison to other scalers, refer to :ref:`Compare RobustScaler with |
| 1571 | other scalers <plot_all_scaling_robust_scaler_section>`. |
| 1572 | |
| 1573 | .. versionadded:: 0.17 |
| 1574 | |
| 1575 | Read more in the :ref:`User Guide <preprocessing_scaler>`. |
| 1576 | |
| 1577 | Parameters |
| 1578 | ---------- |
| 1579 | with_centering : bool, default=True |
| 1580 | If `True`, center the data before scaling. |
| 1581 | This will cause :meth:`transform` to raise an exception when attempted |
| 1582 | on sparse matrices, because centering them entails building a dense |
| 1583 | matrix which in common use cases is likely to be too large to fit in |
| 1584 | memory. |
| 1585 | |
| 1586 | with_scaling : bool, default=True |
| 1587 | If `True`, scale the data to interquartile range. |
| 1588 | |
| 1589 | quantile_range : tuple (q_min, q_max), 0.0 < q_min < q_max < 100.0, \ |
| 1590 | default=(25.0, 75.0) |
| 1591 | Quantile range used to calculate `scale_`. By default this is equal to |
| 1592 | the IQR, i.e., `q_min` is the first quantile and `q_max` is the third |
| 1593 | quantile. |
| 1594 | |
| 1595 | .. versionadded:: 0.18 |
| 1596 | |
| 1597 | copy : bool, default=True |
| 1598 | If `False`, try to avoid a copy and do inplace scaling instead. |
| 1599 | This is not guaranteed to always work inplace; e.g. if the data is |
| 1600 | not a NumPy array or scipy.sparse CSR matrix, a copy may still be |
| 1601 | returned. |
| 1602 | |
| 1603 | unit_variance : bool, default=False |
| 1604 | If `True`, scale data so that normally distributed features have a |
| 1605 | variance of 1. In general, if the difference between the x-values of |
| 1606 | `q_max` and `q_min` for a standard normal distribution is greater |
| 1607 | than 1, the dataset will be scaled down. If less than 1, the dataset |
| 1608 | will be scaled up. |
| 1609 |
no outgoing calls
searching dependent graphs…