Apply a power transform featurewise to make data more Gaussian-like.
Power transforms are a family of parametric, monotonic transformations
that are applied to make data more Gaussian-like. This is useful for
modeling issues related to heteroscedasticity (non-constant variance),
or other situations where normality is desired.
Currently, PowerTransformer supports the Box-Cox transform and the
Yeo-Johnson transform. The optimal parameter for stabilizing variance and
minimizing skewness is estimated through maximum likelihood.
Box-Cox requires input data to be strictly positive, while Yeo-Johnson
supports both positive or negative data.
By default, zero-mean, unit-variance normalization is applied to the
transformed data.
Estimate the optimal parameter lambda for each feature.
The optimal lambda parameter for minimizing skewness is estimated on
each feature independently using maximum likelihood.
Parameters:
X : array-like of shape (n_samples, n_features)
The data used to estimate the optimal transformation parameters.
y : None
Ignored.
Returns:
self : object
Fitted transformer.
fit_transform(X, y=None)
Fit PowerTransformer to X, then transform X.
Parameters:
X : array-like of shape (n_samples, n_features)
The data used to estimate the optimal transformation parameters
and to be transformed using a power transformation.
y : Ignored
Not used, present for API consistency by convention.
Returns:
X_new : ndarray of shape (n_samples, n_features)
Transformed data.
get_feature_names_out(input_features=None)
Get output feature names for transformation.
Parameters:
input_features : array-like of str or None, default=None
Input features.
If input_features is None, then feature_names_in_ is
used as feature names in. If feature_names_in_ is not defined,
then the following input feature names are generated:
["x0","x1",...,"x(n_features_in_-1)"].
If input_features is an array-like, then input_features must
match feature_names_in_ if feature_names_in_ is defined.
Returns:
feature_names_out : ndarray of str objects
Same as input features.
get_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing
mechanism works.
The method works on simple estimators as well as on nested objects
(such as Pipeline). The latter have
parameters of the form <component>__<parameter> so that it’s
possible to update each component of a nested object.
Parameters:
**params : dict
Estimator parameters.
Returns:
self : estimator instance
Estimator instance.
transform(X)
Apply the power transform to each feature using the fitted lambdas.
Parameters:
X : array-like of shape (n_samples, n_features)
The data to be transformed using a power transformation.
Returns:
X_trans : ndarray of shape (n_samples, n_features)