TimelessMetrics.Anomaly (timeless_metrics v6.0.11)

Copy Markdown View Source

Anomaly detection via z-score analysis on residuals from a trend model.

Fits the same polynomial + seasonal model as TimelessMetrics.Forecast, computes residuals (actual - predicted), and flags points where the z-score exceeds a threshold based on the chosen sensitivity level.

Sensitivity thresholds:

  • :low — z > 3.0 (flags only extreme outliers)
  • :medium — z > 2.5 (default, good balance)
  • :high — z > 2.0 (flags more subtle anomalies)

Summary

Functions

Detect anomalies in time series data.

Functions

detect(data, opts \\ [])

Detect anomalies in time series data.

Parameters

  • data - List of {timestamp, value} tuples
  • opts - Options:
    • :sensitivity - :low, :medium, or :high (default: :medium)
    • :periods - Seasonal period lengths in seconds (default: auto-detected)

Returns {:ok, [%{timestamp, value, expected, score, anomaly}, ...]} or {:error, reason}.