mojolearn.PowerTransformer#
- class mojolearn.PowerTransformer(method='yeo-johnson', *, standardize=True, copy=True)[source]#
Bases:
_PrepBaseApply a power transform per feature to make the data more Gaussian.
Follows scikit-learn’s
PowerTransformer. Each column gets the Yeo-Johnson or Box-Cox transform with the lambda that maximizes the log-likelihood, then (by default) is standardized to zero mean and unit variance. Lambda is searched in[-8, 8], so fitted lambdas can differ slightly from scikit-learn’s. NaN values are ignored in fit and kept as NaN. Input and output are float32.- Parameters:
method ({‘yeo-johnson’, ‘box-cox’}, default ‘yeo-johnson’) –
'box-cox'requires strictly positive data (ValueErrorotherwise).standardize (bool, default True) – Standardize the transformed columns.
copy (bool, default True) – Accepted for scikit-learn compatibility; transform always returns a new array.
- Variables:
Notes
inverse_transformundoes the standardization, then the power transform.Examples
>>> import numpy as np, mojolearn >>> X = np.random.default_rng(0).lognormal(size=(1000, 4)).astype(np.float32) >>> Xt = mojolearn.PowerTransformer().fit_transform(X)
Methods
fit(X[, y])fit_transform(X[, y])Fit to
X, then transformX.get_params([deep])Return the constructor parameters as a dict.
inverse_transform(X)set_params(**params)Set constructor parameters.
transform(X)