DocumentationClassesStandardScaler

Class: StandardScaler

Standardize features by removing the mean and scaling to unit variance.

The standard score of a sample x is calculated as:

Python Reference

Constructors

new StandardScaler()

new StandardScaler(opts?): StandardScaler

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.with_mean?booleanIf true, center the data before scaling. This does not work (and will 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_std?booleanIf true, scale the data to unit variance (or equivalently, unit standard deviation).

Returns StandardScaler

Defined in generated/preprocessing/StandardScaler.ts:23

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/preprocessing/StandardScaler.ts:21
_isInitializedbooleanfalsegenerated/preprocessing/StandardScaler.ts:20
_pyPythonBridgeundefinedgenerated/preprocessing/StandardScaler.ts:19
idstringundefinedgenerated/preprocessing/StandardScaler.ts:16
optsanyundefinedgenerated/preprocessing/StandardScaler.ts:17

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/StandardScaler.ts:676


mean_

Get Signature

get mean_(): Promise<ArrayLike>

The mean value for each feature in the training set. Equal to undefined when with_mean=False and with_std=False.

Returns Promise<ArrayLike>

Defined in generated/preprocessing/StandardScaler.ts:605


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/preprocessing/StandardScaler.ts:651


n_samples_seen_

Get Signature

get n_samples_seen_(): Promise<number | ArrayLike>

The number of samples processed by the estimator for each feature. If there are no missing samples, the n_samples_seen will be an integer, otherwise it will be an array of dtype int. If sample_weights are used it will be a float (if no missing data) or an array of dtype float that sums the weights seen so far. Will be reset on new calls to fit, but increments across partial_fit calls.

Returns Promise<number | ArrayLike>

Defined in generated/preprocessing/StandardScaler.ts:701


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/preprocessing/StandardScaler.ts:49


scale_

Get Signature

get scale_(): Promise<ArrayLike>

Per feature relative scaling of the data to achieve zero mean and unit variance. Generally this is calculated using np.sqrt(var_). If a variance is zero, we can’t achieve unit variance, and the data is left as-is, giving a scaling factor of 1. scale_ is equal to undefined when with_std=False.

Returns Promise<ArrayLike>

Defined in generated/preprocessing/StandardScaler.ts:582


var_

Get Signature

get var_(): Promise<ArrayLike>

The variance for each feature in the training set. Used to compute scale_. Equal to undefined when with_mean=False and with_std=False.

Returns Promise<ArrayLike>

Defined in generated/preprocessing/StandardScaler.ts:628

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/StandardScaler.ts:101


fit()

fit(opts): Promise<any>

Compute the mean and std to be used for later scaling.

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?ArrayLikeIndividual weights for each sample.
opts.X?ArrayLikeThe data used to compute the mean and standard deviation used for later scaling along the features axis.
opts.y?anyIgnored.

Returns Promise<any>

Defined in generated/preprocessing/StandardScaler.ts:118


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/StandardScaler.ts:162


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/StandardScaler.ts:204


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/StandardScaler.ts:240


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/StandardScaler.ts:62


inverse_transform()

inverse_transform(opts): Promise<ArrayLike>

Scale back the data to the original representation.

Parameters

ParameterTypeDescription
optsobject-
opts.copy?booleanCopy the input X or not.
opts.X?ArrayLikeThe data used to scale along the features axis.

Returns Promise<ArrayLike>

Defined in generated/preprocessing/StandardScaler.ts:274


partial_fit()

partial_fit(opts): Promise<any>

Online computation of mean and std on X for later scaling.

All of X is processed as a single batch. This is intended for cases when fit is not feasible due to very large number of n_samples or because X is read from a continuous stream.

The algorithm for incremental mean and std is given in Equation 1.5a,b in Chan, Tony F., Gene H. Golub, and Randall J. LeVeque. “Algorithms for computing the sample variance: Analysis and recommendations.” The American Statistician 37.3 (1983): 242-247:

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?ArrayLikeIndividual weights for each sample.
opts.X?ArrayLikeThe data used to compute the mean and standard deviation used for later scaling along the features axis.
opts.y?anyIgnored.

Returns Promise<any>

Defined in generated/preprocessing/StandardScaler.ts:317


set_fit_request()

set_fit_request(opts): Promise<any>

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in fit.

Returns Promise<any>

Defined in generated/preprocessing/StandardScaler.ts:363


set_inverse_transform_request()

set_inverse_transform_request(opts): Promise<any>

Request metadata passed to the inverse_transform method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Parameters

ParameterTypeDescription
optsobject-
opts.copy?string | booleanMetadata routing for copy parameter in inverse_transform.

Returns Promise<any>

Defined in generated/preprocessing/StandardScaler.ts:401


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/StandardScaler.ts:437


set_partial_fit_request()

set_partial_fit_request(opts): Promise<any>

Request metadata passed to the partial_fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in partial_fit.

Returns Promise<any>

Defined in generated/preprocessing/StandardScaler.ts:473


set_transform_request()

set_transform_request(opts): Promise<any>

Request metadata passed to the transform method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Parameters

ParameterTypeDescription
optsobject-
opts.copy?string | booleanMetadata routing for copy parameter in transform.

Returns Promise<any>

Defined in generated/preprocessing/StandardScaler.ts:511


transform()

transform(opts): Promise<ArrayLike>

Perform standardization by centering and scaling.

Parameters

ParameterTypeDescription
optsobject-
opts.copy?booleanCopy the input X or not.
opts.X?any[]The data used to scale along the features axis.

Returns Promise<ArrayLike>

Defined in generated/preprocessing/StandardScaler.ts:545