NLP & ML Research · 202554% lower RMSE

Toronto Traffic Anomaly Detection

Cut hourly traffic forecast error by 54% with a GRU, then showed the simpler Poisson GLM is the better anomaly alarm (ROC-AUC 0.94 vs 0.71).

Anomaly DetectionTime SeriesPyTorchGRUPoisson GLM

Problem

Traffic counts carry strong daily and weekly patterns, noise, and event-driven spikes, so an anomaly detector can forecast well and still raise poor alerts.

Approach

I trained a Poisson GLM and a GRU sequence model on 2020-2024 hourly counts, tested both on held-out 2025 data, and scored anomalies with KL divergence.

Result

The GRU cut forecast RMSE by 54% (890 to 407) on an unseen year, but the interpretable GLM was the better alarm: ROC-AUC 0.94 vs 0.71 and F1 0.49 vs 0.14.

How it works

Step 1 of 5: Hourly traffic counts

Highlights

  • Cut hourly traffic forecast error by 54% (RMSE 890 to 407) with a GRU in PyTorch over a Poisson GLM baseline, tested on an unseen year (2025) of City of Toronto counts.
  • Showed the simpler GLM is the better alarm: with KL-divergence anomaly scoring it reached ROC-AUC 0.94 vs 0.71 for the GRU (F1 0.49 vs 0.14).
  • Built the dataset from 306k raw 15-minute count records across 3,800+ locations, aggregated to hourly, with 2025 held out so no future data reached training.

Solo course paper for Probabilistic Models & Machine Learning at York University.

Focus

This project was less about chasing one model score and more about understanding what different anomaly detectors assume.

What I compared

  • A Poisson GLM for interpretable modeling of traffic count behavior.
  • A GRU sequence model for temporal dependency capture.
  • KL-divergence anomaly scoring to inspect shifts between expected and observed behavior.

Main lesson

The better forecaster was not the better detector. If the anomaly score is poorly calibrated, a more complex model can still produce noisy operational signals, so evaluation had to stay tied to practical alert usefulness, not just loss curves.

Limits

  • The two models do not see the same inputs: the GRU reads the previous 24 observed counts, while the GLM gets four calendar and event features and no history. Part of the forecast gap comes from that.
  • The anomaly labels are heuristics built from the 2025 data itself, so F1 and ROC-AUC depend on those rules.
  • The counts are short surveys at many locations, not one continuous series, and the saved run scales and windows the data across locations. A per-location rerun with train-only scaling is the next step.
Back to projects
Role Fit Check