AI IoT Data Forecasting
We often see the same pain: sensors on the factory floor are noisy, data gaps appear, and standard SARIMA gives a 30% error because it ignores interactions with neighboring equipment. The client wants to predict a compressor failure an hour ahead, but the current model is either too heavy for edge or misses anomalies. We build turnkey systems that close these gaps. Over 5 years, we have deployed predictive pipelines on 50+ industrial sites, processing over 10,000 sensors in real time. Typical project budget ranges from $25k to $60k, with recurring savings of $10k/year per sensor on cloud costs.
Why Standard Models Fall Short for IoT Forecasting
IoT time series have specific characteristics: sampling rates in seconds/minutes, sensor noise, outliers (5σ and above), long gaps due to channel failures, and drift. Univariate models ignore dependencies — workshop temperature depends on weather, machine load, and open doors. Multivariate forecasting requires feature engineering: lag features, rolling statistics, time stamps.
Data quality issues are the main reason 60% of proofs-of-concept fail. We assess:
def assess_data_quality(ts_df):
issues = {}
issues['missing_rate'] = ts_df.isna().mean()
z_scores = (ts_df - ts_df.mean()) / ts_df.std()
issues['outlier_rate'] = (np.abs(z_scores) > 5).mean()
issues['stuck_periods'] = detect_constant_windows(ts_df, min_duration=10)
long_trend = np.polyfit(range(len(ts_df)), ts_df.fillna(method='ffill'), 1)[0]
issues['drift_per_day'] = long_trend * 86400 / ts_df.index.freq.nanos * 1e9
return issues
How We Build the Preprocessing Pipeline
- Interpolation of short gaps (<5 min) — time-linear.
- Forward fill for long gaps with an imputation flag (model learns to ignore fictitious values).
- Adaptive normalization: a 24-hour rolling window compensates drift and seasonality.
- Feature synthesis: lags [1, 5, 15, 60, 1440], rolling mean/std 5/15/60 min, hour/day/day_of_week.
LightGBM with these features achieves 15–20% higher accuracy than SARIMA on regular series and 2 times better on noisy ones.
Model Selection Based on Series Characteristics
| Model |
Best Suited For |
Accuracy* |
Inference Time |
Edge-ready |
| SARIMA |
Series with seasonality (energy, temperature) |
85–92% MAPE |
50 µs |
Yes (C++) |
| LightGBM |
Any: noisy, multivariate |
90–95% |
100 µs |
Yes (C API) |
| LSTM |
Nonlinear patterns, long dependencies |
92–97% |
1–5 ms |
Yes (INT8 ONNX) |
| Chronos/TimesFM |
Rare sensors, zero-shot |
75–85% |
10–50 ms |
No (cloud) |
*MAPE at 12-step (minute) forecast horizon. LightGBM is 2 times more accurate than SARIMA on noisy data, and LSTM achieves 97% MAPE vs 85% for SARIMA on complex series.
Typical Problems Solved by Preprocessing
| Problem |
Method |
Impact on Accuracy |
| Gaps <5 min |
Linear interpolation |
±2% |
| Gaps >5 min |
Forward fill + flag |
±5% |
| Sensor drift |
Rolling normalization (24h window) |
+10–15% |
| Outliers (5σ+) |
Percentile capping |
+5–8% |
How to Deploy the Model on Edge
Edge devices — ARM Cortex-A, 256 KB RAM. Our solution:
- Train the model (PyTorch).
- Export to ONNX.
- Quantize to INT8 (4x size reduction, 2x speedup).
- Run on device via ONNX Runtime.
import onnxruntime as ort
torch.onnx.export(model, dummy_input, 'forecaster_edge.onnx', opset_version=11)
from onnxruntime.quantization import quantize_dynamic
quantize_dynamic('forecaster_edge.onnx', 'forecaster_edge_quant.onnx')
session = ort.InferenceSession('forecaster_edge_quant.onnx')
forecast = session.run(None, {'input': recent_data})[0]
Edge forecasting saves traffic: only anomalies are sent to the cloud — 80–95% savings, making edge inference 5 to 20 times more efficient in data transmission. This is especially critical for remote sites with limited bandwidth. We use ONNX quantization to reduce model size and leverage TinyML techniques for efficient on-device inference. Our approach combines machine learning for IoT time series forecasting. We design an MQTT Kafka pipeline for sensor data. Our solution includes Grafana monitoring dashboards. Contact us for a one-week pilot to test the effect on your data.
What We Do for 10,000+ Sensors
- Hierarchical forecasting: grouping by type, location, system → top-down reconciliation improves stability.
- AutoML time series: StatsForecast parallel-fit SARIMA/ETS for thousands of series in minutes.
- Online sensor anomaly detection: rolling z-score + residual-based (forecast-actual).
Case study: for a network of pump stations, we deployed a hierarchical LightGBM that reduced false positive anomaly alerts by 30% compared to unitary models.
How the Process Works
- Analytics: audit sources (MQTT/Kafka), assess quality, select model.
- Design: pipeline architecture, data schema, tech stack (MLflow, Weights & Biases).
- Implementation: preprocessing pipeline → baseline LightGBM → iterations (LSTM, edge).
- Testing: A/B on historical data, p99 latency, reliability.
- Deployment: Docker + Kubernetes (cloud) or ONNX (edge) + Grafana dashboard.
What’s Included in the Deliverable
- Collection and preprocessing pipeline (Python, Kafka, MQTT).
- Trained model (online + batch).
- Grafana dashboard with forecasts and alerting.
- Edge inference code (ONNX / C++).
- Documentation (architecture, API, instructions).
- Operator training (2–3 hours).
- API documentation.
- Access to cloud dashboard.
- 3 months of post-deployment support.
Timeline
- 4–5 weeks: ingestion + preprocessing + LightGBM baseline + dashboard.
- 3–4 months: full cycle with LSTM, edge ONNX, streaming anomaly detection, AutoML for fleet.
We provide a free project assessment: reach out to discuss your use case. Get a consultation on model selection. ISO 27001 certified, 5+ years of experience — quality guaranteed.
Additional resources: Wikipedia - Time series.
When does a time series forecasting model fail in production?
The CFO requests a quarterly sales forecast. An analyst builds SARIMA on three years of data, achieves MAPE 8.3% on the test set, and deploys. Two months later, the metric in production jumps to 23%. The root cause: the model was trained on pre‑COVID data, tested on a stable period, but production hit a promotion and supply chain disruption. Data leakage plus distribution shift—perfect notebook numbers, a broken forecast in reality. We have seen this pattern dozens of times across retail, fintech, and IoT. Our team has delivered more than 50 forecasting projects over 5+ years.
Incorrect cross-validation. Standard train_test_split for time series creates data leakage: the model sees future values during training. The correct approach is TimeSeriesSplit or walk‑forward validation with an expanding window.
Multiple seasonality. Hourly electricity consumption has three seasonalities: daily (24h), weekly (168h), yearly (8760h). SARIMA handles only one. Prophet can handle multiple but scales poorly to thousands of series.
Missing values and anomalies. A missing sensor reading is information (the sensor turned off), not NaN. Linear interpolation destroys this signal. Proper handling depends on the missingness mechanism.
Cold start. A new SKU in a 50,000‑item assortment has no history, yet a forecast is needed. Standard approaches fail; cross‑learning or feature‑based methods are required.
Why is model selection critical for your data?
Prophet (Meta) – a solid start for business data with clear seasonality and holidays. Fast setup, interpretable, built‑in outlier detection. Fails on irregular patterns and does not scale beyond ~10k series without parallelization.
Gradient boosting on features (LightGBM, XGBoost) – often underestimated. Engineer lags (t‑1, t‑7, t‑28), rolling means, day‑of‑week, holidays. The model trains on all series simultaneously, solving cold start via transfer learning. MAPE in retail often beats neural nets with proper feature engineering.
TFT (Temporal Fusion Transformer) – a transformer designed for interpretable forecasting with covariates. Built‑in variable selection, temporal attention, quantile outputs. Available in pytorch‑forecasting. Requires ~10,000+ records per series for stable training.
PatchTST – splits the series into patches (like ViT for images), capturing local patterns better than classic transformers. Excellent for long‑horizon forecasting (96–720 steps ahead).
N‑HiTS, N‑BEATS – attention‑free neural architectures, faster than TFT, competitive accuracy. N‑BEATS won the M4/M5 benchmarks for tasks without covariates.
| Method |
Covariates |
Scale (series) |
Interpretability |
Complexity |
| Prophet |
Yes (regressors) |
Up to 10k |
High |
Low |
| LightGBM + features |
Yes |
100k+ |
Medium |
Medium |
| TFT |
Yes |
1k–100k |
High |
High |
| PatchTST |
No/limited |
Any |
Low |
Medium |
| N‑HiTS |
No |
Any |
Low |
Low |
How do we deploy TFT in production?
A typical pipeline via pytorch‑forecasting:
training = TimeSeriesDataSet(
data,
time_idx="time_idx",
target="sales",
group_ids=["store", "sku"],
min_encoder_length=max_encoder_length // 2,
max_encoder_length=max_encoder_length, # 120 days
min_prediction_length=1,
max_prediction_length=max_prediction_length, # 28 days
static_categoricals=["store_type", "category"],
time_varying_known_reals=["price", "promo_flag"],
time_varying_unknown_reals=["sales"],
target_normalizer=GroupNormalizer(groups=["store", "sku"], transformation="softplus"),
)
A common mistake: the default target_normalizer (StandardScaler) breaks predictions for series with zero values (no sales on weekends). GroupNormalizer with transformation="softplus" is the correct choice for count data.
Case study: retail demand forecasting
A chain of 120 stores, 8,000 SKUs, 28‑day forecast horizon. The original system: SARIMA per series, MAPE 18.4%, retraining cycle – 6 hours. We replaced it with TFT on PyTorch + pytorch‑forecasting: a single model for all series, MAPE 11.2%, retraining – 40 minutes on an A10G. Feature importance via variable selection revealed that day_before_holiday influences more than the holiday date itself. Annual savings on inference alone exceeded $50,000.
Step‑by‑step configuration
-
Data collection and preparation. Handle missing values (mark NaN, interpolate only for technical failures), aggregate to required frequency, engineer covariates (holidays, promotions, prices).
-
Create
TimeSeriesDataSet. Set group_ids (store + SKU), time index, forecast horizon. Choose target_normalizer based on target distribution.
-
Train a baseline. Prophet or LightGBM first – to understand complexity.
-
Train TFT. Use
TemporalFusionTransformer with loss=QuantileLoss(), tune learning rate and hidden layer sizes.
-
Validate and interpret. Walk‑forward test, analyze variable selection, build attention heatmaps.
How to properly evaluate forecast quality?
RMSE alone is misleading – it over‑penalizes large values. Our standard set:
-
MAPE – interpretable, unstable near zero.
-
sMAPE – symmetric, avoids division by small numbers.
-
MASE (Mean Absolute Scaled Error) – normalized relative to a naive seasonal forecast, ideal for comparing series of different scales.
-
Pinball loss – for probabilistic forecasting, inventory management.
| Metric |
When to use |
Drawback |
| MAPE |
Business reporting, series without zeros |
Unstable for small values |
| sMAPE |
Model comparison |
Asymmetric interpretation |
| MASE |
Multi‑scale series, benchmarks |
Needs seasonal naive baseline |
| Pinball loss |
Probabilistic models |
Multiple values for different quantiles |
We guarantee a model card with these metrics on the validation set and walk‑forward results on at least 6 months of history.
What deliverables do you receive?
- Documentation of chosen architecture and hyperparameter rationale.
- Reproducible training and inference pipeline (Docker + CI/CD + Airflow/Prefect).
- Committed code with unit tests for key components.
- Team training: retraining, output interpretation, deployment of new versions.
- 3 months of post‑delivery support (consultations, bug fixes, fine‑tuning).
The model is deployed via FastAPI or Triton Inference Server. Retraining is scheduled (e.g., weekly) via Airflow with drift validation and automatic rollback if metrics deteriorate.
Process and timeline
We start with EDA: visualization, ADF test, STL decomposition, analysis of missing values and outliers. This takes 2–3 days but often reveals systemic data issues that block forecasting. Then we build a baseline (naive seasonal, Prophet), engineer features for LightGBM, and select a neural architecture if needed. Walk‑forward validation with a realistic horizon. Deployment via API with automatic retraining scheduled via Airflow or Prefect.
Timeline: MVP forecast on one data type – 3–6 weeks. Hierarchical forecasting system with automation – 2–5 months. Cost is calculated individually based on data volume, number of series, and required accuracy.
Our team consists of certified ML engineers (AWS ML Specialty, GCP Professional ML Engineer) with 5+ years on the market and over 50 completed forecasting projects. Contact us for a free analysis of your data – we will assess the task and provide initial recommendations within 1–2 days. Request a consultation to ensure your forecasts work in production, not just in a notebook.