← All projects
Machine learning & AI · Python
!

anomaly

Detect anomalies in metrics — z-score, robust z-score, IQR, EWMA and seasonal residual, with scoring that does not flatter itself.

01 Generate a labelled series

Sixteen weeks of hourly request rate with a daily rhythm, a weekend dip and a slow climb. Four kinds of fault are injected and labelled: spike, dip (outage), level shift, and a variance burst. Tune the knobs and re-run.

series true anomaly (labelled) detector flag

02 How each detector scores

detectorideawhere it fails
randomuniform noiseeverywhere — it is the control
z-scoredistance from the mean in σmasking: mean and σ are dragged by the outliers
robust z-scoredistance from the median, scaled by MADstill blind to seasonality
iqrdistance outside the quartilessame
ewmadistance from a moving expectationfollows a drift, so it will not report one
seasonal residualsubtract the daily shape, then judgeneeds to know the period

The threshold is the chosen quantile of the scores the detector produced on the series — never chosen from the labels. Strict F1 is judged point by point; point-adjusted F1 credits a whole segment from one hit, which is why the random control can look respectable on the adjusted number alone.

03 Draw your own series

Sketch a metric directly on the canvas (drag left to right). Inject labelled spikes, then run any detector on your drawing — the same JS ports of the Python detectors score it.

Pad empty — draw a line or load the preset.

04 Detector comparison dashboard

Every detector scores the current series; each score series is normalised to its own max so the shapes are comparable. The table runs the real strict/point-adjusted metrics for each detector at the quantile set above.

detectorflagsstrict Pstrict Rstrict F1point-adj F1

05 Threshold lab — precision / recall / F1 live

Drag the threshold along the selected detector's score axis. Flags are recomputed instantly; precision, recall and F1 (both scoring conventions) update in real time. The toggle switches which F1 is headline.

F1 convention
0.50
i
scoring

Why these points were flagged

    27 tests · Python 3.10–3.12 · no runtime dependencies · Built by Umer Hashmi