Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Scikit-Learn · Class

PowerTransformer

PowerTransformer applies a feature-wise Box-Cox or Yeo-Johnson transformation to make data more Gaussian-like. It estimates each feature's power parameter by maximum likelihood and standardizes the result by default.

How it works

PowerTransformer applies a monotonic Box-Cox or Yeo-Johnson transformation independently to each feature. It estimates each feature's parameter by maximum likelihood and, by default, standardizes the transformed columns to zero mean and unit variance.

Syntax

class sklearn.preprocessing.PowerTransformer(*, method='yeo-johnson', standardize=True, copy=True)

Parameters

NameTypeDescription
method{'yeo-johnson', 'box-cox'}, default='yeo-johnson'Power transform method: 'yeo-johnson' or 'box-cox'.
standardizebool, default=TrueWhether to apply zero-mean, unit-variance normalization after transforming.
copybool, default=TrueWhether to copy input data rather than attempt in-place computation during transformation.

Returns

A fitted PowerTransformer instance from fit; transformed feature data from transform or fit_transform.

Key points

  • The transformation is applied independently to each feature to make its distribution more Gaussian-like.
  • Each feature receives a power parameter selected by maximum likelihood to stabilize variance and reduce skewness.
  • The class offers two transformation families: Box-Cox and Yeo-Johnson.
  • Unless disabled, transformed features are normalized to zero mean and unit variance.
  • Yeo-Johnson is suitable for features containing both positive and negative observations.
  • Box-Cox can be used only when every input value is strictly greater than zero.

Common mistakes

  • Choose Yeo-Johnson when any feature contains zero or negative values; Box-Cox accepts only strictly positive input.
  • With copy=False, transformation may modify the input data in place.

Example: Transform feature distributions

from sklearn.preprocessing import PowerTransformer

X = [[1.0, 2.0], [3.0, 2.0], [4.0, 5.0]]
transformer = PowerTransformer(method="yeo-johnson")
X_transformed = transformer.fit_transform(X)
print(X_transformed)
print(transformer.lambdas_)

Fits one maximum-likelihood power parameter per feature, then transforms the data and applies the default standardization.

When to use it

Reduce feature skewness

Regression or classification features have strongly skewed distributions.

Stabilize non-constant variance

Feature variance changes substantially across the range of observations.

Transform signed data with Yeo-Johnson

A feature matrix includes zero or negative measurements.

Use Box-Cox for positive data

A strictly positive matrix benefits from a power-family transformation.

Interview questions

QWhat problem does PowerTransformer solve, and how are its parameters learned?

It transforms each feature with a monotonic power transformation and estimates that feature's lambda independently by maximum likelihood. The goal is to make the feature more Gaussian-like while stabilizing variance and reducing skewness.

Follow-up: Which method handles negative values? Yeo-Johnson does; Box-Cox requires every input value to be strictly positive.

QWhen would you choose Yeo-Johnson instead of Box-Cox?

The default method is Yeo-Johnson, which supports positive and negative values. Box-Cox is the alternative and is restricted to strictly positive data.

Follow-up: What additional default behavior occurs after the nonlinear transform? The output is standardized to zero mean and unit variance.

QWhat does the standardize parameter control?

Its default standardize=True applies zero-mean, unit-variance normalization to the transformed output. Set standardize=False when that scaling should not be performed.

Follow-up: How can the fitted transformation be reused on new data? Call transform on new samples after fitting, or use fit_transform for the training data.

  • sklearn.preprocessing.power_transform
  • sklearn.preprocessing.QuantileTransformer
  • sklearn.preprocessing.FunctionTransformer

Source: PowerTransformer. Checked 2026-10-15.