Documentation
Classes
RobustScaler

RobustScaler

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

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 preprocessing 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, using the median and the interquartile range often give better results. For an example visualization and comparison to other scalers, refer to Compare RobustScaler with other scalers.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new RobustScaler(opts?: object): RobustScaler;

Parameters

NameTypeDescription
opts?object-
opts.copy?booleanIf false, try to avoid a copy and do inplace scaling instead. This is not guaranteed to always work inplace; e.g. if the data is not a NumPy array or scipy.sparse CSR matrix, a copy may still be returned. Default Value true
opts.quantile_range?anyQuantile range used to calculate scale\_. By default this is equal to the IQR, i.e., q\_min is the first quantile and q\_max is the third quantile.
opts.unit_variance?booleanIf true, 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 dataset will be scaled down. If less than 1, the dataset will be scaled up. Default Value false
opts.with_centering?booleanIf true, 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. Default Value true
opts.with_scaling?booleanIf true, scale the data to interquartile range. Default Value true

Returns

RobustScaler

Defined in: generated/preprocessing/RobustScaler.ts:27 (opens in a new tab)

Methods

dispose()

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Signature

dispose(): Promise<void>;

Returns

Promise<void>

Defined in: generated/preprocessing/RobustScaler.ts:122 (opens in a new tab)

fit()

Compute the median and quantiles to be used for scaling.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeThe data used to compute the median and quantiles used for later scaling along the features axis.
opts.y?anyNot used, present here for API consistency by convention.

Returns

Promise<any>

Defined in: generated/preprocessing/RobustScaler.ts:139 (opens in a new tab)

fit_transform()

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit\_params and returns a transformed version of X.

Signature

fit_transform(opts: object): Promise<any[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Input samples.
opts.fit_params?anyAdditional fit parameters.
opts.y?ArrayLikeTarget values (undefined for unsupervised transformations).

Returns

Promise<any[]>

Defined in: generated/preprocessing/RobustScaler.ts:179 (opens in a new tab)

get_feature_names_out()

Get output feature names for transformation.

Signature

get_feature_names_out(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.input_features?anyInput features.

Returns

Promise<any>

Defined in: generated/preprocessing/RobustScaler.ts:226 (opens in a new tab)

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Signature

get_metadata_routing(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns

Promise<any>

Defined in: generated/preprocessing/RobustScaler.ts:264 (opens in a new tab)

init()

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Signature

init(py: PythonBridge): Promise<void>;

Parameters

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/preprocessing/RobustScaler.ts:78 (opens in a new tab)

inverse_transform()

Scale back the data to the original representation.

Signature

inverse_transform(opts: object): Promise<ArrayLike>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeThe rescaled data to be transformed back.

Returns

Promise<ArrayLike>

Defined in: generated/preprocessing/RobustScaler.ts:299 (opens in a new tab)

set_output()

Set output container.

See Introducing the set_output API for an example on how to use the API.

Signature

set_output(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.transform?"default" | "pandas"Configure output of transform and fit\_transform.

Returns

Promise<any>

Defined in: generated/preprocessing/RobustScaler.ts:336 (opens in a new tab)

transform()

Center and scale the data.

Signature

transform(opts: object): Promise<ArrayLike>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeThe data used to scale along the specified axis.

Returns

Promise<ArrayLike>

Defined in: generated/preprocessing/RobustScaler.ts:369 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/preprocessing/RobustScaler.ts:25 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/preprocessing/RobustScaler.ts:24 (opens in a new tab)

_py

PythonBridge

Defined in: generated/preprocessing/RobustScaler.ts:23 (opens in a new tab)

id

string

Defined in: generated/preprocessing/RobustScaler.ts:20 (opens in a new tab)

opts

any

Defined in: generated/preprocessing/RobustScaler.ts:21 (opens in a new tab)

Accessors

center_

The median value for each feature in the training set.

Signature

center_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/preprocessing/RobustScaler.ts:402 (opens in a new tab)

feature_names_in_

Names of features seen during fit. Defined only when X has feature names that are all strings.

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/preprocessing/RobustScaler.ts:473 (opens in a new tab)

n_features_in_

Number of features seen during fit.

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/preprocessing/RobustScaler.ts:448 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/preprocessing/RobustScaler.ts:65 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/preprocessing/RobustScaler.ts:69 (opens in a new tab)

scale_

The (scaled) interquartile range for each feature in the training set.

Signature

scale_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/preprocessing/RobustScaler.ts:425 (opens in a new tab)