Data Preparation for ML · Lesson 14

Numeric Scaling

Numeric scaling changes feature units without changing the ordering of observations.

ConceptWorked examplePracticeKnowledge check
Textbook walkthrough

Numeric Scaling

Numeric scaling changes feature units without changing the ordering of observations. Standardisation subtracts the training mean and divides by the training standard deviation; other scalers use ranges or robust quantiles. Scaling is important for methods whose geometry or optimisation depends on feature magnitude, such as KNN, SVMs, PCA and many gradient-based models.

Learning goal: explain why Numeric Scaling behaves this way, apply it to a small example, and verify the result independently. Begin by being able to justify this first step: Fit scaling parameters on training data only.

Deeper walkthrough

Read Numeric Scaling as a mechanism, not a recipe

Treat this as a sequence of observable decisions rather than one opaque command. Stage 1: Fit scaling parameters on training data only. Stage 2: Transform training and held-out data with the same fitted scaler. Stage 3: Choose standard, min-max or robust scaling based on model/data characteristics. Final checkpoint: Place learned scaling inside the validation pipeline.

Mechanism

Follow the transformation

Fit scaling parameters on training data only.

Transform training and held-out data with the same fitted scaler.

Choose standard, min-max or robust scaling based on model/data characteristics.

Evidence

Know what would convince you

  • Verify the split/validation boundary before comparing scores.
  • Inspect model/preprocessing state or a hand-computable tiny example.
Useful distinctionRepresentation: How the method encodes inputs/predictions.
Visual demonstration of Numeric Scaling
Visual demonstration: use the diagram to trace the main objects and state changes involved in Numeric Scaling.
Click a stage to inspect what happens, what changes, and what should be checked before moving on.
Stage 1

Fit scaling parameters on training data…

Fit scaling parameters on training data only. At this stage of Numeric Scaling, keep the incoming data or object separate from the learned parameter, transformed object, or statistic so the change can be reproduced and independently checked.

Transformation focus: keep the input and produced parameters/result separate so the change is observable and reproducible.
How it works

Trace the mechanism step by step

  1. Fit scaling parameters on training data only.
  2. Transform training and held-out data with the same fitted scaler.
  3. Choose standard, min-max or robust scaling based on model/data characteristics.
  4. Do not expect scaling to fix skewness, outliers or semantic data errors by itself.
  5. Place learned scaling inside the validation pipeline.
Worked demonstration

Standardise a feature

Values: [10, 20, 30]
Mean = 20, standard deviation ≈ 8.16
Scaled ≈ [-1.225, 0, 1.225]
Expected / illustrative result
The relative positions remain, but the feature is recentered and expressed in standard-deviation units.
Interpret the result.

For Numeric Scaling, connect the result to the fitted state, held-out data or prediction rule that produced it and independently check one prediction, split or metric component.

Distinctions & related ideas

Place the concept correctly

RepresentationHow the method encodes inputs/predictions.
Learning/operationWhat fitted state or calculation changes.
ValidationIndependent evidence used to judge generalisation or correctness.
Use deliberately

When it is appropriate

Use Numeric Scaling when it answers a defined question in Data Preparation for ML and its inputs/assumptions match the current data or program state.

Boundary conditions

When to stop or reconsider

Reconsider Numeric Scaling when the required information is unavailable, the operation would violate a validation/data boundary, or a simpler operation answers the question more transparently.

Common mistakes

Failure modes to recognise

  • Optimising on the final test set.
  • Ignoring feature scale/representation or split structure when the method depends on them.
  • Reporting a single score without checking errors, variance or operating conditions.
Verification

How to check the result

  • Verify the split/validation boundary before comparing scores.
  • Inspect model/preprocessing state or a hand-computable tiny example.
  • Perturb one input/hyperparameter and predict the expected direction or behaviour.
Hands-on practice

Demonstrate understanding

Try this:

Construct a tiny example of Numeric Scaling. First fit scaling parameters on training data only. Then transform training and held-out data with the same fitted scaler. Predict the result before execution and explain one boundary or failure case.

Use a tiny fixed split or synthetic example. State what is fitted, what remains held out, and what result you expect before running it.
Knowledge check

Check reasoning, not memorisation

Which approach best demonstrates understanding of Numeric Scaling?

Quick reference

Remember the logic

Step 1Fit scaling parameters on training data only.
Step 2Transform training and held-out data with the same fitted scaler.
Step 3Choose standard, min-max or robust scaling based on model/data characteristics.
Step 4Do not expect scaling to fix skewness, outliers or semantic data errors by itself.
Lesson summary

What to remember

  • Numeric scaling changes feature units without changing the ordering of observations. Standardisation subtracts the training mean and divides by the training standard deviation; other scalers use ranges or robust quantiles. Scaling is important for methods whose geometry or optimisation depends on feature magnitude, such as KNN, SVMs, PCA and many gradient-based models.
  • Fit scaling parameters on training data only.
  • Optimising on the final test set.
  • Verify the split/validation boundary before comparing scores.