Skip to content

Online Scaling and Preproessing

API Reference

ondil.OnlineScaler

Bases: OndilEstimatorMixin, TransformerMixin, BaseEstimator

std_ property

std_: float | ndarray

Standard deviation of the scaled variables.

__init__

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

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

Parameters:

  • forget (float, default: 0.0 ) –

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

  • to_scale (bool | ndarray, default: True ) –

    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.

fit

fit(
    X: ndarray,
    y: None = None,
    sample_weight: ndarray | None = None,
) -> OnlineScaler

Fit the OnlineScaler() Object for the first time.

Parameters:

  • X (ndarray) –

    Matrix of covariates X.

  • y (None, default: None ) –

    Not used, present for compatibility with sklearn API. Defaults to None.

  • sample_weight (ndarray, default: None ) –

    Weights for each sample. Defaults to None (uniform weights).

update

update(X: ndarray, y=None, sample_weight: ndarray = None)

Update the OnlineScaler() for new rows of X.

Parameters:

  • X (ndarray) –

    New data for X.

  • y (None, default: None ) –

    Not used, present for compatibility with sklearn API. Defaults to None.

  • sample_weight (ndarray, default: None ) –

    Weights for each sample. Defaults to None (uniform weights).

transform

transform(X: ndarray) -> np.ndarray

Transform X to a mean-std scaled matrix.

Parameters:

  • X (ndarray) –

    X matrix for covariates.

Returns:

  • ndarray

    np.ndarray: Scaled X matrix.

inverse_transform

inverse_transform(X: ndarray) -> np.ndarray

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

Parameters:

  • X (ndarray) –

    Scaled X matrix.

Returns:

  • ndarray

    np.ndarray: Scaled back to the original scale.