Skip to main content

Models of the TfL transit network

Project description

Tubeulator Models

Three graph neural network models of the London Underground, each predicting routes at a different granularity:

  • line — sequence of (line, direction) pairs: "take the Jubilee westbound, then the Northern northbound"
  • change — adds interchange stations: where exactly to transfer between lines
  • station — full station-by-station path from origin to destination
  • nexthop

All three share a GATv2 encoder over the station topology graph and differ only in their decoder head.

Quickstart

just all        # fetch data + build graph + enumerate routes + train all models

Or step by step:

just fetch      # pull timetables from TfL API → GTFS zip
just graph      # GTFS → GeoParquet → PyG graph objects
just routes     # enumerate routes for all origin-destination pairs
just train-all  # train line, change, and station models sequentially

Training

just train change           # single model, default profile (dev)
just train station full     # single model, full profile
just train-all              # all three, default profile
just train-full             # all three, full profile
just dev                    # rebuild routes + train change model (fast iteration)

All hyperparameters live in defaults.toml. CLI flags override the TOML but never replace it:

tm-train --model line --profile full --lr 5e-5

Profiles control the training regime:

Profile Epochs Batch size LR Notes
dev 20 512 5e-4 Fast iteration
full 200 256 1e-4 Production, d_model=256, deeper encoder

Note: to train the value primary use

just train nexthop full --value-primary --batch-size 1024 --epochs 200

Data pipeline

Each step has a CLI entry point and a corresponding justfile recipe:

Step CLI Recipe Output
Fetch timetables tm-build-gtfs just fetch data/tfl_station_data_gtfs.zip
Build graph tm-gtfs2pyg just graph data/graph/, data/pyg/
Enumerate routes tm-build-routes just routes data/routes.json
Plot network tm-plot just plot data/graph/network.png
Train tm-train just train checkpoints/

Staged graph conversion is also available if you only need to re-run part of the pipeline:

uv run --group prep    tm-gtfs2graph   # GTFS → GeoParquet
uv run --group pyg     tm-graph2pyg    # GeoParquet → PyG .pt

Configuration

defaults.toml is the single source of truth for all tuneable values. The merge order is:

[base] → [model.<type>] → [profiles.<name>] → [profiles.<name>.model.<type>] → CLI overrides

Development

just lint       # ruff check
just clean      # remove data/ and checkpoints/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tubeulator_models-0.1.0.tar.gz (58.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tubeulator_models-0.1.0-py3-none-any.whl (70.9 kB view details)

Uploaded Python 3

File details

Details for the file tubeulator_models-0.1.0.tar.gz.

File metadata

  • Download URL: tubeulator_models-0.1.0.tar.gz
  • Upload date:
  • Size: 58.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22","id":"wilma","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tubeulator_models-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b1201099aaab88cfd2629790b01e766d384812f10168c33773bfe9a38a9ea3b9
MD5 8f1f55d3e5dfe73a51d2cefce6894ae3
BLAKE2b-256 a15a9dcb74d294bb6c607a6d8cf3cc1c93ba9441cb5f76b06d74c2f2104ff0c7

See more details on using hashes here.

File details

Details for the file tubeulator_models-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tubeulator_models-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 70.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22","id":"wilma","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tubeulator_models-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e24df7ba1ca0f7ee529c91132fd87b8e6bd935fec13494e3b912ebb551b394ec
MD5 0f30c55d1d4ed38efc9c94acee842dc6
BLAKE2b-256 ef15e71b788caf9b2d043bcec2458cbf96a59da298b9b1eb9ca6a499d153e8b7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page