Analytics & ML · Study deck

Data Preprocessing Workflow

A warehouse sensor reports a sudden temperature jump.

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:

  • Design a Data Quality Pipeline: Architect a validate-clean-transform workflow for IoT sensor streams
  • Compare Preprocessing Techniques: Evaluate validation, imputation, and normalization methods based on sensor type and data characteristics
  • Implement Edge-Side Preprocessing: Build and test resource-efficient data quality checks that run on constrained devices
  • Calculate Data Quality Impact: Quantify the cost of poor data quality versus the investment in preprocessing using the 1-10-100 rule
iotclass.org

Major section

Start With the Story

A warehouse sensor reports a sudden temperature jump.

  • It may be a real door opening, a loose probe, a missing sample, or a unit change.
  • A cleaning step that silently smooths the jump can erase the very event the operator needs.
  • If no safe repair exists, keep the gap.
  • Preprocessing can make data easier to use.
iotclass.org

Major section

The Data Quality Problem in IoT

Validation marks impossible or malformed evidence before it is rewritten; cleaning applies recorded rules to gaps, duplicates, or noise; transformation prepares consistent units, windows, and features for a named consumer.

  • Each stage can change what later analytics see.
iotclass.org

Major section

The Three-Stage Pipeline

Preprocessing decisions are easier to audit when validation, repair, and feature preparation remain separate.

  • Validate asks the physical-bounds question before any value changes: Clean can remove proven errors or fill bounded gaps: Transform prepares features only after accepted and repaired states are known.
iotclass.org

Major section

Cost of Poor Data Quality

Understanding why data quality matters requires quantifying the cost of getting it wrong.

  • The 1-10-100 labels are a relative heuristic, not a universal invoice: they show how contaminated evidence accumulates reprocessing, diagnosis, and decision costs as it travels.
  • The meaning is the direction and compounding effect.
iotclass.org

Major section

Smart Building Temperature Pipeline

Scenario: You are deploying 200 temperature sensors across a commercial building for HVAC optimization.

  • Each sensor reports every 30 seconds.
  • You need clean, analysis-ready data for the building management system.
  • Step 2 -- Design Cleaning Strategy: That gives the building team a contract: every later interpolation, filter, and feature sees data that has already survived the deployment-specific rules.
iotclass.org

Major section

Normalization Throughput Calculator

The cleaning stage interpolates only bounded short gaps; longer gaps remain flagged as missing.

  • Experiment with different temperature readings, zone bounds, and sensor configurations to see how min-max normalization works and how pipeline throughput scales.
  • Result: With the default settings, the pipeline processes 24,000 readings per hour (200 sensors x 2 readings/min x 60 min).
  • The three-stage pipeline is illustrated in the data quality pipeline figure above. -->.
iotclass.org

Major section

Common Pitfalls in IoT Data Quality

Skipping validation because "the sensor is reliable": Even high-quality sensors fail.

  • A $500 industrial temperature sensor can still produce garbage readings when its wiring corrodes, its power supply fluctuates, or firmware bugs cause buffer overflows.
  • Validation rules must be context-specific.
  • A sudden temperature spike might be a genuine HVAC failure, not noise.
iotclass.org

Major section

Common Pitfalls in IoT Data Quality (continued)

Over-smoothing the signal: Aggressive noise filtering (large window moving averages, very low alpha in EMA) removes real events along with noise.

  • Ignoring sensor drift: A sensor that reads 0.5 degrees Celsius too high on day 1 might read 3 degrees too high by month 6.
  • Without periodic recalibration or drift detection, your "clean" data slowly becomes systematically wrong.
  • Normalizing before cleaning: If you normalize data that contains outliers, the outliers distort the scaling parameters (min, max, mean, standard deviation), making all your normalized values wrong.
Sensor-data cleaning pipeline for a freezer record covering schema, units, identity, domain range, freshness, quarantine, imputation, and provenance.
Sensor-data cleaning pipeline for a freezer record covering schema, units, identity, domain range, freshness, quarantine, imputation, and provenance.
iotclass.org

Major section

Summary and Key Takeaways

Balance filtering with responsiveness: Over-smoothing removes real events.

  • Data quality preprocessing is not optional in IoT systems -- it is the critical foundation that determines whether your analytics, ML models, and automated decisions can be trusted.
  • Skipping or reordering stages causes compounding errors.
  • Under-smoothing leaves noise that corrupts analysis.
iotclass.org

Deck summary

Key takeaways

A warehouse sensor reports a sudden temperature jump.

  • Validation marks impossible or malformed evidence before it is rewritten; cleaning applies recorded rules to gaps, duplicates, or noise; transformation prepares consistent units, windows, and features for a named consumer.
  • Preprocessing decisions are easier to audit when validation, repair, and feature preparation remain separate.
  • Understanding why data quality matters requires quantifying the cost of getting it wrong.
  • Scenario: You are deploying 200 temperature sensors across a commercial building for HVAC optimization.
iotclass.org

Retrieval practice

Recall check 1 of 5

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

Q1In the validate-clean-transform pipeline, why must validation run before cleaning?

ACleaning is optional, so validation is simply scheduled first by convention
BCleaning steps like interpolation would spread invalid readings into previously good data
CValidation is slower, so running it first keeps the pipeline from stalling later
DTransformation must precede both, and validation just confirms the transform
Show answer

Answer: B Validation must reject impossible values first, or cleaning algorithms will smear those errors into good data.

iotclass.org

Retrieval practice

Recall check 2 of 5

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

Q2A cleaned temperature value is used in an alert review. Which record lets the reviewer tell measurement from repair?

AOnly the final transformed number, because cleaning removes the need for provenance.
BA statement that all missing values were zero, without a source trace.
CThe model score alone, because it records the original sensor sample.
DThe raw reading, quality flag, and declared cleaning transformation.
Show answer

Answer: D A cleaned value needs its raw source, quality state, and transformation record to support review.

iotclass.org

Retrieval practice

Recall check 3 of 5

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

Q3According to the 1-10-100 rule, what is the approximate cost ratio between preventing a data quality issue at the edge versus fixing a wrong decision made from bad data?

A1:10 -- prevention is 10 times cheaper than failure
B1:100 -- prevention is 100 times cheaper than failure
C1:1000 -- prevention is 1000 times cheaper than failure
D10:100 -- prevention is 10 times cheaper than failure
Show answer

Answer: B The illustrative 1-10-100 rule assigns a 1:100 prevention-to-failure cost ratio; it is not a measured cost guarantee.

iotclass.org

Retrieval practice

Recall check 4 of 5

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

Q4Why should you normalize data AFTER cleaning rather than before?

ABecause floating-point normalization runs too slowly on dirty readings.
BBecause errors and outliers distort the parameters used to normalize data.
CBecause cleaning can work only on values in the original sensor units.
DBecause convention makes normalization the last transform in every pipeline.
Show answer

Answer: B Outliers and errors can distort fitted normalization parameters (min, max, mean, std) and the scaled values that depend on them.

Q5What flags values beyond a declared physical or statistical boundary without silently deleting them?

ARaw Data Input
BMissing Value Handling
CFormat Standardization
DOutlier Rule
Show answer

Answer: D An outlier rule uses a declared physical or statistical boundary rather than deleting surprises silently.

iotclass.org

Retrieval practice

Recall check 5 of 5

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

Q6Complete the sensor data quality pipeline:

Adf[column] = df[column].interpolate(method='linear')
Bdf[column] = df[column].fillna(0)
Cdf[column] = df[column].replace(np.nan, -1)
Ddf[column] = df[column].dropna()
Show answer

Answer: A Sensor data cleaning involves interpolating missing values (not dropping or zeroing), range-checking against physical limits, and smoothing with an exponential moving average to reduce noise while preserving trends.

iotclass.org

Print reference

Answers 1 of 2

Answer key.

  1. B · Validation must reject impossible values first, or cleaning algorithms will smear those errors into good data.
  2. D · A cleaned value needs its raw source, quality state, and transformation record to support review.
  3. B · The illustrative 1-10-100 rule assigns a 1:100 prevention-to-failure cost ratio; it is not a measured cost guarantee.
  4. B · Outliers and errors can distort fitted normalization parameters (min, max, mean, std) and the scaled values that depend on them.
iotclass.org

Print reference

Answers 2 of 2

Answer key.

  1. D · An outlier rule uses a declared physical or statistical boundary rather than deleting surprises silently.
  2. A · Sensor data cleaning involves interpolating missing values (not dropping or zeroing), range-checking against physical limits, and smoothing with an exponential moving average to reduce noise while preserving trends.
iotclass.org