Data observability · proof of concept · synthetic Ontario gaming data

Beyond the Z-Score

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.

Result ·

Same detection rate, a fraction of the noise

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.

Why a z-score was not enough

The baseline has no idea what day it is

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.

  • At 3σ it goes blind. The band is so wide that a Saturday missing a third of its records still looks like an ordinary Tuesday. It caught 9 of 21 incident signals, mostly the extreme ones (missing feed, ×100 unit error).
  • At 2σ it cries wolf. Tighten it and every busy Saturday, long weekend and holiday trips it: 216 false alerts in 23 months, roughly one every three days.
  • Same-weekday z-scores help, then stall. Comparing Saturday to the last eight Saturdays fixes the weekly rhythm, but Victoria Day still gets compared to normal Mondays. It caught 18 incidents and raised 185 false alerts, 38 of them on stat holidays.
Explore the series

Expected-value band vs. what actually landed

Detector band
Window

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.

Where false alerts land

Calendar days stop being alarms

False alerts by day type

Darker = more false alerts. All 7 metrics, evaluation window.

False alerts per quarter

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.

Ground truth

The 15 injected incidents

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.

How it works

Predict the day, then judge the gap

Profile

Feed → daily metrics

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.

Stage 1

Normal-day model

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.

Stage 2

Holiday memory

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

Residual vs. its own error

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.

Video explainer

Watch the case study

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.

Run it

Reproduce the POC

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.