MCPcopy Create free account
hub / github.com/scikit-learn/scikit-learn / power_transform

Function power_transform

sklearn/preprocessing/_data.py:3659–3759  ·  view source on GitHub ↗

Parametric, monotonic transformation 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

(X, method="yeo-johnson", *, standardize=True, copy=True)

Source from the content-addressed store, hash-verified

3657 prefer_skip_nested_validation=False,
3658)
3659def power_transform(X, method="yeo-johnson", *, standardize=True, copy=True):
3660 """Parametric, monotonic transformation to make data more Gaussian-like.
3661
3662 Power transforms are a family of parametric, monotonic transformations
3663 that are applied to make data more Gaussian-like. This is useful for
3664 modeling issues related to heteroscedasticity (non-constant variance),
3665 or other situations where normality is desired.
3666
3667 Currently, power_transform supports the Box-Cox transform and the
3668 Yeo-Johnson transform. The optimal parameter for stabilizing variance and
3669 minimizing skewness is estimated through maximum likelihood.
3670
3671 Box-Cox requires input data to be strictly positive, while Yeo-Johnson
3672 supports both positive or negative data.
3673
3674 By default, zero-mean, unit-variance normalization is applied to the
3675 transformed data.
3676
3677 Read more in the :ref:`User Guide <preprocessing_transformer>`.
3678
3679 Parameters
3680 ----------
3681 X : array-like of shape (n_samples, n_features)
3682 The data to be transformed using a power transformation.
3683
3684 method : {'yeo-johnson', 'box-cox'}, default='yeo-johnson'
3685 The power transform method. Available methods are:
3686
3687 - 'yeo-johnson' [1]_, works with positive and negative values
3688 - 'box-cox' [2]_, only works with strictly positive values
3689
3690 .. versionchanged:: 0.23
3691 The default value of the `method` parameter changed from
3692 'box-cox' to 'yeo-johnson' in 0.23.
3693
3694 standardize : bool, default=True
3695 Set to True to apply zero-mean, unit-variance normalization to the
3696 transformed output.
3697
3698 copy : bool, default=True
3699 If False, try to avoid a copy and transform in place.
3700 This is not guaranteed to always work in place; e.g. if the data is
3701 a numpy array with an int dtype, a copy will be returned even with
3702 copy=False.
3703
3704 Returns
3705 -------
3706 X_trans : ndarray of shape (n_samples, n_features)
3707 The transformed data.
3708
3709 See Also
3710 --------
3711 PowerTransformer : Equivalent transformation with the
3712 Transformer API (e.g. as part of a preprocessing
3713 :class:`~sklearn.pipeline.Pipeline`).
3714
3715 quantile_transform : Maps data to a standard normal distribution with
3716 the parameter `output_distribution='normal'`.

Calls 2

fit_transformMethod · 0.95
PowerTransformerClass · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…