lazymatrix.standardize
LazyMatrix for Python · 0.1.1
standardize(
X: typing.Any,
*,
center: bool = True,
scale: bool = True
) -> lazymatrix.LazyMatrixFit column means and population scales and return a lazy matrix.
Parameters
X : numpy.ndarray or scipy.sparse matrix or array
Two-dimensional real numeric input. Sparse input must use CSR or CSC. The returned matrix owns a copy of the raw values in float64 storage.
center : bool, default=True
Subtract each column's mean during operations.
scale : bool, default=True
Divide each column by its population standard deviation, replacing exact zero scales with one.
Returns
LazyMatrix
A matrix retaining fitted column parameters without constructing a normalized copy. Statistics are fitted immediately.
Raises
TypeError
If the input type, storage format, values, or options are unsupported.
ValueError
If the input is not two-dimensional or has no rows.
Notes
This first release fits each input independently. Reusing fitted normalization on new observations is not yet exposed by the Python API.
Examples
>>> import numpy as np
>>> from scipy import sparse
>>> from lazymatrix import standardize
>>> Z = standardize(sparse.csr_matrix([[1.0, 0.0], [3.0, 4.0]]))
>>> Z @ np.ones(2)
array([-2., 2.])
