Lesson 7 — Scaling new data with training stats
Scale new data with the training min and max
In Lesson 2 you scaled one list. In real ML you have training data (what the model learns from) and new data (what it sees later). The rule: compute min and max from training data only, then reuse those same numbers for new data. Peeking at new data while preparing the model is called data leakage and makes results look better than they really are.
lo, hi = 10, 50 # learned from training data
(60 - lo) / (hi - lo) # 1.25 — new data can fall outside 0..1
Why it matters: the model was trained on one scale; new inputs must be translated to that exact same scale, or its predictions are nonsense.
Finish scale(x) using lo and hi from the training data, then scale each new value. Note 60 becomes 1.25 — that is correct.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
A quick 3-question quiz on this lesson — instant feedback.