Thursday, November 12, 2026

Standardization vs Min-Max Scaling: Choosing a Data Scaling Method

TL;DR

Adding one scaler can lift a k-nearest neighbors model from 69% to 95% accuracy on the wine dataset. This guide compares standardization, min-max scaling and RobustScaler on real numbers, shows which models need scaling at all, and explains how to avoid leakage. Decision trees, meanwhile, sit the whole thing out, as unbothered by units as a cat by a spreadsheet.

Three takeaways for your next pipeline:

Say you train a k-nearest neighbors model on a wine dataset and it gets 69% accuracy. You add one line of preprocessing, change nothing else, and accuracy jumps to 95%. That line is a scaler, and choosing which one to use is the question most people search for as “standardization vs min-max scaling”.

Here is the short answer. Standardization rescales each feature to mean 0 and standard deviation 1, and it is the safer default for most models. Min-max scaling squeezes each feature into a fixed range, usually 0 to 1, and suits bounded data and models that expect inputs in a range. When your data has outliers, neither is ideal: an outlier-resistant scaler based on the median and interquartile range (scikit-learn’s RobustScaler) usually works better. Tree-based models need no scaling at all. The rest of this article shows each method on real numbers and a real model comparison, with the output from the code.

Key Takeaways

  • Data scaling puts numeric features on comparable ranges so that no feature dominates just because of its units.
  • Standardization (z-score): (x - mean) / std. Use it as the default for linear models, SVMs, neural networks and PCA.
  • Min-max scaling: (x - min) / (max - min). Use it when features have natural bounds, such as pixel values or percentages, or when a model expects inputs in 0 to 1.
  • One extreme value ruins both: in our example, a single outlier squeezed seven normal incomes into 0.00 to 0.01 with min-max scaling.
  • RobustScaler centers on the median and divides by the interquartile range, so outliers barely move the scale for everyone else.
  • Fit the scaler on training data only, inside a pipeline, to avoid leaking test information.

What Is Data Scaling and Why Does It Matter?

Data scaling is the preprocessing step that transforms numeric features so they share a similar range or spread. It matters because many models compare features by size. A k-nearest neighbors model measures distance between rows, so a feature that runs from 278 to 1,680 (proline in the wine dataset below) will drown out one that runs from 0.48 to 1.71 (hue). Gradient-based models train faster and more reliably when features are on similar scales, and regularized models penalize coefficients in a way that depends on feature units.

Scaling does not change the shape of a feature’s distribution. A skewed feature stays skewed after standardization. If you need to change the shape, that is a different tool (a log transform or scikit-learn’s PowerTransformer or QuantileTransformer).

Standardization (Z-Score Scaling)

Standardization subtracts each feature’s mean and divides by its standard deviation, so the result has mean 0 and standard deviation 1. A value of 2 means “two standard deviations above average”. In scikit-learn, this is StandardScaler.

Use it as the default for linear and logistic regression, support vector machines, neural networks, PCA and k-means. The values are not bounded, so a new data point can land at 4 or -6 without breaking anything. Its weakness is outliers: the mean and standard deviation are both pulled toward extreme values, as the example below shows.

Min-Max Scaling (Normalization)

Min-max scaling maps the smallest training value to 0 and the largest to 1, with everything else in between. In scikit-learn, this is MinMaxScaler, and you can choose another range with feature_range. It is often called normalization, though that word is used loosely for several different things.

Use it when features have natural limits, such as image pixels from 0 to 255 or percentages, and for models or methods that expect inputs in a fixed range. Its weakness is that the whole scale depends on two values, the minimum and the maximum. One extreme value sets the range for every other row.

What Happens With an Outlier?

Here are monthly incomes for eight customers. Seven are between 3,200 and 5,000 USD. The eighth is 250,000 USD, perhaps a real high earner or perhaps a data entry error.

import numpy as np
from sklearn.preprocessing import MinMaxScaler, RobustScaler, StandardScaler

# Monthly income in USD for eight customers. The last one is an outlier.
np.set_printoptions(suppress=True)
income = np.array([[3200], [4100], [3900], [4500], [3600], [5000], [4300], [250000]])

for scaler in (StandardScaler(), MinMaxScaler(), RobustScaler()):
    scaled = scaler.fit_transform(income).ravel()
    print(f"{type(scaler).__name__:15}", np.round(scaled, 2))

Output:

StandardScaler  [-0.39 -0.38 -0.38 -0.37 -0.38 -0.37 -0.38  2.65]
MinMaxScaler    [0.   0.   0.   0.01 0.   0.01 0.   1.  ]
RobustScaler    [ -1.25  -0.12  -0.38   0.38  -0.75   1.     0.12 307.25]

Look at the seven normal customers in each row:

  • StandardScaler turns them all into roughly -0.38. The outlier inflated the mean to 34,825 and the standard deviation along with it, so the real differences between 3,200 and 5,000 almost vanish.
  • MinMaxScaler is worse: all seven land between 0.00 and 0.01, and the outlier gets the entire rest of the range.
  • RobustScaler keeps them spread from -1.25 to 1.00. It subtracts the median (4,200) and divides by the interquartile range (800), and neither statistic moves much because of one extreme value. The outlier still stands out at 307.25, which is the honest answer.

The outlier-resistant scaler does not remove outliers. It keeps them from setting the scale for everyone else. You still have to decide whether 250,000 is a real value or an error. scikit-learn’s own example on comparing scalers on data with outliers shows the same effect with plots on the California housing data.

Standardization vs Min-Max Scaling on a Real Dataset

To see the effect on models, the next script runs 5-fold cross-validation on scikit-learn’s wine dataset (178 wines, 13 chemical measurements, 3 grape cultivars) with three models and four preprocessing choices. Each scaler sits inside a pipeline, so it is fit only on the training folds.

from sklearn.datasets import load_wine
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import cross_val_score
from sklearn.neighbors import KNeighborsClassifier
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import MinMaxScaler, RobustScaler, StandardScaler
from sklearn.tree import DecisionTreeClassifier

X, y = load_wine(return_X_y=True)
print("Feature ranges:", round(X.min(axis=0).min(), 2), "to", round(X.max(axis=0).max(), 1))

scalers = {"none": None, "StandardScaler": StandardScaler(),
           "MinMaxScaler": MinMaxScaler(), "RobustScaler": RobustScaler()}
models = {"k-NN": KNeighborsClassifier(),
          "LogisticRegression": LogisticRegression(max_iter=5000),
          "DecisionTree": DecisionTreeClassifier(random_state=0)}

print(f"{'':20}" + "".join(f"{name:>16}" for name in scalers))
for model_name, model in models.items():
    row = f"{model_name:20}"
    for scaler in scalers.values():
        pipe = make_pipeline(scaler, model) if scaler else model
        row += f"{cross_val_score(pipe, X, y, cv=5).mean():16.3f}"
    print(row)

Output (mean accuracy over 5 folds, scikit-learn 1.9):

Feature ranges: 0.13 to 1680.0
                                none  StandardScaler    MinMaxScaler    RobustScaler
k-NN                           0.691           0.949           0.950           0.938
LogisticRegression             0.961           0.983           0.978           0.989
DecisionTree                   0.888           0.888           0.888           0.888

Three results are worth reading closely:

  • k-NN needs scaling. Accuracy goes from 0.691 to about 0.95 with any scaler. Without it, distances are almost entirely decided by proline, the feature with the biggest numbers.
  • Logistic regression gains and trains more reliably. Accuracy rises from 0.961 to 0.978 to 0.989. On the unscaled data, scikit-learn also printed a ConvergenceWarning even with 5,000 iterations allowed, a common sign that features need scaling.
  • The decision tree does not care. It scored 0.888 in every column. Trees split on one feature at a time using thresholds, and rescaling a feature moves the threshold without changing which rows fall on each side.

Between standardization and min-max scaling, the differences here are within a point or two. That is typical. The choice between scaling and no scaling matters much more than the choice of scaler, unless your data has outliers.

Which Scaler Should You Use?

Situation Scaler
General default for linear models, SVMs, neural networks, PCA, k-means StandardScaler
Features with natural bounds (pixels, percentages), or a model that expects 0 to 1 MinMaxScaler
Outliers you want to keep but not let dominate RobustScaler
Sparse data (many zeros) that must stay sparse MaxAbsScaler
Decision trees, random forests, gradient boosting No scaling needed

Scaling matters for clustering too. If you cluster locations, scale and units interact in ways that are easy to miss, as our article on k-means clustering for spatial analysis shows. And when you report a gain from scaling, compare it against a baseline first. A dummy classifier baseline tells you the accuracy you would get by guessing.

Fit the Scaler on Training Data Only

A scaler learns statistics (mean, minimum, median) from the data you fit it on. If you fit it on the full dataset before splitting, the test rows have already shaped the scale, and your evaluation is slightly optimistic. The fix is simple: put the scaler in a Pipeline with the model, as in the comparison above. Then fit learns the scaling from training data only, and predict applies the same learned scaling to new data. The RobustScaler reference page shows the same pattern: the median and interquartile range are learned in fit and reused by transform on later data.

Back to the Wine Model

The jump from 69% to 95% in the opening was not a new model. It was k-NN finally measuring distance across all 13 measurements instead of just one. If your features are roughly well behaved, start with standardization. If they have natural bounds, min-max scaling is fine. If one customer earns 250,000 a month, use the median-based scaler and look hard at that row.

Frequently Asked Questions

Is Normalization the Same as Min-Max Scaling?

Usually, but not always. Many tutorials use “normalization” to mean min-max scaling. In scikit-learn, though, the Normalizer class does something different: it rescales each row to unit length, which is used for text and other vector data.

Should I Scale the Target Variable?

For most models it is not required. It can help neural networks when the target has a very large range. If you scale the target, use TransformedTargetRegressor so predictions are converted back to the original units automatically.

Do I Need to Scale Data for Random Forests?

No. Tree-based models, including random forests and gradient boosting, split each feature at a threshold, and rescaling does not change which rows fall on each side. Our decision tree scored exactly the same with and without scaling.

Does Standardization Make Data Normally Distributed?

No. It shifts and rescales the values, but the shape stays the same, so a skewed feature is still skewed. To make a feature closer to normal, use a log transform, PowerTransformer or QuantileTransformer.

Disclaimer: The content on this website reflects the views of contributing authors and not necessarily those of Generative AI Lab. This site may contain sponsored content, affiliate links, and material created with generative AI. Thank you for your support.

Generative AI Lab mascot
Generative AI Lab Editorial Team
Articles researched, written and edited by the Generative AI Lab team. About Generative AI Lab

Must read

- Advertisement -spot_img

More articles

- Advertisement -spot_img

Latest articles

Available for Amazon Prime