Notes

Normalization

When you train a model, your features can arrive in wildly different “units”: income in dollars, age in years, clicks per day, and a binary flag. Normalization is the family of preprocessing tricks that puts numeric features onto a more comparable scale so the model doesn’t get distracted by raw magnitude.

What normalization does

In supervised learning, normalization usually means rescaling a feature using a consistent rule learned from the training data, then applying that same rule to validation/test data. Common forms include:

  • Min-max scaling: maps values into a fixed range (commonly 0 to 1).
  • Standardization (frequently grouped under “normalization” in practice): shifts to zero mean and scales to unit variance.
  • Vector normalization: scales each sample so its feature vector has length 1 (useful with cosine similarity).

Why it matters for models

Many algorithms are sensitive to feature scale. With k-nearest neighbors or SVMs, distances can be dominated by a large-scale feature (e.g., “annual income”) while ignoring smaller-scale ones (e.g., “number of late payments”). With linear/logistic regression trained by gradient descent, normalization makes optimization behave better and makes regularization (L1/L2) treat coefficients more fairly. Tree-based models (like random forests) care much less because they split by thresholds, not distances.

How it’s used correctly

You fit the scaler on the training split only, then transform everything else—otherwise you leak information. In scikit-learn this is typically done with:

from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression

model = make_pipeline(StandardScaler(), LogisticRegression())

Normalization is a feature-scaling preprocessing step that transforms numeric inputs to a common scale, typically by rescaling values to a fixed range (e.g., min–max normalization to [0,1]) or to unit length (L2 normalization). It matters because many supervised models and optimizers are sensitive to feature magnitude; normalization stabilizes training, improves numerical conditioning, and prevents large-scale features from dominating distance-, gradient-, or regularization-based learning.

Imagine you’re comparing people’s heights (in centimeters) and incomes (in dollars). The income numbers are huge compared to heights, so if you just “add everything up,” income can drown out height. Normalization is like putting different measurements onto a similar scale so they’re easier to compare fairly.

In supervised learning, models learn from examples by looking for patterns in the input data. If one feature has much bigger numbers than others, it can unfairly dominate the learning process. Normalization rescales features so each one has a more balanced influence, which often helps training behave more smoothly and makes predictions more reliable.