← Back to blog
TechnicalOctober 21, 2026·14 min read

When the Sensor Lies: How Hardware Imperfections Affect Machine Learning

How noise, drift, calibration, and sampling changes can turn reliable predictions into hardware-dependent errors.

When the Sensor Lies: How Hardware Imperfections Affect Machine Learning

Imagine a human activity classifier that reaches 97 percent accuracy in the lab. It is then deployed in a wristband from a different supplier and starts labelling sitting as walking. Or imagine a gas-monitoring model that is accurate in January and quietly wrong by June, with no code change in between. These hypothetical examples illustrate how acquisition changes can affect a model.

Nothing crashed. The model loaded, the pipeline ran, and the predictions looked plausible. What changed was the hardware producing the numbers.

We usually treat the dataset as a given and spend our effort on the model. But every row in that dataset passed through a transducer, an amplifier, an analog to digital converter, some firmware, and a clock. Each stage leaves fingerprints, and the model learns the fingerprints along with the signal.

This article follows the path from physical quantity to input tensor, catalogues the common imperfections, connects them to distribution shift, and tests them in a small simulation. It ends with a practical answer to a practical question: how much should we trust a model when the hardware behind its data changes?

1. The pipeline between the world and your tensor

A supervised model assumes a stable mapping from input x to target y. For sensor-driven systems, x is not the physical quantity. It is a measurement of it.

Stages from a physical quantity through a sensor and digitizer to preprocessing and a model.
Figure 1. Each stage between the physical quantity and the model can add noise, bias, drift, or timing error. The final measurement alone does not identify which stage changed.

A simple model of what arrives at the model after sampling is:

xobs[k] = g · xtrue(kT + τk)
+ b + d(kT) + n[k]

where g is the gain (sensitivity), b the bias (offset), d(·) a slowly varying drift, n[k] noise, T = 1/fs the sampling period, and τk timing jitter. Quantization and clipping add further distortions that this equation leaves out.

Training on device A teaches the model the statistics produced by one particular set of gain, offset, drift, noise, and sampling characteristics. Deployment on another device, or on the same device months later, can change them. Without acquisition metadata or monitoring, that change may be invisible to the pipeline.

2. A field guide to sensor imperfections

ImperfectionWhere it comes fromWhat the signal looks likeWhat can go wrong for the model
NoiseThermal and electronic noise, photon shot noise in cameras, quantizationRandom scatter around the true value; a higher noise floorLow-amplitude classes blur together; variance and high-frequency features change meaning
Bias (offset)Zero-offset error in MEMS parts, ADC offset, temperatureWhole signal shifted by a constantFeatures that read absolute level, such as means and thresholds, shift directly
Gain errorSensitivity differs from the datasheet or from unit to unitAmplitude scaled up or downMagnitude-based features and decision thresholds move
DriftTemperature, ageing, sensor poisoning, supply voltageBias or gain that changes slowly over hours to monthsAccuracy decays quietly; the model was right on day one
Calibration errorImperfect factory or field calibration, axis misalignment, mounting orientationSystematic distortion unique to each unitA unit-specific fingerprint the model can latch onto
Sampling effectsDifferent or unstable sampling rates, timing jitter, dropped samples, aliasingFrequency content misread, folded, or smearedAnything defined per second or per hertz silently changes meaning
Resolution and rangeADC bit depth, saturation and clippingVisible steps; flat-topped peaksSmall signals vanish and large peaks are truncated

Two points deserve emphasis.

Drift is a time problem. Gas sensors are a well-studied example. Vergara and colleagues collected a long-running sensor array dataset over about three years specifically to study how drift degrades classifiers trained on early measurements [1]. A model validated on last quarter's data has not been validated on next quarter's hardware.

Sampling is a frequency problem. For a band-limited signal, the sampling theorem relates faithful reconstruction to sampling above twice its highest frequency [2]. Components above the Nyquist frequency can alias into lower frequencies; recovering the original signal then generally requires additional information or assumptions. Anti-alias filtering before sampling matters. Even without aliasing, a pipeline that assumes 50 Hz but receives 100 Hz data assigns the wrong physical frequencies to its spectral features.

Noise also has structure. For inertial sensors, Allan variance analysis separates white noise from bias instability and random walk, which is why datasheets quote several noise figures rather than one [3].

3. Why this is a distribution shift problem

In distribution-shift vocabulary, covariate shift means that P(X) changes while P(Y | X) remains fixed [4, 5]. A change in sensor hardware can move the measured input distribution, but the fact that the person is performing the same activity does not establish that the conditional distribution is unchanged.

Sensors complicate that clean story.

Covariate shift assumes the mapping from inputs to correct outputs is intact. A biased sensor can break that. If a reading of 5.2 used to correspond to a true concentration of 5.9 and now corresponds to 5.4, then P(Y | X) has changed for the same input value. From the model's point of view, that is closer to concept shift.

ImperfectionTypical effect on the model's world
Noise, sampling changeCan change both P(X) and P(Y | X); unchanged activity labels do not establish pure covariate shift.
Bias, gain errorDepends on whether the conditional relationship in the retained features changes.
DriftA moving target: shift that grows with deployment time
Calibration differences between unitsShift between sources, plus a risk of shortcut learning

The last row connects to shortcut learning, where a model uses a feature that predicts the label in the dataset but is not the intended signal [6]. Suppose all "running" samples came from device A and all "resting" samples from device B. A flexible model can learn device-specific noise instead of motion, and it will look excellent on a random split. Device heterogeneity of this kind, including sampling-rate instability across phones and watches, has been shown to hurt activity recognition on devices the model has not seen [7].

A random split that mixes the same devices into both halves does not establish performance on an unseen device. Device-held-out evaluation asks that separate question.

4. A small experiment

To make this concrete, I built two toy problems. They are deliberately simple, and the numbers illustrate mechanisms, not real-world magnitudes. Results are from a single run with a fixed random seed.

Experiment A: activity classification. Synthetic accelerometer-magnitude windows (128 samples at 50 Hz, in units of g) for three classes: rest, walk (about 1.6 to 2.2 Hz), and run (about 2.6 to 3.4 Hz). Walk and run amplitudes overlap. A random forest uses four features per window: mean, standard deviation, dominant frequency, and peak-to-peak range. It is trained on clean data, then evaluated on a test set with one imperfection at a time added.

import numpy as np
from sklearn.metrics import accuracy_score


def add_noise(W, sigma, rng):
    return W + sigma * rng.standard_normal(W.shape)


def add_bias(W, b):
    return W + b


# Gain error on motion; keep the gravity offset.
def scale_motion(W, g):
    return 1.0 + g * (W - 1.0)


def add_drift(W, d):
    return W + d * np.linspace(0, 1, W.shape[1])


def features(W, fs):
    spec = np.abs(np.fft.rfft(W - W.mean(1, keepdims=True), axis=1))
    freqs = np.fft.rfftfreq(W.shape[1], 1 / fs)
    return np.c_[
        W.mean(1), W.std(1), freqs[spec.argmax(1)], np.ptp(W, axis=1)
    ]


# clf: RandomForestClassifier fitted on features(X_train, fs=50)
rng = np.random.default_rng(7)
for s in [0.05, 0.10, 0.40]:
    acc = accuracy_score(
        y_test, clf.predict(features(add_noise(X_test, s, rng), 50))
    )
    print(f"noise sigma={s}: accuracy={acc:.3f}")
Perturbation on the test setLevelAccuracy
Nonenone100%
Extra noiseσ = 0.05 g100%
Extra noiseσ = 0.10 g66.7%
Extra noiseσ = 0.40 gabout 65%
Constant biasup to 0.5 g100%
Gain error on motion0.7× to 1.5×100%
Linear drift across the window0.2 g100%
Linear drift across the window0.4 g66.7%
Device logs at 100 Hz, pipeline assumes 50 Hznone66.7%
Same device, pipeline told the true 100 Hznone95.1%
Sampling clock 10% off nominaltrue 55 Hz vs assumed 50 Hz87.9%
Test conditionBaseline modelAugmented model
Noise σ = 0.10 g66.7%100%
Noise σ = 0.20 g66.7%98.2%
Noise σ = 0.40 gabout 65%95.4%
Gain 0.7×100%94.2%

Augmentation recovered most of the noise robustness. It was not free: the augmented model lost some accuracy on the 0.7× gain condition, where the baseline had been perfect. Robustness is a trade, and it is worth measuring what you pay.

Experiment B: calibration-style regression. Now a simpler task. A sensor reports reading = 0.5 + 0.8 × concentration + noise, where concentration ranges from 0 to 10. A linear model learns to invert that relationship, then the sensor misbehaves.

ConditionMean absolute error (concentration units)
Clean0.106
Offset of +0.2 in the reading0.256
Offset of +0.5 in the reading0.627
Gain error of 0.9×0.560
Slow drift from 0 to +0.5 over the deployment0.331
Extra noise, σ = 0.30.298

When a model reads absolute values, hardware error passes straight through. An offset of 0.5 in the reading becomes 0.5 / 0.8 ≈ 0.63 in the prediction, which matches the measured 0.627. There is no model failure to debug here; the sensor is simply answering a different question than it used to.

Taken together, these simulations show why the representation matters. Some perturbations left this classifier unchanged, others crossed its decision boundaries, and errors in absolute readings affected the regression predictions. These outcomes depend on the task, perturbation range, and model; they are not universal guarantees.

5. How much can we trust the model when the hardware changes?

The honest answer is: only as far as it has been tested against that change. The practical workflow below turns that into steps.

  1. Record acquisition metadata with the data: device model and unit, firmware version, sampling rate, calibration date, mounting, and environment. Providing the correct rate addresses the frequency-axis mismatch, although the experiment shows that it does not restore perfect accuracy by itself.
  2. Split by hardware, not by row. Hold out whole devices or sessions. Leave-one-device-out evaluation answers the question a random split cannot: what happens on hardware the model has never seen?
  3. Sweep the imperfections. Evaluate across a grid of noise, offset, gain, drift, and sampling-rate values and plot accuracy against level. This is the same idea as benchmarks that corrupt images with noise at several severities [8]. Look for cliffs and note where they sit relative to your hardware's datasheet specifications.
  4. Augment with perturbations that match the physics. Noise levels, offsets, and gain ranges taken from datasheets or measured units are better than arbitrary ones. Measure the cost on clean data, as the gain result above shows.
  5. Prefer representations that ignore nuisance variation. Detrending, per-window normalization, and features that do not depend on absolute level or scale remove whole classes of hardware error before the model sees them. Only do this when the removed information is not part of the task.
  6. Monitor inputs, not just outputs. Labels often arrive late or never. Track cheap input statistics in deployment: noise floor, mean level, dominant frequency, clipping rate, and effective sampling interval. A two-sample test such as Kolmogorov-Smirnov can flag change, though no single detector is reliable on its own and a flagged difference does not prove performance has dropped [9].
  7. Make uncertainty visible. Modern networks can be poorly calibrated [10], and simple confidence scores are only a baseline for detecting unfamiliar inputs [11]. Abstention or review can help when validated for the intended setting, but a shifted input can still receive a confidently wrong prediction.
  8. Adapt carefully, and re-validate. Importance weighting [12], per-device recalibration, and test-time adaptation methods [13] can help when hardware changes, but each needs evaluation on data from the new hardware. Sometimes the right fix is recalibrating the sensor, not retraining the model.

Quick diagnostic guide

SymptomPlausible causeFirst check
Strong on device A, weak on device BCalibration, noise, or sampling difference; possible shortcutCompare raw signal statistics across devices
Accuracy decays slowly after deploymentDriftPlot input statistics against time; recalibrate and re-test
Sudden failure on a new batch of unitsCliff from a changed noise floor or rangeRun the perturbation sweep around the new specifications
Everything looks plausible but is wrongSampling rate or unit mismatchCheck metadata, shapes, timestamps, and units
Good random split, poor device-held-out splitPossible device shortcut or other device-dependent shiftUse grouped splits; test with devices swapped

6. What the final claim should say

A model is not only a function of its training data. It is a function of the hardware that generated that data, and of every calibration, firmware setting, and clock behind it. When any of those change, the model is being asked a question it was not trained on.

So the useful question is not simply how accurate the model is. It is:

How accurate is this model, on which hardware, calibrated when, sampled how, and what happens to that number when any of those change?

That question is less convenient than a single accuracy figure. It is also the one that tells you whether to trust the model on Monday morning.

Limitations of the experiments

Both experiments use synthetic data with a single random seed, and the classification classes are perfectly separable when clean, which real data rarely is. The numbers show how mechanisms behave, not how large the effects will be on your hardware. Replicating the sweeps on a real sensor dataset with multiple devices is the natural next step.

References

  1. Vergara, A., Vembu, S., Ayhan, T., Ryan, M. A., Homer, M. L., & Huerta, R. (2012). Chemical gas sensor drift compensation using classifier ensembles. Sensors and Actuators B: Chemical, 166-167, 320-329. Read source
  2. Shannon, C. E. (1949). Communication in the presence of noise. Proceedings of the IRE, 37(1), 10-21. Read source
  3. El-Sheimy, N., Hou, H., & Niu, X. (2008). Analysis and modeling of inertial sensors using Allan variance. IEEE Transactions on Instrumentation and Measurement, 57(1), 140-149. Read source
  4. Quiñonero-Candela, J., Sugiyama, M., Schwaighofer, A., & Lawrence, N. D., editors (2009). Dataset Shift in Machine Learning. MIT Press. Read source
  5. Moreno-Torres, J. G., Raeder, T., Alaiz-Rodríguez, R., Chawla, N. V., & Herrera, F. (2012). A unifying view on dataset shift in classification. Pattern Recognition, 45(1), 521-530. Read source
  6. Geirhos, R., Jacobsen, J.-H., Michaelis, C., Zemel, R., Brendel, W., Bethge, M., & Wichmann, F. A. (2020). Shortcut learning in deep neural networks. Nature Machine Intelligence. arXiv:2004.07780 Read source
  7. Stisen, A., Blunck, H., Bhattacharya, S., et al. (2015). Smart devices are different: Assessing and mitigating mobile sensing heterogeneities for activity recognition. Proceedings of ACM SenSys. Read source
  8. Hendrycks, D., & Dietterich, T. (2019). Benchmarking neural network robustness to common corruptions and perturbations. ICLR. arXiv:1903.12261 Read source
  9. Rabanser, S., Günnemann, S., & Lipton, Z. C. (2019). Failing loudly: An empirical study of methods for detecting dataset shift. NeurIPS. arXiv:1810.11953 Read source
  10. Guo, C., Pleiss, G., Sun, Y., & Weinberger, K. Q. (2017). On calibration of modern neural networks. ICML. arXiv:1706.04599 Read source
  11. Hendrycks, D., & Gimpel, K. (2017). A baseline for detecting misclassified and out-of-distribution examples in neural networks. ICLR. arXiv:1610.02136 Read source
  12. Shimodaira, H. (2000). Improving predictive inference under covariate shift by weighting the log-likelihood function. Journal of Statistical Planning and Inference, 90(2), 227-244. Read source
  13. Wang, D., Shelhamer, E., Liu, S., Olshausen, B., & Darrell, T. (2021). Tent: Fully test-time adaptation by entropy minimization. ICLR. arXiv:2006.10726 Read source

Want to share your own experience? Every member can write here: reach out and we'll help you publish your first post.