BeginnerCoder

Lesson 2 — Normalisation

Put every value on the same 0..1 scale

Normalisation (here, min-max scaling) squeezes values into the range 0 to 1. The smallest value becomes 0, the largest becomes 1, and everything else lands in between. The formula for one value x is (x − min) / (max − min).

lo, hi = 0, 200
print((50 - lo) / (hi - lo))   # 0.25

A list comprehension like [f(x) for x in data] applies the same formula to every item and gives you a new list.

Why it matters: a model that sees "age 30" next to "salary 50000" will think salary is far more important just because its numbers are bigger. Scaling puts features on equal footing.

Want it another way?
Task

Fill in scaled with a list comprehension that applies the min-max formula from the theory to every value, rounded to 3 decimals.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.