Documentation
Classes
StandardScaler

StandardScaler

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

The standard score of a sample x is calculated as:

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new StandardScaler(opts?: object): StandardScaler;

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.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. Default Value true
opts.with_std?booleanIf true, scale the data to unit variance (or equivalently, unit standard deviation). Default Value true

Returns

StandardScaler

Defined in: generated/preprocessing/StandardScaler.ts:23 (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/StandardScaler.ts:104 (opens in a new tab)

fit()

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

Signature

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

Parameters

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

Returns

Promise<any>

Defined in: generated/preprocessing/StandardScaler.ts:121 (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/StandardScaler.ts:170 (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/StandardScaler.ts:217 (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/StandardScaler.ts:255 (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/StandardScaler.ts:62 (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 data used to scale along the features axis.
opts.copy?booleanCopy the input X or not.

Returns

Promise<ArrayLike>

Defined in: generated/preprocessing/StandardScaler.ts:290 (opens in a new tab)

partial_fit()

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:

Signature

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

Parameters

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

Returns

Promise<any>

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

set_fit_request()

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:

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample\_weight parameter in fit.

Returns

Promise<any>

Defined in: generated/preprocessing/StandardScaler.ts:387 (opens in a new tab)

set_inverse_transform_request()

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:

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.copy?string | booleanMetadata routing for copy parameter in inverse\_transform.

Returns

Promise<any>

Defined in: generated/preprocessing/StandardScaler.ts:426 (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/StandardScaler.ts:464 (opens in a new tab)

set_partial_fit_request()

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:

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample\_weight parameter in partial\_fit.

Returns

Promise<any>

Defined in: generated/preprocessing/StandardScaler.ts:501 (opens in a new tab)

set_transform_request()

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:

Signature

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

Parameters

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

Returns

Promise<any>

Defined in: generated/preprocessing/StandardScaler.ts:541 (opens in a new tab)

transform()

Perform standardization by centering and scaling.

Signature

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

Parameters

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

Returns

Promise<ArrayLike>

Defined in: generated/preprocessing/StandardScaler.ts:576 (opens in a new tab)

Properties

_isDisposed

boolean = false

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

_isInitialized

boolean = false

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

_py

PythonBridge

Defined in: generated/preprocessing/StandardScaler.ts:19 (opens in a new tab)

id

string

Defined in: generated/preprocessing/StandardScaler.ts:16 (opens in a new tab)

opts

any

Defined in: generated/preprocessing/StandardScaler.ts:17 (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/StandardScaler.ts:710 (opens in a new tab)

mean_

The mean value for each feature in the training set. Equal to undefined when with\_mean=False and with\_std=False.

Signature

mean_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/preprocessing/StandardScaler.ts:639 (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/StandardScaler.ts:685 (opens in a new tab)

n_samples_seen_

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.

Signature

n_samples_seen_(): Promise<number | ArrayLike>;

Returns

Promise<number | ArrayLike>

Defined in: generated/preprocessing/StandardScaler.ts:735 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/preprocessing/StandardScaler.ts:49 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/preprocessing/StandardScaler.ts:53 (opens in a new tab)

scale_

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.

Signature

scale_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/preprocessing/StandardScaler.ts:616 (opens in a new tab)

var_

The variance for each feature in the training set. Used to compute scale\_. Equal to undefined when with\_mean=False and with\_std=False.

Signature

var_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/preprocessing/StandardScaler.ts:662 (opens in a new tab)