Navetra predicts near-future traffic speeds on large urban road networks and uses those predictions directly for routing decisions.
Unlike classical navigation systems that react only to current conditions, Navetra explicitly models how traffic evolves over time and computes routes based on expected future states.
Navetra operates on a city-scale road graph and provides:
- Segment-level traffic speed forecasts
- Time-dependent routing using predicted travel times
- Route optimization over future departure windows
- A unified API that works with or without trained ML models
Routing decisions are driven directly by predicted speeds rather than post-hoc heuristics.
Navetra combines spatial and temporal learning in a modular pipeline.
A graph neural network operating on an edge-as-node road graph captures how congestion propagates across connected road segments.
A patch-based temporal transformer models longer-range temporal patterns such as:
- Rush hour dynamics
- Weekday vs weekend behavior
- Night-time traffic recovery
Together, this hybrid architecture enables accurate forecasting of future traffic conditions across the network.
An STGAFormer-based model is included as an experimental baseline for comparison.
Evaluated on a large Istanbul road graph using future speed prediction and end-to-end routing metrics:
| Metric | Result |
|---|---|
| Speed MAE | ~2–3 km/h |
| ETA RMSE | ~5 minutes |
| Hit@±5 min | ~89% |
ETA errors are measured along full predicted routes rather than individual segments.
All visualizations are generated directly from model outputs and routing results.
Navetra follows a production-oriented pipeline:
- Road network extraction from OSM or shapefiles
- Graph construction (segments + directed adjacency)
- Spatio-temporal data generation
- GNN + temporal model training
- Prediction and routing served via a Flask API
- Web or mobile clients consume future-aware routes
The same API operates in both ML-driven and simulation-driven modes.
python traffic_prediction_api.py ^
--model_path path\to\model.pth ^
--model_type dstcgcn_patchtst ^
--data_dir complete_training_data ^
--port 5000GET http://localhost:5000/health
Returns model status, loaded datasets, and graph size.
-
GET /health
Returns system status and active prediction mode. -
GET /traffic/current
Returns predicted segment speeds within a viewport. -
GET /predict/all
Lightweight speed predictions (optionally bounded). -
POST /route/optimize
Finds the best departure time within a future window. -
POST /routes/forecast
Returns multiple future routes for different departure times.
- Directed graph with time-dependent edge weights
- Edge weight equals predicted travel time
- Future departure times interpolate predicted speeds
- Routing uses sparse Dijkstra for scalability
Routing decisions are fully driven by predicted traffic evolution.
Navetra explicitly distinguishes between operating modes:
-
ML Mode
Uses trained GNN + PatchTST models when artifacts are available. -
Simulation Mode
Falls back to a time-aware, road-type-aware traffic simulation when models or features are missing.
Both modes expose identical API endpoints.
Navetra is suitable for:
- Spatio-temporal traffic modeling research
- Urban mobility experiments
- Smart city simulations
- Mobile or web-based routing applications
The system prioritizes clarity, correctness, and extensibility.