Analytics & ML · Study deck

Signal Preprocessing Contracts

Picture three vibration sensors watching the same motor.

Data Dora is your guide for this deck.

dataqualitypreprocessing
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 preprocessing order changes the statistical meaning of a sensor stream.
  • Choose alignment, resampling, smoothing, and detrending steps based on the physical signal you must preserve.
  • Identify when causal filters, centered filters, interpolation, or downsampling can mislead real-time IoT decisions.
  • Record preprocessing parameters and quality flags so dashboards, models, and incident reviews can reproduce the cleaned stream.
iotclass.org

Major section

Start With the Story

Their clocks differ, one misses samples, and one reports a brief spike.

  • The analyst can make a smooth chart, but the maintenance lead needs to know whether the motor changed or the cleaning steps invented the change.
  • Shift one clock, remove a short run, add a real step change, repeat a reading, and place a spike at the edge of a window.
  • This simple record does not select the best mathematical method.
iotclass.org

Major section

Raw Data Needs Preprocessing

Between validated raw readings and a model that can learn from them sits preprocessing: aligning sensors that sample at different rates, filling or marking gaps, smoothing noise, and removing trends.

  • Preprocessing is a workflow, not a single step, and the order of operations matters.
  • Getting the sequence right is as important as choosing the techniques.

Why it matters

Skip it and even a good model struggles, because it is fed misaligned, noisy, drifting inputs that obscure the pattern you want it to find.

After raw sensor readings have been captured, the preprocessing contract runs through validation, cleaning, and transformation before features are safe for models and dashboards.
After raw sensor readings have been captured, the preprocessing contract runs through validation, cleaning, and transformation before features are safe for models and dashboards.
iotclass.org

Major section

Raw Data Needs Preprocessing (continued)

For example, a cold-room monitor might collect temperature every 10 seconds, door state every event, and compressor current once a minute.

  • Intuition: preprocessing is preparing ingredients before cooking.
  • You wash and chop in a sensible order — and if you blend before removing the stone, the whole dish is ruined no matter how good the recipe.
  • The important distinction is that preprocessing preserves evidence while making the signal usable.
iotclass.org

Major section

Raw Data Needs Preprocessing (continued)

The sequence carries the chapter's narrative forward: every stage needs an input contract, a versioned action, and an output-quality record so downstream models can distinguish measured data from repaired or derived evidence.

  • A removed point should leave a quality flag; an imputed value should be distinguishable from a measured value; a resampled series should record the original sampling interval.
  • Those records let later troubleshooting answer whether an alarm came from the physical process or from the cleaning choice.
  • That discipline gives downstream analytics a stable contract instead of a moving target.
iotclass.org

Major section

Align, Smooth, Resample

The conversion might be mean vibration energy, maximum temperature, door-open seconds, and the count of validation failures.

  • A practical preprocessing run starts by writing down the target analysis grain.
  • Without that target grain, teams often resample blindly and create features that cannot be compared.
  • The filter is part of the measurement design, not cosmetic cleanup.

Why it matters

A moving average is acceptable for a slow room-temperature trend because a few seconds of lag may be harmless.

iotclass.org

Major section

Align, Smooth, Resample (continued)

If the model makes one prediction per minute, a 100 Hz vibration stream, a 1 Hz temperature stream, and event-driven door contacts all need rules that convert them to that one-minute grain.

  • For those cases, a median filter may remove one-sample spikes, or a Savitzky-Golay filter may reduce noise while preserving peak shape.
  • Savitzky-Golay (window 11, order 3): fits a cubic in each window, so it removes noise while keeping the peak's height and the slopes on either side.
  • Each step assumes the previous one has already run.
iotclass.org

Major section

How Preprocessing Misleads

Preprocessing changes the statistical meaning of the data.

  • A moving average reduces variance, interpolation creates synthetic samples, detrending removes low-frequency content, and downsampling discards information above the new sampling limit.
  • The timing model is just as important as the math.
  • Aliasing is the other hidden trap.
  • Downsample only after filtering out content the new sample rate cannot represent.

Key terms

Preprocessing
Preprocessing is lossy and choices are revisited.

Why it matters

Offline analysis can use centred windows or zero-phase filters because it can look forward and backward around an event.

iotclass.org

Major section

How Preprocessing Misleads (continued)

Over-smoothing hides signal Too wide a window erases the very features you are trying to detect.

  • A live edge alarm cannot use future samples without delaying the alert or leaking future information into the decision.
  • The pipeline may appear smoother and cheaper, while the feature has become false evidence.
  • Neither creates information that was not sampled.
iotclass.org

Major section

How Preprocessing Misleads (continued)

If a filter needs five future samples to look clean in a notebook, it is not the same filter that can run in production at the event boundary.

  • If a 100 Hz vibration component is downsampled to 20 Hz without a low-pass filter, high-frequency energy folds into lower frequencies and can look like a real slow oscillation.
  • Changing an imputation window, a smoothing alpha, or a normalization range can shift model inputs enough to invalidate comparisons with previous metrics.
  • The window should be matched to the timescale of the phenomenon, not set to "as smooth as possible".
iotclass.org

Major section

How Preprocessing Misleads (continued)

That record also lets teams rerun old raw data through the new pipeline and measure whether the change improved the signal or only moved the baseline.

  • For real-time alarms that lag can be the difference between catching an event and missing its onset; account for it or use a zero-phase filter offline.
  • Resampling is not free Upsampling invents points by interpolation (which can imply detail that was never measured); downsampling must respect the sampling limit to avoid aliasing.
  • Retain the validated raw data so you can reprocess with different parameters instead of being stuck with one irreversible pipeline.
iotclass.org

Deck summary

Key takeaways

Their clocks differ, one misses samples, and one reports a brief spike.

  • Between validated raw readings and a model that can learn from them sits preprocessing: aligning sensors that sample at different rates, filling or marking gaps, smoothing noise, and removing trends.
  • For example, a cold-room monitor might collect temperature every 10 seconds, door state every event, and compressor current once a minute.
  • The sequence carries the chapter's narrative forward: every stage needs an input contract, a versioned action, and an output-quality record so downstream models can distinguish measured data from repaired or derived evidence.
  • Preprocessing changes the statistical meaning of the data.
iotclass.org

Retrieval practice

Recall check 1 of 3

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

Q1Why does the ORDER of preprocessing steps matter?

AThe steps are independent, so smoothing, outlier handling, and resampling cannot affect one another.
BSteps interact, so smoothing before outlier removal can spread a bad sample into neighbouring data.
CValidation should run last, so it can check the smoother's final output rather than noisy raw samples.
DOrder matters only for speed because later steps compress the data after smoothing and resampling.
Show answer

Answer: B Preprocessing steps interact, so sequence changes the result.

iotclass.org

Retrieval practice

Recall check 2 of 3

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

Q2You must smooth noise but preserve the height and shape of genuine sharp peaks. Which filter is better suited?

AA wide moving average, because the flattened peak can be restored later from the smoothed curve.
BKeep the raw signal, so the measured peak height is not changed by a smoothing window.
CA Savitzky-Golay filter, because its local polynomial fit preserves peaks and slopes better.
DPeak deletion first, because the baseline can later be used to infer the removed peak shape.
Show answer

Answer: C Savitzky-Golay preserves peak shape and derivatives that a moving average flattens.

iotclass.org

Retrieval practice

Recall check 3 of 3

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

Q3A real-time alarm reacts late after a wide moving-average smoother was added. Why?

AA causal moving average uses past samples, so the smoothed signal reaches events late
BSmoothing makes the sensor sample faster, so the alarm queue has to wait longer
CMoving averages delete every real event, so the alarm has no trigger to process
DWider windows only change display smoothness, so timing is unchanged by design
Show answer

Answer: A Smoothing introduces lag proportional to window width, delaying real-time detection.

iotclass.org

Print reference

Answers

Answer key.

  1. B · Preprocessing steps interact, so sequence changes the result.
  2. C · Savitzky-Golay preserves peak shape and derivatives that a moving average flattens.
  3. A · Smoothing introduces lag proportional to window width, delaying real-time detection.
iotclass.org