ShiftDemand

Forecasting six-hour emergency medical incident volume across New York City and testing generalization against San Francisco dispatch records without patient data.

(Targeted track award: **Excellence in Research & Reproducibility)


1. The Problem

Municipal emergency medical service (EMS) supervisors and dispatch planners decide hours ahead of a shift how to stage ambulances, allocate overtime, or flag likely surge windows across neighborhoods. Relying only on last week's counts or a fixed multi-week seasonal average reacts slowly when call volume drifts over several days or shifts abruptly around holidays and Daylight Saving Time transitions.

At the same time, forecasting operational demand should not require patient-level medical records or proprietary dispatch feeds. I built ShiftDemand to test how far strictly causal, aggregate public dispatch counts can go in predicting next-shift EMS incident volume across New York City's five boroughs (2,184 six-hour shifts spanning 2025 through June 2026), and—crucially—to test whether weights trained on New York survive external transfer to an independent city (San Francisco Fire Department) with a different reporting taxonomy.

2. The Method

ShiftDemand operates strictly on aggregated incident start timestamps—no patient identifiers, caller details, or clinical notes are ever requested.

  1. Privacy-preserving aggregate inputs: From NYC Open Data (FDNY 76xm-jjuj, January 2021–June 2026), I aggregated 8,728,455 valid dispatch records (28 unallocated calls excluded) into four six-hour local civil shifts per day (00:00, 06:00, 12:00, 18:00 America/New_York) for each of the five boroughs, explicitly passing each shift's physical elapsed hours (5, 6, or 7) so spring-forward and fall-back Daylight Saving transitions are modeled cleanly.
  2. Relative multiplicative tree model: Because Staten Island receives a fraction of Brooklyn's call volume, forecast.py predicts the relative residual around an eight-week same-borough, same-weekday, same-hour seasonal baseline (y / eight_weeks - 1) using scikit-learn's HistGradientBoostingRegressor (loss="absolute_error", max_iter=170, max_leaf_nodes=15, min_samples_leaf=32, l2_regularization=1). Inputs cover strictly past rolling demand ratios (1 to 56 shifts at both borough and citywide levels), holiday adjacency flags, cyclic day-of-year terms, and shift elapsed hours.
  3. Locked out-of-time protocol (protocol.json):
    • Train (2021–2023): Fit the gradient-boosted residual model.
    • Select (Jan–Jun 2024): Pick the strongest reference baseline (recent_adjusted, which scales the 8-week seasonal mean by the prior 48-hour observed-to-expected ratio, MAE 16.15) and the optimal blend weight (1.0 for New York, MAE 14.91) on validation data.
    • Calibrate (Jul–Dec 2024): Fix nominal 90% empirical prediction intervals from out-of-sample residual quantiles per borough and shift hour (3,680 calibration rows).
    • Freeze & Evaluate (2025 and Jan–Jun 2026): Lock all parameters before inspecting either test period.
  4. Local replay and CLI verification: build_demo.py packages 2,184 held-out shifts into a standalone browser viewer (results/shift-replay.html) that hides recorded outcomes until requested, while replay.py re-runs single-shift inference strictly from prior counts (load_counts(as_of=at)) and checks numerical agreement (< 1e-6) against the frozen archive.

3. Evaluation

All metrics below compare the frozen model against the pre-selected seasonal reference across contiguous calendar-week paired block bootstraps (5,000 replicates for volume MAE; 10,000 replicates for daily overload reviews).

A. Primary New York City Out-of-Time Holdouts

Test Period Borough-Shifts Calls Model MAE Reference MAE MAE Reduction (95% CI) WAPE 90% Coverage
2025 (full year) 7,300 1,612,266 15.08 16.68 -9.58% [-1.93, -1.27] 6.83% 90.44%
Jan–Jun 2026 (H1) 3,620 792,938 16.85 18.14 -7.07% [-1.71, -0.82] 7.69% 88.48%

Error fell in every single borough in both 2025 and Jan–Jun 2026, with the largest gains during peak daytime shifts (12:00–18:00 MAE dropped -13.43% in 2025, from 19.66 to 17.02). At the same time, individual shifts remain noisy: on 2026-06-01 12:00 in the Bronx, the model forecast 376 incidents (90% band 337–420, reference 358) while FDNY recorded 310—an honest 66-incident miss that shows why single-shift anecdotes cannot substitute for multi-year calibration.

B. External Validation in San Francisco (DataSF nuek-vuh3)

Because San Francisco's public dispatch table logs individual dispatched units rather than borough totals, external_sf/fetch.py filters specifically for Medical Incident calls and deduplicates by incident_number at earliest receipt (1,296,766 unit rows collapsed cleanly into 693,255 unique incidents, ~1.87 units per call, verified by an independent full-window SQL/API check).

  • Zero-shot transfer fails cleanly: Running the frozen New York weights unmodified on San Francisco (America/Los_Angeles, averaged across NYC's five borough codes) gave 9.14 vs. 9.26 MAE in 2025 (95% CI [-0.28, +0.04]) and 9.41 vs. 9.42 in Jan–Jun 2026 ([-0.23, +0.20]). Both uncertainty intervals crossed zero, confirming that cross-city dynamics do not transfer without local calibration.
  • Local refitting succeeds under the exact same pipeline: Training the identical model family on San Francisco's 2021–2023 history (selecting a 0.5 blend with SF's 8-week seasonal reference on H1 2024 and calibrating intervals on H2 2024) lowered MAE from 9.04 to 8.84 (-2.22%, 95% CI [-0.33, -0.09], 90.14% coverage) in 2025, and from 9.51 to 9.36 (-1.56%, 95% CI [-0.27, -0.02], 90.06% coverage) in Jan–Jun 2026.

C. Operational Triage Stress Test & Zero-Leakage Audits

  • One workload review per day (alert_budget.py, overload_classifier.py): Simulating a fixed budget of one shift review per local day (targeting volume >= the 2024 90th percentile via backward induction), the volume model achieved lower Brier probability error than the seasonal reference across all four city-period tests (0.0603 vs 0.0734 in NYC 2025; 0.0668 vs 0.0795 in NYC H1 2026; 0.0974 vs 0.1002 in SF 2025; 0.1120 vs 0.1139 in SF H1 2026), and also outperformed a direct binary classifier in three of those four tests (0.1120 vs 0.1102 in SF H1 2026). On binary hit counts (95/210 vs 86 in NYC; 101/268 vs 108 in SF), paired weekly 95% CIs crossed zero, showing that modest MAE gains do not automatically translate into dramatic daily threshold-alert gains.
  • Leakage & byte-reproducibility checks (audit.py, external_sf/audit.py): Perturbing future records past 2025-03-09, 2025-11-02, and 2026-06-01 changes prior forecasts by 0.0, and an independent offline rebuild from cached CSVs reproduces exact SHA-256 hashes for every prediction file on one CPU thread.

4. Impact Analysis: Who Benefits, and Who Could Be Harmed

  • Who benefits: EMS operations analysts, dispatch supervisors, and public-health researchers gain an open, auditable baseline with honest prediction intervals and zero patient privacy risk, making it easy to benchmark whether more complex models actually beat an adjusted 8-week seasonal rule before deploying them.
  • Who could be harmed:
    1. Patients in under-resourced neighborhoods if used to cut crews: Because the model is trained to minimize average count error (MAE), a naive planner treating low predicted counts or narrow 90% intervals as justification to reduce baseline ambulance staffing could worsen response delays during rare, sudden mass-casualty or heatwave spikes. Notice that ~10% of shifts still fall outside a calibrated 90% interval by design.
    2. Agencies assuming plug-and-play portability: As the San Francisco frozen-weight experiment directly demonstrates, transferring weights trained on one city's dispatch definitions to another without local refitting produces no reliable benefit and can misstate calibration intervals.
    3. Neighborhood equity blind spots: New York predictions operate at the borough level and San Francisco predictions cover the whole service area. Aggregate counts can look normal while severe local hotspots or unequal response times emerge inside specific ZIP codes.

5. Limitations

  • Delayed public archive vs. live CAD: NYC Open Data and DataSF publish dispatch logs on an archive schedule rather than real-time streaming. Operational use assumes internal dispatch systems can supply completed shift totals immediately after each six-hour boundary.
  • Incident counts do not measure acuity or unit-hours: One cardiac arrest requiring multiple advanced life support units and prolonged hospital turnaround consumes far more capacity than one minor low-acuity call, yet both contribute +1 to the incident total.
  • Retrospective evaluation only: Neither dispatch response times, ambulance utilization, nor clinical patient outcomes were measured in a live agency trial.
  • Rare-surge sensitivity: The daily alert-budget experiment shows that while continuous probability calibration improves consistently, hitting extreme 90th-percentile tail shifts under a strict 1-review-per-day cap remains statistically indistinguishable from a seasonal baseline.

6. Future Steps (With One More Month)

  1. Incorporate live operational covariates without PII: Add public hourly weather forecasts (heat index, freezing rain), major scheduled city events, and rolling hospital diversion/turnaround indicators where legally and publicly available.
  2. Model acuity-weighted workload and sub-borough zones: Separate high-acuity priority calls from low-acuity transports and downscale forecasts from whole boroughs to EMS station battalions so spatial bottlenecks become visible.
  3. Prospective shadow deployment: Run the frozen pipeline in silent shadow mode alongside live dispatch feeds for 30 days to measure real-time data latency, missing-timestamp handling, and planner usefulness before touching any staffing decision.

AI Assistance & Data Attribution

  • Public Datasets: All incident data come exclusively from NYC Open Data — FDNY EMS Incident Dispatch Data (76xm-jjuj) and DataSF — Fire Department and Emergency Medical Services Dispatched Calls (nuek-vuh3). Both sources are queried at aggregate/incident-count level only.
  • AI Tool Disclosure: OpenAI Codex and Antigravity AI coding assistants helped implement the data-fetching scripts, gradient-boosted training/audit pipeline, static replay viewer, verification checks, and video recording script. I scoped the cross-city external validation design, enforced strict chronological freezing and zero-leakage testing, and oversaw every documentation rewrite and demonstration output. The runtime forecasting model (HistGradientBoostingRegressor) runs deterministically on local CPU without any generative AI calls. Spoken audio in the demonstration video uses neural text-to-speech (edge-tts) synced to live browser and CLI captures.
Share this project:

Updates

Submission history