3  Feature Engineering for ML

analytics-ml
modeling
feature
engineering

3.1 Start With the Story

Picture an IoT team using the ideas in Feature Engineering for ML during a live operations review. A device has produced messy evidence, an analytic step is about to change an alert or control decision, and someone has to explain why the result should be trusted.

Read this page as that path from sensor evidence to accountable action. Start with what the system observes, keep the model or data treatment visible, and finish with the check that would convince an operator, maintainer, or auditor to act.

3.2 Features Preserve Signal Meaning

Feature engineering turns raw IoT observations into model inputs that preserve the meaning needed for a decision. The useful feature is not simply a statistic or embedding. It is a repeatable measurement of the signal, context, label boundary, and time window that the model will see again in deployment.

For a vibration classifier, a feature may describe energy in a frequency band, peak behavior, or a change from normal baseline. For an occupancy model, a feature may combine motion events, door state, time of day, and recent absence. For a battery-risk model, a feature may tie voltage, temperature, current draw, firmware state, and communication retries to a service decision.

If you only need the intuition, this layer is enough: a feature is acceptable when its source, window, units, label timing, missing-data behavior, transformation code, and deployment availability are all reviewable.

Worked example: a temperature-alert model might turn one-second sensor samples into a 60-second window with mean, maximum, slope, missing-sample count, and last-calibration age. Those features are only trustworthy if the same window boundary, unit conversion, calibration state, and missing-data rule are used during training, validation, and deployment. If the edge device later reports every 10 seconds, the feature recipe has changed even when the feature names stay the same.

Signal

Name the physical or operational phenomenon the feature represents, including sensor source, units, sampling behavior, and expected noise.

Window

Define the time span, event boundary, aggregation rule, freshness, and whether the window is allowed to look before or after the prediction time.

Label

Connect the feature to the target label without leaking future outcomes, maintenance notes, post-event states, or operator decisions.

Deployment

Prove the same feature can be computed online or at the edge with the available latency, power, storage, privacy, and fallback behavior.

Feature engineering pipeline diagram showing raw sensor values moving through a window segment, statistic extraction, and normalization to a zero-to-one scaled feature vector

Feature engineering pipeline from raw sensor values through windowing, statistics, and normalization

What Makes a Feature Set Useful

A feature set is useful when the chosen dimensions make the groups easier to distinguish together than they would be alone. Color by itself may overlap, weight by itself may overlap, but color plus weight may separate the examples well enough for a simple model. Even a simple image question such as whether a fruit is more red or orange needs a recipe: maximum channel value, mean channel value, channel ratio, and histogram shape can support different decisions. A weak feature is not "wrong" because it is ugly. It is weak when it is irrelevant, unstable, too expensive to compute, unavailable at inference time, or unable to separate the decision groups it is supposed to support.

Direct Measurements

Use physical quantities directly when the units and calibration are trustworthy: weight, temperature, pressure, vibration energy, battery voltage, or signal strength.

Encoded Objects

Represent objects as numbers only when the encoding preserves the useful difference. A color may become an RGB tuple; an image may become an ordered grid of pixel values.

Windowed Signals

Represent audio, motion, or other time-varying signals as fixed windows, sampled sequences, frequency features, or summary values such as mean, slope, variance, peaks, zero crossings, event counts, and energy.

Distribution Summaries

Histograms, skewness, and kurtosis can preserve distribution shape, but bin choices and window boundaries matter: too few bins hide detail, while too many bins become sparse and sensitive to noise.

Real sensor preprocessing is application-dependent. Filtering, denoising, normalization, clipping, and windowing should be chosen because they preserve the decision signal, not because they are standard notebook steps. For a gesture classifier on a Particle-class device, the pipeline might collect IMU motion on the device, compute compact window features locally, train or configure the model from a phone workflow, display the predicted character on the phone, and keep raw logs for Python plots so the team can see whether four in-air gestures are actually separable.

3.3 Practitioner: Write a Feature Recipe

A feature recipe is the contract between training and inference. It states exactly how a feature is computed, what assumptions it uses, how missing and out-of-range values are handled, and what evidence proves it still means the same thing when deployed.

Recipe Field
What to Record
Failure Mode
Retest Trigger
Source and units
Sensor stream, channel, unit, calibration state, coordinate frame, sample rate, and timestamp source.
A model treats values from different devices, firmware, units, or placements as if they were comparable.
Sensor, firmware, calibration, placement, gateway, time source, or unit conversion changes.
Window and transform
Window length, stride, event boundary, aggregation, filter, normalization, clipping, and order of operations.
Training and inference use different window boundaries or transformation order.
Sampling rate, latency budget, feature code, normalization baseline, or streaming architecture changes.
Label boundary
Prediction time, label source, delay, human review state, exclusion rule, and unavailable future information.
Features include future labels, maintenance actions, post-alarm states, or manual corrections.
Label process, operator workflow, data retention, audit rule, or target definition changes.
Quality behavior
Missingness, stale data, outliers, duplicate events, imputation, confidence flags, and degraded-mode fallback.
Cleaning hides data gaps or creates features that look valid when the source is weak.
Missing-rate pattern, device population, environment, privacy policy, field failures, or drift monitor changes.

Keep feature selection reviewable. Removing redundant features can make a model cheaper and easier to monitor, but the retained features should still explain the operational claim. If a selected feature is a proxy for user identity, protected status, site ID, maintenance shift, or a post-decision workflow, the review should check whether it is meaningful, fair, legal, and available at inference.

Common selection methods ask different questions. A variance threshold keeps features that actually spread out across examples, so a nearly constant column does not pretend to add evidence. Univariate tests score one feature at a time against the label and can reveal a single strong separator, but they can miss combinations that only work together. Principal component analysis (PCA) transforms the feature space toward directions with high variation and can reduce dimensionality, but the projected components still need scaling, provenance, and deployment-time reproducibility.

Feature recipe template Feature name: stable, versioned, and tied to one meaning. Decision target: what the model output supports. Source streams: sensor, unit, time source, calibration, device class, and context. Window rule: length, stride, event boundary, freshness, and prediction-time cutoff. Transform rule: filtering, aggregation, scaling, clipping, encoding, and missing-data behavior. Validation evidence: holdout split, leakage check, drift monitor, edge or cloud cost, and failure behavior. Retest trigger: any change in sensor, firmware, label process, sampling, code, deployment path, population, environment, or decision use.

3.4 Leakage, Drift, Feature Contracts

Feature engineering often fails because a model learns a shortcut that will not hold after deployment. The shortcut may be explicit leakage, such as a post-event field inside the feature table. It may also be a quiet proxy, such as a device ID that stands in for a site, a timestamp that stands in for maintenance schedule, or a missing-value pattern that stands in for a broken collection process.

A practical leakage test asks whether the value would exist, with the same precision and delay, at the moment the model must act. If the answer depends on a future repair ticket, a later human label, a batch backfill, or a post-alarm state, the feature contract is invalid for real-time inference.

Temporal Leakage

The feature uses values, labels, repairs, alarms, or operator actions that happen after the prediction time.

Population Leakage

The split lets the same device, user, room, asset, or site appear in both training and validation when deployment needs generalization.

Processing Drift

The deployed code changes sampling, normalization, clipping, imputation, encoding, or missing-data labels compared with training.

Meaning Drift

The same feature name remains in the table after sensors, firmware, labels, usage, environment, or operating policy changes its meaning.

The strongest defense is a feature contract: a versioned recipe, an availability check at prediction time, a leakage audit, a held-out validation split that matches deployment, and monitors for input range, missingness, drift, and feature calculation failures. Feature stores can help when they preserve this contract, but they do not remove the need to review feature meaning.

Under the hood, feature selection should also be treated as a reliability decision. Dropping a feature can reduce cost, but it may remove the only signal that catches a rare failure mode. Adding a feature can improve a metric, but it may increase latency, power, privacy risk, or false confidence. The accepted feature set should state what it optimizes and what it no longer claims to detect.

3.5 Summary

  • Feature engineering turns raw IoT data into model inputs that preserve signal meaning for a specific decision.
  • Useful feature sets separate the decision groups with reproducible dimensions, whether those dimensions come from direct measurements, encoded images, fixed signal windows, summary statistics, or distribution summaries.
  • Every feature needs a recipe: source, unit, timestamp, window, transform, label boundary, missing-data behavior, and deployment availability.
  • Leakage checks must verify that the feature is available at prediction time and does not encode future labels, post-event actions, or inappropriate proxies.
  • Validation should hold out the boundary that deployment must generalize across, such as future time, new devices, new sites, or new users.
  • Feature selection is an operations decision as well as a modeling decision because retained and dropped features change cost, latency, privacy, monitoring, and failure coverage.
  • Retest feature recipes after sensor, firmware, label process, sampling, transform code, deployment path, population, environment, or decision-use changes.
Key Takeaway

Feature engineering is trustworthy when training and deployment share the same feature meaning: source, window, transform, label boundary, quality behavior, leakage controls, and retest triggers all stay reviewable.

3.6 See Also

Machine Learning Fundamentals

Review the basic supervised-learning terms that feature recipes support.

IoT Machine Learning Pipeline

Place features inside the full path from decision target to deployed model, monitoring, and retraining evidence.

Validation and Outlier Detection

Connect feature quality to schema checks, outlier handling, provenance, drift, and exception review.

Edge ML and TinyML Deployment

Check whether feature computation fits edge latency, memory, power, update, telemetry, and fallback constraints.