DocumentationClassesQuantileTransformer

Class: QuantileTransformer

Transform features using quantiles information.

This method transforms the features to follow a uniform or a normal distribution. Therefore, for a given feature, this transformation tends to spread out the most frequent values. It also reduces the impact of (marginal) outliers: this is therefore a robust preprocessing scheme.

The transformation is applied on each feature independently. First an estimate of the cumulative distribution function of a feature is used to map the original values to a uniform distribution. The obtained values are then mapped to the desired output distribution using the associated quantile function. Features values of new/unseen data that fall below or above the fitted range will be mapped to the bounds of the output distribution. Note that this transform is non-linear. It may distort linear correlations between variables measured at the same scale but renders variables measured at different scales more directly comparable.

For example visualizations, refer to Compare QuantileTransformer with other scalers.

Read more in the User Guide.

Python Reference

Constructors

new QuantileTransformer()

new QuantileTransformer(opts?): QuantileTransformer

Parameters

ParameterTypeDescription
opts?object-
opts.copy?booleanSet to false to perform inplace transformation and avoid a copy (if the input is already a numpy array).
opts.ignore_implicit_zeros?booleanOnly applies to sparse matrices. If true, the sparse entries of the matrix are discarded to compute the quantile statistics. If false, these entries are treated as zeros.
opts.n_quantiles?numberNumber of quantiles to be computed. It corresponds to the number of landmarks used to discretize the cumulative distribution function. If n_quantiles is larger than the number of samples, n_quantiles is set to the number of samples as a larger number of quantiles does not give a better approximation of the cumulative distribution function estimator.
opts.output_distribution?"uniform" | "normal"Marginal distribution for the transformed data. The choices are ‘uniform’ (default) or ‘normal’.
opts.random_state?numberDetermines random number generation for subsampling and smoothing noise. Please see subsample for more details. Pass an int for reproducible results across multiple function calls. See Glossary.
opts.subsample?numberMaximum number of samples used to estimate the quantiles for computational efficiency. Note that the subsampling procedure may differ for value-identical sparse and dense matrices. Disable subsampling by setting subsample=None.

Returns QuantileTransformer

Defined in generated/preprocessing/QuantileTransformer.ts:29

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/preprocessing/QuantileTransformer.ts:27
_isInitializedbooleanfalsegenerated/preprocessing/QuantileTransformer.ts:26
_pyPythonBridgeundefinedgenerated/preprocessing/QuantileTransformer.ts:25
idstringundefinedgenerated/preprocessing/QuantileTransformer.ts:22
optsanyundefinedgenerated/preprocessing/QuantileTransformer.ts:23

Accessors

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/QuantileTransformer.ts:524


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/preprocessing/QuantileTransformer.ts:497


n_quantiles_

Get Signature

get n_quantiles_(): Promise<number>

The actual number of quantiles used to discretize the cumulative distribution function.

Returns Promise<number>

Defined in generated/preprocessing/QuantileTransformer.ts:416


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/preprocessing/QuantileTransformer.ts:74


quantiles_

Get Signature

get quantiles_(): Promise<ArrayLike[]>

The values corresponding the quantiles of reference.

Returns Promise<ArrayLike[]>

Defined in generated/preprocessing/QuantileTransformer.ts:443


references_

Get Signature

get references_(): Promise<ArrayLike>

Quantiles of references.

Returns Promise<ArrayLike>

Defined in generated/preprocessing/QuantileTransformer.ts:470

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/QuantileTransformer.ts:130


fit()

fit(opts): Promise<any>

Compute the quantiles used for transforming.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeThe data used to scale along the features axis. If a sparse matrix is provided, it will be converted into a sparse csc_matrix. Additionally, the sparse matrix needs to be nonnegative if ignore_implicit_zeros is false.
opts.y?anyIgnored.

Returns Promise<any>

Defined in generated/preprocessing/QuantileTransformer.ts:147


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/QuantileTransformer.ts:188


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/QuantileTransformer.ts:234


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/QuantileTransformer.ts:272


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/QuantileTransformer.ts:87


inverse_transform()

inverse_transform(opts): Promise<any>

Back-projection to the original space.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeThe data used to scale along the features axis. If a sparse matrix is provided, it will be converted into a sparse csc_matrix. Additionally, the sparse matrix needs to be nonnegative if ignore_implicit_zeros is false.

Returns Promise<any>

Defined in generated/preprocessing/QuantileTransformer.ts:308


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/QuantileTransformer.ts:346


transform()

transform(opts): Promise<ArrayLike>

Feature-wise transformation of the data.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeThe data used to scale along the features axis. If a sparse matrix is provided, it will be converted into a sparse csc_matrix. Additionally, the sparse matrix needs to be nonnegative if ignore_implicit_zeros is false.

Returns Promise<ArrayLike>

Defined in generated/preprocessing/QuantileTransformer.ts:382