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

Class PowerTransformer

sklearn/preprocessing/_data.py:3257–3652  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

3255
3256
3257class PowerTransformer(OneToOneFeatureMixin, TransformerMixin, BaseEstimator):
3258 """Apply a power transform featurewise to make data more Gaussian-like.
3259
3260 Power transforms are a family of parametric, monotonic transformations
3261 that are applied to make data more Gaussian-like. This is useful for
3262 modeling issues related to heteroscedasticity (non-constant variance),
3263 or other situations where normality is desired.
3264
3265 Currently, PowerTransformer supports the Box-Cox transform and the
3266 Yeo-Johnson transform. The optimal parameter for stabilizing variance and
3267 minimizing skewness is estimated through maximum likelihood.
3268
3269 Box-Cox requires input data to be strictly positive, while Yeo-Johnson
3270 supports both positive or negative data.
3271
3272 By default, zero-mean, unit-variance normalization is applied to the
3273 transformed data.
3274
3275 For an example visualization, refer to :ref:`Compare PowerTransformer with
3276 other scalers <plot_all_scaling_power_transformer_section>`. To see the
3277 effect of Box-Cox and Yeo-Johnson transformations on different
3278 distributions, see:
3279 :ref:`sphx_glr_auto_examples_preprocessing_plot_map_data_to_normal.py`.
3280
3281 Read more in the :ref:`User Guide <preprocessing_transformer>`.
3282
3283 .. versionadded:: 0.20
3284
3285 Parameters
3286 ----------
3287 method : {'yeo-johnson', 'box-cox'}, default='yeo-johnson'
3288 The power transform method. Available methods are:
3289
3290 - 'yeo-johnson' [1]_, works with positive and negative values
3291 - 'box-cox' [2]_, only works with strictly positive values
3292
3293 standardize : bool, default=True
3294 Set to True to apply zero-mean, unit-variance normalization to the
3295 transformed output.
3296
3297 copy : bool, default=True
3298 Set to False to perform inplace computation during transformation.
3299
3300 Attributes
3301 ----------
3302 lambdas_ : ndarray of float of shape (n_features,)
3303 The parameters of the power transformation for the selected features.
3304
3305 n_features_in_ : int
3306 Number of features seen during :term:`fit`.
3307
3308 .. versionadded:: 0.24
3309
3310 feature_names_in_ : ndarray of shape (`n_features_in_`,)
3311 Names of features seen during :term:`fit`. Defined only when `X`
3312 has feature names that are all strings.
3313
3314 .. versionadded:: 1.0

Calls 1

StrOptionsClass · 0.90

Used in the wild real call sites across dependent graphs

searching dependent graphs…