StandardScaler-class: class StandardScaler

StandardScalerR Documentation

class StandardScaler

Description

A class for transforming features by removing the mean and scaling to unit standard deviation.

Usage

zscore(x, .mean, .sd)

inverse_zscore(x, .mean, .sd)

Super class

deepANN::Scaler -> StandardScaler

Public fields

mean

('NULL' | numeric vector)
The mean value for each feature.

std

('NULL' | numeric vector)
The standard deviation for each feature.

with_mean

('NULL' | logical)
If true, center the data before scaling.

with_std

('NULL' | logical)
If true, scale the data to unit standard deviation.

Methods

Public methods


Method new()

Creates a new instance of this R6 class.

Usage
StandardScaler$new(with_mean = TRUE, with_std = TRUE)
Arguments
with_mean

If true, center the data before scaling.

with_std

if true, scale the data to unit standard deviation


Method fit()

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

Usage
StandardScaler$fit(X, axis = 1)
Arguments
X

The data used to compute the per-feature mean and std used for later scaling along the features axis.

axis

The axis along computation is applied.

Returns

The instance self itself.


Method transform()

Perform standardization by centering and scaling.

Usage
StandardScaler$transform(X, axis = 1, order = c("C", "F"))
Arguments
X

The data that will be transformed.

axis

The axis along scaling is applied.

order

The order in which elements of data should be read during scaling. By default, the order is equivalent to the C-style ordering and means elements should be read in row-major order. In opposite, the Fortran-style ordering means elements should be read in column-major order.

Returns

The transformed X.


Method fit_transform()

Run fit() and transform().

Usage
StandardScaler$fit_transform(X, axis = 1, order = c("C", "F"))
Arguments
X

The data that will be transformed.

axis

The axis along scaling is applied.

order

The order in which elements of data should be read during scaling. By default, the order is equivalent to the C-style ordering and means elements should be read in row-major order. In opposite, the Fortran-style ordering means elements should be read in column-major order.

Returns

The transformed X.


Method inverse_transform()

Scale back X to the original representation.

Usage
StandardScaler$inverse_transform(X, axis = 1, order = c("C", "F"))
Arguments
X

The data that will be transformed.

axis

The axis along scaling is applied.

order

The order in which elements of data should be read during scaling. By default, the order is equivalent to the C-style ordering and means elements should be read in row-major order. In opposite, the Fortran-style ordering means elements should be read in column-major order.

Returns

The transformed X.


Method clone()

The objects of this class are cloneable with this method.

Usage
StandardScaler$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

a <- random_int(dim = c(6, 4), min = 1, max = 30)
scaler <- StandardScaler$new()
xt <- scaler$fit_transform(a)
scaler$inverse_transform(xt)

a <- random_int(dim = c(4, 3, 2), min = 1, max = 30)
scaler <- StandardScaler$new()
xt <- scaler$fit_transform(a, axis = c(1, 2))
scaler$inverse_transform(xt, axis = c(1, 2))

stschn/deepANN documentation built on June 25, 2024, 7:27 a.m.