ML Systems Lab Open interactive version →
Advanced 55 min read anomaly detectionCUSUMSTLLSTM autoencoderisolation forest

Time Series Anomaly Detection

Point/contextual/collective anomalies, CUSUM, STL residuals, LSTM autoencoders, adaptive thresholds

Time series anomaly detection fails in production for one specific reason more than any other: teams apply a threshold to the raw series instead of the residuals of a properly specified seasonal and trend model. An API error rate of 10,000 per minute is normal during peak traffic and anomalous at 3am — but a static threshold treats both identically. The raw series conflates seasonality, trend, and anomaly signal into a single number; a threshold on raw values fires whenever any component is high, including seasonality that's entirely expected. Decompose first, threshold on the residuals, and nearly all seasonality-driven false positives disappear. The quality ceiling for any anomaly detector is the quality of its baseline model — the residuals are only as clean as the decomposition.

Key points

Takeaway

Nearly all production false-positive problems in time series anomaly detection trace back to applying a threshold to the raw series instead of the residuals of a properly specified seasonal+trend model. The decompose-first, threshold-on-residuals pattern eliminates seasonality-driven false positives immediately. The second most important insight is distinguishing root causes from downstream symptoms via causal graph traversal: a single upstream failure floods the alert queue with correlated alerts across dozens of metrics, and incident response fails when teams chase symptoms while the root cause persists.

Recap

Check your understanding

Q1. Your 3-sigma threshold on raw API error rate generates 200 false-positive alerts per day from seasonality. Which TWO fixes are correct?

Q2. You use an LSTM autoencoder for multivariate anomaly detection on 50 metrics. The reconstruction error correctly identifies an outage on day 15 of deployment, but by day 90 the false positive rate has tripled. What happened and how do you fix it?

Q3. You detect a latency spike anomaly in your API service. Your colleague says it is a "real anomaly." You say it is a downstream symptom. How do you distinguish, and what are the implications for incident response?

Q4. You are designing an anomaly detection system for 10,000 IoT sensors. Labelled anomalies exist for only 50 sensors. How do you evaluate model performance across all 10,000?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →