Analytics & ML · Study deck

Feature Scaling and Leakage Controls

A feature-scaling model sees battery voltage near 3.7 and packet count near 20,000, even though both columns describe the same device leakage-control window.

Data Dora is your guide for this deck.

dataqualityfeature
Data Dora, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Explain why large-magnitude sensor units distort distance and gradient-based models.
  • Choose min-max, z-score, or robust scaling based on feature shape and model needs.
  • Store scaler parameters as part of a reproducible training and inference artifact.
  • Prevent train/test leakage by fitting scalers on training data only.
iotclass.org

Major section

Fit the Scaling Rule Without Seeing Tomorrow

The fit arrow must use training data only.

  • Validation, test, and production records pass through the stored transformation; they do not change its mean, spread, minimum, or maximum.
  • Min-max scaling uses (x'=(x-3.4)/(3.8-3.4)).
  • The 3.6 V value becomes (0.2/0.4=0.5).

Numbers to remember

3.6 VThe 3.6 V value becomes (0.2/0.4=0.5).

Why it matters

Refitting with 4.0 V would pull that test point to 1.0 and allow test information to alter evaluation.

Normalization is the last transform in a feature pipeline: raw sensor values are windowed, summarized into features, then scaled so unit magnitude does not decide model importance.
Normalization is the last transform in a feature pipeline: raw sensor values are windowed, summarized into features, then scaled so unit magnitude does not decide model importance.
iotclass.org

Major section

Fit the Scaling Rule Without Seeing Tomorrow (continued)

The method must match the feature and feature-scaling model; “normalized” is not a complete recipe.

  • A later test reading of 4.0 V becomes (0.6/0.4=1.5), which is outside the training range but honest.
  • Z-score scaling uses a training mean and standard deviation.
  • Leakage can enter before scaling.
iotclass.org

Major section

Fit the Scaling Rule Without Seeing Tomorrow (continued)

Robust scaling instead uses a median and interquartile range, which can reduce the influence of extreme values.

  • A rolling average that includes samples after the prediction time gives the feature-scaling model knowledge of the future.
  • A random split can place windows from the same device session on both sides.
  • A maintenance label copied into a feature is direct answer leakage.
iotclass.org

Major section

Fit the Scaling Rule Without Seeing Tomorrow (continued)

If a production feature falls far beyond the training range, log it as a monitoring fact rather than clipping it silently unless clipping was an explicit, tested rule.

  • A scaled value helps the feature-scaling model, but an operator needs the original unit and range when investigating an alert.
  • A correct feature-scaling model paired with another training run's parameters can produce wrong scores while every file loads successfully.
  • Refitting with 4.0 V would pull that test point to 1.0 and allow test information to alter evaluation.
iotclass.org

Major section

Start With the Story

One column holds small decimals and another holds large counts.

  • The data owner must make their scales fair without learning from the cases reserved to judge the model.
  • A remote review can compare fleets, but the released local rule needs its own version and safe fallback.
  • This opening does not choose every scaling method or prove model quality.
iotclass.org

Major section

Feature Scales Distort Models

The numbered pipeline separates raw observations, window construction, feature extraction, and normalization, so parameters fitted at the wrong boundary are easier to spot.

  • Windowing fixes which samples contribute to a training example; extraction gives each feature a physical meaning and unit; normalization changes scale but should not change that meaning.
Normalization is the last transform in a feature pipeline: raw sensor values are windowed, summarized into features, then scaled so unit magnitude does not decide model importance.
Normalization is the last transform in a feature pipeline: raw sensor values are windowed, summarized into features, then scaled so unit magnitude does not decide model importance.
iotclass.org

Deck summary

Key takeaways

The fit arrow must use training data only.

  • The method must match the feature and feature-scaling model; “normalized” is not a complete recipe.
  • Robust scaling instead uses a median and interquartile range, which can reduce the influence of extreme values.
  • If a production feature falls far beyond the training range, log it as a monitoring fact rather than clipping it silently unless clipping was an explicit, tested rule.
  • One column holds small decimals and another holds large counts.
iotclass.org

Retrieval practice

Recall check 1 of 3

Data Dora says: answer from memory, then check your reasoning.

Q1Why do many ML algorithms need features scaled to comparable ranges?

ATo fit sensor values into a compact numeric storage range before training.
BBecause scaling is a privacy control that hides original sensor units, so training can proceed without exposing temperature or pressure readings.
CLarge-magnitude features can dominate distance or gradient methods because of units.
DOnly to make plots and tables easier to compare; distance and gradient calculations would be unchanged by the raw units.
Show answer

Answer: C Without scaling, unit magnitude, not importance, drives many algorithms.

iotclass.org

Retrieval practice

Recall check 2 of 3

Data Dora says: answer from memory, then check your reasoning.

Q2With mean = 30 and std = 8, what is the z-score standardised value of a raw reading of 46?

A2.0, because (46 - 30) / 8 = 16/8
B16, because only the raw difference from the mean matters
C0.46, because z-score scaling divides the raw value by 100
D5.75, because the reading is divided directly by the standard deviation
Show answer

Answer: A Subtract the mean, then divide by the standard deviation; the reading is two standard deviations above the mean.

iotclass.org

Retrieval practice

Recall check 3 of 3

Data Dora says: answer from memory, then check your reasoning.

Q3Why must a scaler's parameters (e.g. mean and std) be computed from the training set only, not the full dataset?

AFitting on all data leaks test-set statistics into training
BThe full dataset is usually too large to compute a mean or standard deviation
CThe test data has no meaningful mean or standard deviation
DThe parameter source makes no difference once the model has been trained
Show answer

Answer: A Train-only fitting prevents leakage and keeps evaluation representative of deployment, where future data statistics are unknown.

iotclass.org

Print reference

Answers

Answer key.

  1. C · Without scaling, unit magnitude, not importance, drives many algorithms.
  2. A · Subtract the mean, then divide by the standard deviation; the reading is two standard deviations above the mean.
  3. A · Train-only fitting prevents leakage and keeps evaluation representative of deployment, where future data statistics are unknown.
iotclass.org