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

Scikit-Learn · Class

MinMaxScaler

MinMaxScaler linearly maps each feature independently into a chosen interval, defaulting to [0, 1]. It learns feature extrema during fitting and reuses them for later transformations.

How it works

MinMaxScaler learns each feature's training-set minimum and maximum, maps those values into feature_range, and applies the same linear mapping to later data. It preserves feature ordering and relative linear spacing, but does not make distributions less sensitive to outliers.

Syntax

class sklearn.preprocessing.MinMaxScaler(feature_range=(0, 1), *, copy=True, clip=False)

Parameters

NameTypeDescription
feature_rangetuple (min, max), default=(0, 1)Desired range of transformed data.
clipbool, default=FalseSet to True to clip transformed values of held-out data to the provided feature range.

Returns

The class provides transformed arrays through its transform and fit_transform methods; the page documents learned attributes including data_min_, data_max_, data_range_, scale_, min_, n_features_in_, and n_samples_seen_.

Key points

  • Use the estimator when every feature should be mapped independently into a chosen interval.
  • Each column receives its own learned offset and scale rather than sharing statistics across columns.
  • The operation first standardizes a feature using its training minimum and maximum, then applies the requested range.
  • It is a range-based alternative to standardization centered at zero with unit variance.
  • For fitted data, the largest observed value in a feature maps to the upper endpoint of feature_range.
  • For fitted data, the smallest observed value in a feature maps to the lower endpoint of feature_range.
  • The clip option controls whether transformed held-out observations are forced into the configured interval.

Common mistakes

  • Outliers remain influential because the learned extrema determine the linear mapping.
  • With clip=True, transformed held-out values outside the fitted range are clipped to feature_range; otherwise they can fall outside it.

Example: Scale training and test features

from sklearn.preprocessing import MinMaxScaler

X_train = [[1., 10.], [2., 20.], [3., 30.]]
X_test = [[4., 25.]]

scaler = MinMaxScaler(feature_range=(-1, 1))
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)
print(X_train_scaled)
print(X_test_scaled)

Fit the scaler on training data, then reuse it to transform both training and held-out data.

When to use it

Bound feature magnitudes

A model performs better or trains more consistently when numeric inputs occupy a bounded interval.

Align feature ranges

Different columns use incompatible units or numeric scales.

Reuse fitted preprocessing

A pipeline must apply identical preprocessing to training, validation, and production data.

Clip deployment values

An application requires transformed held-out values to stay within a prescribed interval.

Interview questions

QHow does MinMaxScaler transform data?

It learns a separate minimum and maximum for every feature during fit, then linearly maps each feature into feature_range. The default target interval is [0, 1].

Follow-up: What happens to a value outside the training range? Unless clipping is enabled, the same linear mapping can produce a value outside feature_range.

QHow can the output interval be customized?

The default feature_range is (0, 1), but a different two-element range can be supplied. The lower and upper values define the destination interval for each feature's fitted minimum and maximum.

Follow-up: Can the range be reversed? The documented parameter is a tuple (min, max), so callers should provide a valid intended lower-to-upper range.

QWhat is the main limitation of MinMaxScaler?

It is sensitive to outliers because each feature's extrema determine the scale. It rescales outliers into the requested interval rather than reducing their influence.

Follow-up: When might another scaler be preferable? Choose a method whose documented behavior is more appropriate when extreme observations should not dominate the scaling.

  • StandardScaler
  • RobustScaler
  • MaxAbsScaler
  • minmax_scale

Source: MinMaxScaler. Checked 2026-10-15.