Explore the differences between single and multiple variable anomaly detection approaches.
This guide demonstrates anomaly detection across multiple time series using local and global methods. You will learn: • How to detect anomalies in each time series independently (local). • How to detect anomalies across multiple correlated time series (global).
If you want to run this notebook interactively, click the badge below:
Both local and global methods rely on the Nixtla API for anomaly detection. The main difference is how anomalies are identified: individually per time series vs. collectively across multiple series at the same timestamp.
1. Install and Import Dependencies
If you haven’t already, install Nixtla and import your dependencies.
2. Connect to the Nixtla API
Create a NixtlaClient instance. Replace ‘my_api_key_provided_by_nixtla’ with your actual API key.
Use an Azure AI Endpoint
To use an Azure AI endpoint, set the base_url
argument explicitly:
We use an example from the SMD dataset (SMD: Server Machine Dataset). This dataset is a benchmark for anomaly detection across correlated server-performance metrics (CPU, memory, disk I/O, network throughput, etc.).
Data Size: 38 unique time series Frequency: Hourly (freq=‘h’)
Definition: local anomaly detection analyzes each time series in isolation. It flags anomalies based on each series’ individual deviation from its expected behavior.
Pros: Efficient for individual metrics or when correlations between metrics are not relevant.
Cons: May miss large-scale, system-wide anomalies that are only apparent when multiple series deviate simultaneously.
2.1.1 Example Usage
local detection code:
Sample output logs:
local Method Log Output
2.1.2 Visualization
This figure highlights anomalies detected in four selected metrics. Each metric is analyzed independently, so anomalies reflect unusual behavior within that series alone.
local Anomaly Detection Results
Best for detecting anomalies in a single metric or uncorrelated metrics. Low computational overhead, but may overlook cross-series patterns.
Considers correlations across metrics, capturing system-wide issues. More complex and computationally intensive than local methods.
Both detection approaches use Nixtla’s online anomaly detection method. Choose the strategy that best fits your use case and data characteristics.