Skip to contents

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).

Centering and scaling happen independently on each feature by computing the relevant statistics on the samples in the training set. Median and interquartile range are then stored to be used on later data using the $transform() method.

Standardization of a dataset is a common requirement for many machine learning estimators. Typically this is done by removing the mean and scaling to unit variance. However, outliers can often influence the sample mean / variance in a negative way. In such cases, the median and the interquartile range often give better results.

Super classes

rgudhi::PythonClass -> rgudhi::SKLearnClass -> rgudhi::BaseScaler -> RobustScaler

Methods

Inherited methods


Method new()

The RobustScaler class constructor.

Usage

RobustScaler$new(
  with_centering = TRUE,
  with_scaling = TRUE,
  quantile_range = c(25, 75),
  copy = TRUE,
  unit_variance = FALSE
)

Arguments

with_centering

A boolean value specifying whether to center the data before scaling. This will cause transform to raise an exception when attempted on sparse matrices, because centering them entails building a dense matrix which in common use cases is likely to be too large to fit in memory. Defaults to TRUE.

with_scaling

A boolean value specifying whether to scale the data to interquartile range. Defaults to TRUE.

quantile_range

A length-2 numeric vector specifying the quantile range used to calculate scale_. Defaults to c(25.0, 75.0).

copy

A boolean value specifying whether to perform in-place scaling and avoid a copy (if the input is already a numpy array). Defaults to TRUE.

unit_variance

A boolean value specifying whether to scale data so that normally distributed features have a variance of 1. In general, if the difference between the x-values of \(q_{\max}\) and \(q_{\min}\) for a standard normal distribution is greater than 1, the data set will be scaled down. If less than 1, the data set will be scaled up. Defaults to FALSE.

Returns

An object of class RobustScaler.


Method clone()

The objects of this class are cloneable with this method.

Usage

RobustScaler$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

if (FALSE) { # reticulate::py_module_available("sklearn.preprocessing")
rs <- RobustScaler$new()
}