Skip to content

lazymatrix.NormalizationParams ​

LazyMatrix for Python · 0.2.0

Source

python
NormalizationParams(
    ncols: int,
    *,
    centers: typing.Any = None,
    scales: typing.Any = None
)

Reusable float64 column centers and scales, independent of raw storage.

Parameters ​

ncols : int

Nonnegative number of columns, retained even when both components are None.

centers : array-like or None, default=None

One real value per column. Copied without changing nonfinite values.

scales : array-like or None, default=None

One real, nonzero value per column. Negative and nonfinite values are preserved. Positive and negative zero raise ValueError with the column index, including values that round to zero in float64.

Notes ​

Obtain fitted parameters with Z.normalization. Reconstruct Rust's NormalizationParams::from_parts(ncols, centers, scales) using the same values and None components. Arrays returned by properties are independent copies. Parameters never update when transformed data changes.

A portable checkpoint consists of an integer ncols and optional one-dimensional float64 centers and scales arrays in feature order. For example, save ncols and only active arrays with numpy.savez, and load with allow_pickle=False. Omitted arrays mean None; do not replace them with zeros or ones because inactive components have different IEEE semantics. This preserves NaN and infinity without nonstandard JSON values.

__init__ {#init} ​

python
__init__(
    ncols: int,
    *,
    centers: typing.Any = None,
    scales: typing.Any = None
) -> None

Source

ncols ​

python
ncols(self) -> int

Source

The number of columns expected by these parameters.

centers ​

python
centers(self) -> NDArray[np.float64] | None

Source

An independent copy of column centers, or None when inactive.

scales ​

python
scales(self) -> NDArray[np.float64] | None

Source

An independent copy of column scales, or None when inactive.

transform ​

python
transform(X: typing.Any) -> "LazyMatrix"

Source

Wrap new raw data using these parameters without fitting statistics.

X must have ncols columns. Input ownership, supported storage, and lazy operations follow LazyMatrix. A column-count mismatch raises ValueError.

Released under the MIT and Apache 2.0 licenses.