This repository contains the implementation of Tramba, a Mamba-based model with adaptive attention designed for urban traffic speed prediction. It jointly models long-range temporal dependencies and non-local spatial correlations to capture complex traffic dynamics in dense urban networks.
The Tramba model integrates:
- Adaptive attention to capture non-local spatial correlations across road links,
- Mamba to capture temporal dependencies,
- Gated fusion of spatial and temporal features.
├── data/
│ └── seoul_traffic_speed (sample).csv # Sample 5-minute speed data for Gangnam links
│ └── GN_links.csv # Metadata for Gangnam road link IDs
├── results/ # Saved results will be stored here
├── data_loader.py # Data preprocessing and sequence construction
├── models.py # Tramba model definition
├── run_tramba.ipynb # Training and evaluation notebook
- The dataset includes 5-minute interval speed records (in km/h) for road links in the Gangnam-gu area of Seoul, South Korea.
- It is publicly available via TOPIS upon request.
- This repository includes a sample dataset.
- Disclaimer: The author does not have the right to redistribute the full dataset.
This file contains traffic speed time-series with the following columns:
| Column | Description |
|---|---|
| PRCS_YEAR | Year of observation |
| PRCS_MON | Month of observation |
| PRCS_DAY | Day of observation |
| PRCS_HH | Hour of observation |
| PRCS_MIN | Minute of observation |
| LINK_ID | Unique identifier of a road link (integer) |
| PRCS_SPD | Average speed in km/h |
A datetime index is constructed from the time columns for temporal sorting and sequence construction.
This file filters the set of links used for training. It contains:
| Column | Description |
|---|---|
| fid | Row index or feature ID |
| LINK_ID | Original identifier from the GIS network |
| s_link | Final link ID used in modeling and filtering speed observations |
The
s_linkcolumn lists link IDs that will be included in training. Only rows inseoul_traffic_speed.csvwhoseLINK_IDis in this list are used.
Note: To successfully run the model, the
s_linkvalues inGN_links.csvmust include allLINK_IDs that appear in theseoul_traffic_speed.csvdataset.
Inside run_tramba.ipynb, you can customize:
SEQ_LIST: input sequence lengths (e.g.,[36, 48])PRED_LIST: output horizon lengths (e.g.,[1, 6, 12, 24, 36])D_MODEL,BATCH_SIZE,EPOCHS: model and training settings
After training, the script will generate:
- Trained weights in
results/ - Runtime logs and training loss/val loss history (
.pkl) - Evaluation metrics in CSV format