Skip to content

Online Scaling and Preproessing

API Reference

rolch.OnlineScaler

__init__

__init__(forget: float = 0.0, to_scale: bool | ndarray = True)

The online scaler allows for incremental updating and scaling of matrices.

Parameters:

Name Type Description Default
forget float

The forget factor. Older observations will be exponentially discounted. Defaults to 0.0.

0.0
to_scale bool | ndarray

The variables to scale. True implies all variables will be scaled. False implies no variables will be scaled. An np.ndarray of type bool or int implies that the columns X[:, to_scale] will be scaled, all other columns will not be scaled. Defaults to True.

True

_prepare_estimator

_prepare_estimator(X: ndarray)

Add derived attributes to estimator

fit

fit(X: ndarray) -> None

Fit the OnlineScaler() Object for the first time.

Parameters:

Name Type Description Default
X ndarray

Matrix of covariates X.

required

inverse_transform

inverse_transform(X: ndarray) -> np.ndarray

Back-transform a scaled X matrix to the original domain.

Parameters:

Name Type Description Default
X ndarray

Scaled X matrix.

required

Returns:

Type Description
ndarray

np.ndarray: Scaled back to the original scale.

partial_fit

partial_fit(X: ndarray) -> None

Update the OnlineScaler() for new rows of X.

Parameters:

Name Type Description Default
X ndarray

New data for X.

required

transform

transform(X: ndarray) -> np.ndarray

Transform X to a mean-std scaled matrix.

Parameters:

Name Type Description Default
X ndarray

X matrix for covariates.

required

Returns:

Type Description
ndarray

np.ndarray: Scaled X matrix.

update

update(X: ndarray) -> None

Wrapper for partial_fit to align API.