Peter Parker

Project 08: How Many Crews, and How Sure

Seventeen years of forecasts, scored against what happened

How many crews to put on shift, and how sure can you be?

Emergency calls, arrivals, orders. "About 3,900 a day" is hard to staff to. "3,600 to 4,200, and that range has held nine times in ten for seventeen years" is something a manager can plan around. This page measures the second kind of claim: 911 weekly forecasts of the next fortnight, scored against what actually happened, and then turned into a number of crews to put on shift. It includes the fortnight where the range broke.

See the month the range broke

... a 90 percent interval should hold 9 times in 10, and over 17 years it does
... the same interval, in its worst three months: March 2020, the Covid pandemic
... what forecasting the rota saves against staffing from last week's demand

Nothing is modelled in your browser. Every number was computed in advance by the backtest and can be checked in the public repository, and every one carries a 95 percent confidence interval there. See how it's built, in three diagrams.

How it works

From a city's emergency calls to crews on shift

The rest of this page is the method and its evidence, in the order it happens. Each part starts in plain language, with a picture. Where there is more to say for someone who builds models for a living, it is folded away under For the technical reader, so you can skip it if you only want the idea.

The whole idea in one picture

Six steps. The order matters: every forecast is made from the past alone and scored against a fortnight that had not happened when it was made.

  1. 1CountDaily emergency incidents for the city, 5 boroughs and 31 dispatch areas.
  2. 2ReplayOne forecast a week since 2009, each seeing only the history before it.
  3. 3ForecastNine models, each giving a full range for the next 14 days.
  4. 4ScoreAgainst what happened, with an interval on every score.
  5. 5ReconcileMake the areas add up to the boroughs and the boroughs to the city.
  6. 6StaffPrice the range into crews at a chosen service level.

Every forecast is scored against a fortnight that had not happened when it was made. That is what lets this page show the month the ranges broke, which a whole-period average would hide.

What a forecast with a range actually looks like

One series at a time, forecast 14 days ahead by the statistical model, which is the forecaster the rest of this page staffs from and reconciles. The band is where the model said demand would be; the dark line is where it went. Pick any of the 37 series: the whole city, one of five boroughs, or a single dispatch area, where the counts are small and the noise is large. Every model that was trained is compared further down.

A fortnight's forecast cannot see a shift that happens inside its own fortnight. In late March 2020 demand leaves the band completely. The band chases it about two weeks later, which is exactly the forecast horizon, and by the time it arrives the outcome has fallen through the bottom instead. No amount of interval calibration fixes that, and the next section is what it did to the guarantee.

The promise, and the month it broke

A 90 percent interval claims to contain the outcome nine times in ten. This is the share it actually contained, in a trailing window, for three ways of building the interval around the same simple forecast. Width is underneath, because an interval can reach any coverage you like by being wide enough, and coverage bought with width is not a result.

Adaptive conformal is the method that is supposed to recover, and it does not. It widens its interval when it starts missing, but it cannot widen past the largest error in its own recent history, and March 2020 was larger than anything in the year before it. It ran out of room rather than being too slow. Watch the widths below the coverage line: they only rise after the fall, not during it.

What conformal coverage actually promises, which is less than it sounds

Split, adaptive and aggregated conformal all calibrate an interval on past errors, and their guarantee holds on average over time, and only if the errors are exchangeable: loosely, that tomorrow's mistakes look like a shuffled version of last year's. Demand through a pandemic is not exchangeable, so no coverage is promised in any one window, and none was delivered.

The implementation is working as designed; the guarantee is weaker than it sounds. A whole-period average would report 0.90 and say nothing at all about the month that mattered. The repository's methods document names the remedy, which this project does not attempt.

Every model that was trained, on one chart

The pretrained model is the one that did not lose, with one large caveat. TimesFM was trained on none of this data and forecasts it zero-shot, with nothing fitted here at all. Its weights postdate most of these origins, though, and its training corpus contains the 2020 period in other series, so a forecast it makes of March 2020 is not the same kind of claim as every other bar above. It is drawn here only on the clean window, the origins whose whole fortnight falls after the latest documented pretraining data, and it is never pooled with the rows above it.

On that window it beats the best statistical model at every level and matches the global boosted model, at no training cost and with no per-series fitting. On the shorter cross-check after its weights were published, the one stretch nothing could have leaked into, it is about one percent behind that boosted model instead. Forty origins cannot settle which of those is the truth, and the repository says so rather than picking the window that flatters it.

For the technical reader: every model at every level, with coverage and width

Compute is comparable within a kind of model, and only roughly across them. It is the median time per forecast times the full schedule, on one desktop CPU. ETS, Theta and MSTL were fitted three at a time and each is charged a third of the shared run, which is why they read alike; AutoARIMA was run alone, so its figure is a whole machine's time. Measured alone, AutoARIMA costs about five times ETS, not the nine the chart suggests, and the repository's methods document has both runs.

Do the parts add up to the whole?

Below zero is better: reconciling lowered the forecast's loss at that level. Whiskers are 95 percent moving-block bootstrap intervals over forecast origins.
Change in CRPS against the unreconciled forecast, and coverage at the nominal level. CRPS is a loss, so negative is better. Every number is a point estimate with a 95 percent moving-block bootstrap interval over forecast origins.

The forecast as a rota, priced

The shorter the bar, the closer the rota came to one that knew each day's demand. Staffing from last week's demand is the grey bar; the slider above moves every bar.
Units staffed a day and what that cost, summed over the 31 dispatch areas and averaged over the days ahead, against an oracle that knew each day's demand and so cost nothing. Every number carries its 95 percent interval.

The slider moves the table exactly, because the table was computed at each of its stops. It also moves the dashed line on the forecast chart at the top of the page, and that line is interpolated between the bands that were exported: it is there to be read, not measured.

Cost here is counted in unit-days, not in money. One unit staffed and not needed costs 1, and one needed and missing costs 4 of the same thing, so a cost saved is a number of unit-days saved and the crew-hours beside it are those unit-days at the hours the inputs table gives them. Nothing on this page invents a rate of pay. Put your own on the crew-hours and the figure is yours; change the two costs and every number in the table moves.

What the data proved wrong

Four things were built, measured and not adopted. Each was a real cost, and the measurements are why it was dropped.

N-HiTS, the plan's neural forecaster

Beaten at every level. Its own 90 percent ranges covered 58 to 68 percent of outcomes, after 18.3 hours of fitting against ETS's 1.5.

PatchTST

The best calibrated model here, and it ties ETS at the city and the boroughs. It loses at the dispatch areas, at about seventeen times the cost.

AutoARIMA

Five times ETS's cost to finish third of the four statistical models.

A GPU

A GTX 1650 gave no speedup on these fits, so every published time is a CPU time.

The full verdict on the neural models, including the one model that did not lose, is in docs/neural-verdict.md.

What this page does not show

How it is engineered

The code is typed and tested, the backtest is checkpointed, and one command writes the README's tables and this page's data from the same stored forecasts.

278automated tests, including one that checks no model sees a day after its forecast date
9,600lines of typed Python in the package, strict type checking and linting clean in CI
911weekly forecasts per model, each for 37 series and 14 days ahead
1CPU for every fit, after a GPU was tried and gave no speedup
For the technical reader: the choices that are easy to get wrong
  • Conformal is written here, not imported. With weekly origins, a 14-day forecast's error has not happened yet at the next origin, and a library that assumes it has leaks the future into the interval.
  • The foundation model is scored only after its training data ends. TimesFM is drawn on its own clean window and never pooled with the models trained here.
  • Every comparison is paired over the same origins, and the intervals resample whole blocks of weeks, because neighbouring weeks are not independent.
  • Reconciliation moves every simulated future, not only the median, so a decision taken over the whole city is taken on futures that add up.
  • The decision inputs are a file, not constants. The two costs and the demand per crew sit in inputs/decision.toml, and every number in the rota moves when they change.
  • The page is served with the headers the host sends, locally too, so a page that only works without its content security policy is caught before it ships.

How this was built

I designed this project and made the calls in it: what to forecast, how to score it, and what to do when a model I had planned for did not earn its place. I came to it from years of forecasting health-sector utilisation. Two of my calls show in the results. I gave the neural forecasters a full, fair run, N-HiTS and PatchTST trained on every series and refitted on a schedule, and then left them out, because the numbers said so. And I wrote the conformal intervals myself rather than take them from a library, because a forecast's error is not known until its date arrives, and an interval that assumes otherwise quietly uses the future.

I used an AI coding assistant (Claude Code) for implementation and drafting, which is now standard practice in software, data science and machine learning work. Every number on this page can be reproduced from the repository with one command, from public data.

Glossary
Backtest
Forecasting dates that have already happened, using only what was known before each one, and scoring the forecasts against what did happen.
Forecast origin
The date a forecast is made from. Here there is one a week, and each forecasts the next 14 days.
Prediction interval
A range a forecast says the outcome will fall in, with a stated chance. A 90 percent interval should contain the outcome nine times in ten.
Coverage
How often an interval actually contained the outcome. Compared with the nominal level, it says whether the interval kept its promise.
Conformal prediction
A way of building intervals from a model's own past errors so that they hold as often as they claim, on average over time, as long as tomorrow's errors look like a shuffle of past ones.
CRPS
Continuous ranked probability score. It scores a whole forecast range against what happened, rewarding ranges that are both close and as narrow as the truth allows. Lower is better.
Skill
The share of the baseline's loss a model removes. Zero is no better than planning from last week; higher is better.
Seasonal naive
The baseline: each day forecast as the same weekday one or two weeks earlier.
Reconciliation (MinT)
Adjusting forecasts made separately for the areas, the boroughs and the city so that they add up, by the smallest change the errors allow.
Moving-block bootstrap
Estimating an interval by resampling whole runs of consecutive weeks, because neighbouring weeks are not independent.
Service level
The share of days the crews on shift are enough for the demand.
Newsvendor rule
The classic rule for choosing a stock level when running short and running over cost different amounts: staff to the point where the two expected costs balance.
Oracle
A rota that knew each day's demand in advance. It costs nothing, so every method is measured by how far it falls short of it.