24 — Practice & Tooling

Anomaly Detection#

Practice✓ Mathematical
◆ The PatternFinding the signal in the noise

Temporal anomalies are observations that deviate from expected patterns. Point anomalies are individual outliers. Contextual anomalies are normal values at the wrong time (e.g., summer demand in winter). Methods range from simple z-score thresholds to autoencoders that learn the normal pattern.

// Interactive — anomaly detection methods
Threshold (σ)2.0
# Python — anomaly detection
from sklearn.ensemble import IsolationForest

# Z-score method
z = (series - series.rolling(30).mean()) / series.rolling(30).std()
anomalies = series[z.abs() > 2.5]

# Isolation Forest on features
clf = IsolationForest(contamination=0.05)
labels = clf.fit_predict(features)
Pattern bridge: Anomaly detection in time series uses the same z-score logic from statistics. In markets, anomalies are price gaps and volume spikes. In MLOps, data quality gates perform anomaly detection on incoming features.
← Previous
Backtesting Forecasts
Open in the full reader, with the topic sidebar →