Time series anomaly detection

On this page 7

Time series anomaly detection is the task of identifying observations, intervals or entire sequences in time-ordered data that deviate from the behavior expected given their temporal context. Within anomaly detection in artificial intelligence, it differs from static outlier detection because order, trend, seasonality and autocorrelation define what counts as normal.

Typical inputs are sensor readings, server metrics, financial transactions and physiological signals. The output is usually an anomaly score per time step or window, which a thresholding rule turns into alerts for operators or downstream systems.

Types of anomalies in time series

Anomalies in temporal data fall into three classic categories, and the category determines which detection methods can find them. A value can be abnormal on its own, abnormal only at a given time, or normal individually but abnormal as part of a sequence.

Anomaly typeDescriptionExample
Point anomalySingle value far from the normal rangeTemperature sensor reads 900 degrees for one sample
Contextual anomalyValue normal globally but not at that timeHigh office power use at 3 a.m. on Sunday
Collective anomalySequence abnormal as a wholeFlat heartbeat signal lasting several seconds
Level shift or change pointPersistent change in mean or varianceLatency baseline doubles after a deployment
Pattern or shape anomalyUnusual waveform shapeDistorted vibration cycle in a rotating machine
Anomaly types in time-ordered data

A practical distinction separates univariate series, where one signal is monitored, from multivariate anomaly detection, where the anomaly may only appear in the relationship between signals, for example two correlated sensors suddenly diverging.

How detection methods model normal behavior

Every method builds an implicit or explicit model of normal behavior and scores deviations from it. The main families differ in how they represent normality and which anomaly types they handle well.

FamilyHow it scores anomaliesRepresentative methods
Statistical decompositionResidual after removing trend and seasonalitySTL with robust z-scores, Seasonal hybrid ESD
Forecasting-basedError between prediction and observationARIMA, exponential smoothing, LSTM forecasters
Reconstruction-basedReconstruction error of a learned compressionLSTM autoencoders, variational autoencoders
Distance and subsequenceDistance to nearest similar windowMatrix profile, time series discords
Window-based tabularOutlier score on extracted window featuresIsolation forest, local outlier factor
Transformer-basedAttention or association discrepancyAnomaly Transformer
Main families of time series anomaly detection methods

Forecasting-based detection is often the most interpretable approach: the model predicts the next value with a prediction interval, and a point outside the interval is flagged. Matrix profile methods are strong for finding discords, the subsequences least similar to any other subsequence, without training a model.

Thresholds, windows and streaming operation

Turning scores into alerts is frequently harder than computing the scores. A static threshold rarely works on real data because noise levels change with load, season and equipment age. Dynamic thresholding sets limits from a rolling estimate of the score distribution, for example a robust median and median absolute deviation over recent windows.

Design decisions about windows and timing have a large effect on results. The table below lists the parameters that most often require tuning.

ParameterTypical settingWhat it affects
Window lengthOne to several seasonal periodsWhich anomaly durations are detectable
Threshold ruleRobust z-score of 3-5 or a percentileTrade-off between recall and false alarms
Training periodSeveral full seasonal cyclesQuality of the learned baseline
Retraining frequencyDaily to monthlyAdaptation to concept drift
Alert suppressionMinimum duration or countReduces flapping and duplicate alerts
Key configuration parameters

In streaming settings, detectors must score each new point with bounded latency and memory. Online variants of decomposition and forecasting models, as well as robust random cut forest, are designed for this mode and update incrementally rather than retraining from scratch.

Evaluating time series anomaly detectors

Evaluation is notoriously difficult and easy to inflate. Labels are scarce, anomalies are rare and many are long intervals rather than single points. The widely used point-adjust protocol, which counts an entire anomalous segment as detected if any single point is flagged, can make even random scores look strong.

  • Prefer range-aware or event-based metrics that reward early detection and penalize fragmented alerts.
  • Report false alarms per day alongside precision and recall, because operators experience alert volume directly.
  • Benchmarks such as the Numenta Anomaly Benchmark and several popular multivariate datasets contain labeling flaws, so results should be checked on the target data.
  • Always compare against simple baselines, such as a seasonal naive forecast with a robust threshold, which remain surprisingly competitive.

Common pitfalls in practice

Most failures in production come from data and process issues rather than model choice. The table below links frequent symptoms to their causes and fixes.

SymptomLikely causeFix
Alerts every Monday morningUnmodeled weekly seasonalityAdd weekly component or seasonal baseline
Detector misses slow degradationBaseline adapts too quicklyUse longer windows or change point tests
Bursts of alerts after outagesAnomalies contaminating training dataExclude or downweight labeled incidents
Spikes from missing dataGaps filled with zerosMark gaps explicitly or interpolate
Many correlated alertsPer-metric detection without groupingAggregate alerts or use multivariate models
Symptoms, causes and fixes

In plain words

Many systems record numbers over time. Examples are room temperature, website visits or a heart rate. These numbers usually follow a regular rhythm. They rise in the morning and fall at night, or they repeat every week.

Time series anomaly detection learns that rhythm and raises a flag when the numbers break it. A busy shop at noon is normal. The same crowd at midnight is strange. The key point is context: a value is judged by when it happens, not only by how big it is.

A real-world example

A regional water utility monitors flow and pressure sensors across its distribution network every minute. Demand follows a strong daily cycle, with peaks around breakfast and evening and a minimum between 2 and 4 a.m., plus a weekly pattern and slow seasonal changes.

The utility builds a forecasting-based detector for each district. A seasonal model trained on eight weeks of data predicts the expected flow with a prediction interval, and night-time flow receives special attention because unexplained flow at night usually indicates leakage rather than consumption. Alerts fire only when the residual exceeds a dynamic threshold for at least 30 consecutive minutes.

Within the first months, the detector identifies a district where minimum night flow rose by about 15 percent over three days. Crews locate a burst underground pipe that had not surfaced, repairing it weeks earlier than customer complaints would have revealed it and reducing water losses.