Class: 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

Constructors

new RobustScaler()

new RobustScaler(opts?): RobustScaler

Parameters

ParameterTypeDescription
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.
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.
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.
opts.with_scaling?booleanIf true, scale the data to interquartile range.

Returns RobustScaler

Defined in generated/preprocessing/RobustScaler.ts:27

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/preprocessing/RobustScaler.ts:25
_isInitializedbooleanfalsegenerated/preprocessing/RobustScaler.ts:24
_pyPythonBridgeundefinedgenerated/preprocessing/RobustScaler.ts:23
idstringundefinedgenerated/preprocessing/RobustScaler.ts:20
optsanyundefinedgenerated/preprocessing/RobustScaler.ts:21

Accessors

center_

Get Signature

get center_(): Promise<any>

The median value for each feature in the training set.

Returns Promise<any>

Defined in generated/preprocessing/RobustScaler.ts:385


feature_names_in_

Get Signature

get feature_names_in_(): Promise<ArrayLike>

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

Returns Promise<ArrayLike>

Defined in generated/preprocessing/RobustScaler.ts:456


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/preprocessing/RobustScaler.ts:431


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/preprocessing/RobustScaler.ts:65


scale_

Get Signature

get scale_(): Promise<any>

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

Returns Promise<any>

Defined in generated/preprocessing/RobustScaler.ts:408

Methods

dispose()

dispose(): Promise<void>

Disposes of the underlying Python resources.

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

Returns Promise<void>

Defined in generated/preprocessing/RobustScaler.ts:117


fit()

fit(opts): Promise<any>

Compute the median and quantiles to be used for scaling.

Parameters

ParameterTypeDescription
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:134


fit_transform()

fit_transform(opts): Promise<any[]>

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters

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

Returns Promise<any[]>

Defined in generated/preprocessing/RobustScaler.ts:173


get_feature_names_out()

get_feature_names_out(opts): Promise<any>

Get output feature names for transformation.

Parameters

ParameterTypeDescription
optsobject-
opts.input_features?anyInput features.

Returns Promise<any>

Defined in generated/preprocessing/RobustScaler.ts:215


get_metadata_routing()

get_metadata_routing(opts): Promise<any>

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Parameters

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

Returns Promise<any>

Defined in generated/preprocessing/RobustScaler.ts:251


init()

init(py): Promise<void>

Initializes the underlying Python resources.

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

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/preprocessing/RobustScaler.ts:78


inverse_transform()

inverse_transform(opts): Promise<ArrayLike>

Scale back the data to the original representation.

Parameters

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

Returns Promise<ArrayLike>

Defined in generated/preprocessing/RobustScaler.ts:285


set_output()

set_output(opts): Promise<any>

Set output container.

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

Parameters

ParameterTypeDescription
optsobject-
opts.transform?"default" | "pandas" | "polars"Configure output of transform and fit_transform.

Returns Promise<any>

Defined in generated/preprocessing/RobustScaler.ts:321


transform()

transform(opts): Promise<ArrayLike>

Center and scale the data.

Parameters

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

Returns Promise<ArrayLike>

Defined in generated/preprocessing/RobustScaler.ts:353