Casino play surges every Friday and Saturday, on long weekends, New Year's Eve and Super Bowl Sunday, and drops on Christmas Day. A rolling 30-day z-score can't tell that rhythm apart from a broken feed. This POC monitors a customer tombstone feed and daily play volumes over 26 months with 15 injected data-quality incidents, and compares the z-score against a model that learns what a normal day should look like.
An incident counts as caught if any of its days alerted. A false alert is an alert on a day with no incident, counted per metric across all 7 monitored metrics. Precision = alerted incident-days ÷ all alerts.
A 30-day rolling mean averages Tuesdays and Saturdays together. Saturday runs about 70% above Tuesday in a normal week, so the standard deviation swells to cover that swing. The result is two failure modes, and no threshold fixes both.
Try Second winter on activity records. The ML band dips for Christmas Day and jumps for New Year's Eve, so the truncated New Year's Eve feed falls outside it. Switch to 30-day z and the same night sits comfortably inside a band that's too wide to mean anything.
Darker = more false alerts. All 7 metrics, evaluation window.
Given time, it learns. In its first winter, the ML detector had never seen a Christmas or a New Year's Eve, and alerted on both. It treats a holiday it hasn't met yet with a wider band, but Christmas Day volumes fall 40%, which is still too far. By the second winter it remembers how each holiday behaved and stays quiet. Of the false alerts it raised, landed on a holiday or event, and most of those came in the first season.
What the ML still misses. It misses three spend dips of about 30% on holiday weekends, where spend itself swings ±8% day to day. For two of them, the record-volume signal for the same incident was caught, so the incident still surfaced. Victoria Day spend (incident 3) slipped past every detector. The answer there is a reconciliation rule (spend per record within a range), not a looser anomaly threshold.
Each day's tombstone rows are profiled: row count, email null %, postal code format (A1A 1A1), duplicate customer IDs, under-19 DOB. Activity adds record volume and total spend.
Gradient-boosted trees predict deviation from the 28-day median using weekday, long weekend, pay-day, season and lottery jackpot size. Retrained weekly, walk-forward, never sees the future.
Each named holiday is one of a kind and comes once a year. The model remembers how far it sat from a normal day last time and applies 85% of that. An unseen holiday gets a damped typical uplift and a 2× wider band.
Alert when actual misses expected by more than 3.5× the model's recent out-of-sample error (robust MAD). A 7-day mean-residual rule catches slow drift. Rates also use a binomial floor so small days don't false-alarm.
Feedback loop. When an alert is triaged as a real incident, that day is removed from training, so a broken load never teaches the model that broken is normal. Missed incidents stay in, as they would in production.
Rates don't need the model. Validity rates like email nulls or bad postal codes aren't seasonal, so a z-score catches their incidents just as well. Use seasonal ML where the business has a rhythm (volumes, spend) and simple rules where it doesn't.
A video walkthrough of this page: why the rolling z-score falls short, and how a machine learning model that learns each day's normal pattern does better.
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt .venv/bin/python src/generate_data.py # synthetic feeds + 15 incidents .venv/bin/python src/observability.py # profile, detect, score (~3 min) .venv/bin/python src/build_report.py # this page
Source, data generator and evaluation: github.com/searchmont-analytics/zscore-vs-ml
All data is synthetic. The demand shape (weekend, holiday, event and jackpot effects) is hand-set in generate_data.py. The model only sees calendar facts and has to learn the size of each effect from the data.