Skip to content

About

When a TTC subway delay is reported, how likely is it to last over 5 minutes? Real model on Toronto Open Data, with evidence and limits shown.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

22 Commits

Folders and files

Repository files navigation

TTC Predict

When a TTC subway delay is reported, how likely is it to last more than 5 minutes?

Live demo: https://danieldemoz.github.io/ttc-predict/ Status: working model on real public data. A portfolio project, not a TTC system.

Part of a Toronto transit series: ttc-predict | TTC-Line1-Optimization | toronto-transit-sentiment-nlp | interactive-transit-dashboard

What it does

You describe a delay incident: line, station, cause, time of day, and weekday or weekend. The model estimates the chance that the delay lasts more than 5 minutes. The model runs in the browser, and each result shows:

  • the average rate for all incidents,
  • the past rate for that cause alone,
  • how many similar past incidents support the estimate, with a warning when evidence is thin.

Results on new data

The model was trained on 2025 incidents (25,289) and tested on January to September 2026 incidents (21,770) that it never saw.

Model AUC Brier Precision* Recall*
Simple rule: cause only 0.801 0.086 0.39 0.45
Logistic regression (used) 0.817 0.083 0.42 0.46
Gradient boosting 0.816 0.083 0.40 0.46

*At a 30% alert threshold.

Honest finding: the model beats the cause-only rule, but only a little. Most of its skill comes from the cause code. Gradient boosting scored no better, so the simpler model is used because it is easier to explain.

Drift: in 2026 the long-delay rate fell to 11.2%, from 13.9% in 2025. The model's average prediction on 2026 was 14.1%, so its percentages run about 3 points high. The demo states this next to every result.

Responsible AI, following the Reliable AI Adoption Framework

  1. Business problem: spot reported incidents that are likely to cause long delays, so staff can act sooner. Success means ranking long delays above a simple cause-based rule, with honest percentages.
  2. Data readiness: TTC subway delay data from City of Toronto Open Data, Open Government Licence – Toronto. It contains no personal information. The station field is typed by hand, so about 1,100 spellings were grouped into 72 named stations plus "Other". See data/README.md.
  3. Governance and risk: this is low-stakes planning support and makes no decisions about people. The main risks are over-trust, weaker results on Line 4 and on security causes, and drift.
  4. Technology: a logistic regression with one-hot features and a time-based split. Exported to JSON and run in the browser with no server.
  5. People and adoption: a person reviews every estimate and can override it. The tool must not be used for rider promises or staff assessment.
  6. Outcomes and monitoring: compare predicted and actual rates monthly and review if they differ by more than 2 points. Check results by line and cause each quarter. Retrain each year.

See the model card for details.

Where it works less well (2026 test data)

  • Line 4 Sheppard: few incidents, and the model over-predicts long delays (15.8% predicted vs 9.5% actual).
  • Security causes: the weakest ranking (AUC 0.69).
  • Line 1, AM peak, and plant and infrastructure causes: percentages run 3 to 5 points high.

How to run

pip install -r requirements.txt
python model/train.py          # rebuilds docs/model.json from data/
python predict.py --line YU --station UNION --code MUIS --band "AM peak"
pytest -q

Open docs/index.html through a local server (python -m http.server -d docs) to use the demo.

Project history

An earlier version showed simulated predictions in the web demo and was trained on generated sample data. It was rebuilt in October 2026 with real data, a time-based test, and the evidence shown in the demo.

Tech stack

Python, pandas, scikit-learn, vanilla JavaScript, GitHub Pages.

License

MIT. The data is from City of Toronto Open Data, used under the Open Government Licence – Toronto.

About

When a TTC subway delay is reported, how likely is it to last over 5 minutes? Real model on Toronto Open Data, with evidence and limits shown.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages