mojolearn.Normalizer#

class mojolearn.Normalizer(norm='l2', *, copy=True)[source]#

Bases: _PrepBase

Scale each row to unit norm.

Follows scikit-learn’s Normalizer. Each row is divided by its 'l1', 'l2' or 'max' norm; a row of zeros is left unchanged. The transformer is stateless: fit only records the number of columns. Input and output are float32.

Parameters:
  • norm ({‘l1’, ‘l2’, ‘max’}, default ‘l2’) – Norm used for each row.

  • copy (bool, default True) – Accepted for scikit-learn compatibility; transform always returns a new array.

Variables:
  • n_features_in_ (int) – Number of columns seen in fit.

  • numeric_mode_ (str) – Numeric mode at fit time; transform runs in the same mode.

Examples

>>> import numpy as np, mojolearn
>>> X = np.random.default_rng(0).random((1000, 8), dtype=np.float32)
>>> Xt = mojolearn.Normalizer(norm="l1").fit_transform(X)
__init__(norm='l2', *, copy=True)[source]#

Methods

fit(X[, y])

fit_transform(X[, y])

Fit to X, then transform X.

get_params([deep])

Return the constructor parameters as a dict.

set_params(**params)

Set constructor parameters.

transform(X[, copy])