1. Start with a baseline
The first clean samples define normal behaviour. Bad training data makes the detector learn the wrong normal.
Tune an IoT anomaly detector and see precision, recall, false alarms, and missed events change.
Watch an IoT sensor stream move through baseline training, scoring, thresholding, and classification. Tune the detector until learners can see why catching every anomaly can also create false alarms.
The first clean samples define normal behaviour. Bad training data makes the detector learn the wrong normal.
The detector turns the latest value into a deviation score: how far it is from the expected range.
Lower thresholds create more alerts. Higher thresholds reduce noise but can miss subtle faults.
Precision, recall, false positives, and false negatives tell whether the detector is useful for the IoT task.
Use clean early samples to estimate the normal range.
A new IoT reading arrives from the device.
Calculate deviation from the baseline or rolling window.
Mark readings outside the detection bounds.
Separate true positives, false positives, and missed events.
Use metrics to choose a threshold that fits the application.
Play or step through the stream. The shaded band is the detector's normal range, the vertical cursor is the current sample, and coloured markers show what the detector got right or wrong.
Try a different stream, detector, threshold, and window to see how each choice changes the result.
The detector is finding most injected events without too many false alerts.
Injected anomalies that produced alerts.
Normal readings that were flagged as abnormal.
Injected anomalies missed by the detector.
Normal readings correctly left alone.
Rolling z-score follows slow changes but can also learn a slow fault if the window is too short.
Lower thresholds improve recall but often reduce precision by creating more false positives.
The clean training region is shaded. If it contains faults, the detector may normalize bad behaviour.
Choose the tuning based on alert cost: missed freezer warming is worse than one extra warning.
precision = TP / (TP + FP). It answers: when the system alerts, how often is the alert correct?
recall = TP / (TP + FN). It answers: of all real anomaly points, how many did the system catch?
F1 = 2PR / (P + R). It is useful when precision and recall both matter, but it does not encode business cost.
Uses one training baseline. It is simple and stable for stationary data but weak when the normal operating level drifts.
Uses recent samples as the baseline. It adapts to drift but can be fooled by short windows and repeated anomalies.
Uses quartiles from recent samples. It is more robust to outliers than mean and standard deviation, but it still needs enough data.
The rolling methods score each sample using previous samples only. That better matches online IoT monitoring than using future data.
The orange true anomalies are injected by the demo so precision and recall can be calculated. A real deployment rarely has labels immediately.
The demo evaluates each sample independently. Real incidents often need event-level scoring, suppression windows, and escalation rules.
A threshold that works for vibration may be poor for temperature. Sensor noise, sampling rate, and cost of missed events all matter.
A rolling baseline can follow normal seasonality. It can also follow a slow fault, which turns an incident into the new normal.
An anomaly score is only evidence. Good IoT systems combine sensor context, device state, maintenance history, and alert routing.
Set the threshold low. Explain why recall rises first, then identify where false positives start to make the detector noisy.
Switch from static z-score to rolling z-score on the greenhouse scenario. Which method handles drift better, and what risk does it introduce?
Use the cold chain scenario. Tune for recall first. Explain why missing a warming event may be more costly than sending an extra alert.
Explore filtering, noise, sampling, and threshold behaviour before anomaly logic consumes the signal.
Connect time-series detection to storage, analytics pipelines, dashboards, and alerting.
Compare anomaly evidence from one sensor with multi-sensor trust and residual checks.