0Pricing
Data Science Academy · Lesson

Scale and Normalize Numbers

Putting features on a fair footing.

Scale and Normalize Numbers is a free Data Science Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Data Science Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why Scale Numbers

Age ranges 0 to 90 while income ranges to millions. Without scaling, the bigger numbers dominate and quietly drown out the smaller ones. ⚖️

Distance-Based Models Care

Models that measure distance, like k-NN and k-means, are very sensitive to scale. Unscaled features hand all the power to the largest column.

Standardization

Standardization rescales a column to mean 0 and standard deviation 1. Values become how many standard deviations they sit from the average.

StandardScaler

The StandardScaler applies standardization for you. Fit it on your data, then transform any column into z-scores.

from sklearn.preprocessing import StandardScaler
z = StandardScaler().fit_transform(df[['age']])

Normalization

Normalization squeezes values into a fixed range, usually 0 to 1. The smallest value maps to 0 and the largest to 1.

MinMaxScaler

Reach for MinMaxScaler to rescale into 0 to 1. It keeps the shape of your data while bounding the range.

from sklearn.preprocessing import MinMaxScaler
m = MinMaxScaler().fit_transform(df[['age']])

Standardize or Normalize

Use standardization when data is roughly bell-shaped or has outliers. Pick normalization when you need a strict 0 to 1 bound.

Outliers Hurt MinMax

A single huge value can squash everything else near zero under MinMax. When outliers dominate, RobustScaler resists them better.

from sklearn.preprocessing import RobustScaler
r = RobustScaler().fit_transform(df[['income']])

Fit on Train Only

Fit the scaler on training data alone, then transform the test set. Fitting on everything leaks test information into your model.

scaler.fit(X_train)
X_test_scaled = scaler.transform(X_test)

Scale Inside a Pipeline

Bundle the scaler with your model in a Pipeline. It then fits only on the training fold during cross-validation, blocking leakage for free.

from sklearn.pipeline import make_pipeline
pipe = make_pipeline(StandardScaler(), model)

Trees Do Not Need It

Tree-based models like random forests split on thresholds, so scaling rarely changes results. Save scaling for distance and linear methods.

Quick Check

You need every feature rescaled to a strict 0-to-1 range. Which scaler fits?

Recap: Scaling

You put features on a fair footing: StandardScaler for z-scores, MinMaxScaler for 0 to 1, RobustScaler for outliers. Always fit on train only. 🎉

Frequently asked questions

Is the “Scale and Normalize Numbers” lesson free?

Yes — the full text of “Scale and Normalize Numbers” is free to read here on the web, and the Data Science Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Data Science Academy course, upgrade to CoddyKit PRO.

What will I learn in “Scale and Normalize Numbers”?

Putting features on a fair footing. You practise Data Science Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Data Science Academy?

No prior experience is required. Data Science Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Scale and Normalize Numbers” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Data Science Academy lesson?

Yes. Every Data Science Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Bin Numbers Into Categories
  2. Encode Categorical Columns
  3. Scale and Normalize Numbers
  4. Build Features From Dates and Text
← Back to Data Science Academy