Documentation
Classes
QuantileTransformer

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 (opens in a new tab)

Constructors

constructor()

Signature

new QuantileTransformer(opts?: object): QuantileTransformer;

Parameters

NameTypeDescription
opts?object-
opts.copy?booleanSet to false to perform inplace transformation and avoid a copy (if the input is already a numpy array). Default Value true
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. Default Value false
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. Default Value 1000
opts.output_distribution?"uniform" | "normal"Marginal distribution for the transformed data. The choices are ‘uniform’ (default) or ‘normal’. Default Value 'uniform'
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. Default Value 10

Returns

QuantileTransformer

Defined in: generated/preprocessing/QuantileTransformer.ts:29 (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/QuantileTransformer.ts:137 (opens in a new tab)

fit()

Compute the quantiles used for transforming.

Signature

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

Parameters

NameTypeDescription
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:154 (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/QuantileTransformer.ts:196 (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/QuantileTransformer.ts:247 (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/QuantileTransformer.ts:287 (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/QuantileTransformer.ts:87 (opens in a new tab)

inverse_transform()

Back-projection to the original space.

Signature

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

Parameters

NameTypeDescription
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:325 (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/QuantileTransformer.ts:365 (opens in a new tab)

transform()

Feature-wise transformation of the data.

Signature

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

Parameters

NameTypeDescription
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:402 (opens in a new tab)

Properties

_isDisposed

boolean = false

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

_isInitialized

boolean = false

Defined in: generated/preprocessing/QuantileTransformer.ts:26 (opens in a new tab)

_py

PythonBridge

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

id

string

Defined in: generated/preprocessing/QuantileTransformer.ts:22 (opens in a new tab)

opts

any

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

Accessors

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/QuantileTransformer.ts:545 (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/QuantileTransformer.ts:518 (opens in a new tab)

n_quantiles_

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

Signature

n_quantiles_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/preprocessing/QuantileTransformer.ts:437 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/preprocessing/QuantileTransformer.ts:74 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

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

quantiles_

The values corresponding the quantiles of reference.

Signature

quantiles_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/preprocessing/QuantileTransformer.ts:464 (opens in a new tab)

references_

Quantiles of references.

Signature

references_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/preprocessing/QuantileTransformer.ts:491 (opens in a new tab)