This project demonstrates an end-to-end traffic forecasting system using:
- ARIMA – classical statistical model
- TFT (Temporal Fusion Transformer) – state-of-the-art deep learning model
Click here to see the dashboard
It includes:
- Full preprocessing pipeline
- Baseline model (ARIMA)
- Advanced deep learning model (TFT)
- Performance comparison
- Streamlit web dashboard
- Source: UCI Machine Learning Repository
- Name: Metro Interstate Traffic Volume
- Link: https://archive.ics.uci.edu/dataset/492/metro+interstate+traffic+volume
- Total Rows: 48,205
- Frequency: Hourly traffic volume
- Target Variable:
traffic_volume
This dataset contains weather, time, holidays, and hourly traffic flow measurements.
To build a robust multi-step (24-hour) traffic forecasting application and demonstrate why TFT significantly outperforms ARIMA for real-world traffic prediction.
- ARIMA
- Temporal Fusion Transformer (PyTorch Forecasting)
- PyTorch Lightning
- Pandas, Numpy
- Feature engineering (lags, rolling windows, embeddings)
- Streamlit web app
- Model checkpoint loading (no retraining required)
Key feature engineering steps:
- Parsed timestamps → extracted:
hour,weekday,weekend,month,rush_hour - Encoded categorical features:
weather_main,weather_description,holiday - Added lag features:
lag_1(previous hour)lag_24(previous day same hour)
- Added rolling averages:
roll_3(3-hour mean)roll_24(24-hour mean)
- Train-val-test split:
- Train: 2012–2016
- Val: 2017
- Test: 2018
- Univariate
- Fast to train
- Struggles with non-linear seasonal behavior
ARIMA RMSE: ≈ 1989
A powerful attention-based architecture for multi-horizon forecasting.
Uses:
- Covariates (weather, time, rolling features)
- Variable selection networks
- Static & dynamic embeddings
- Multi-head temporal attention
TFT Performance :
- Overall RMSE ≈ 287
- t+1 RMSE ≈ 169
- t+6 RMSE ≈ 457
- t+24 RMSE ≈ 63
This represents over 85% performance improvement compared to ARIMA.
Traffic forecasting is critical for:
Adaptive signal control reduces congestion.
Used by Google Maps & Waze for accurate ETA prediction.
Demand-aware bus/train scheduling.
Optimized routing for ambulances, fire services, and police.
Helps identify bottlenecks, plan flyovers, signal placements.
Less idling → lower emissions → healthier cities.
This project replicates the core logic used in Intelligent Transportation Systems (ITS) and Smart City infrastructure.
The Streamlit app includes:
- ARIMA forecast visualization
- TFT multi-horizon forecast
- Model performance metrics
- Comparison plots
- Dataset overview
- GitHub link and modern UI layout
Run locally:
git clone https://github.com/a-anuj/tft-traffic-volume-analysis.git
cd tft-traffic-volume-analysis
streamlit run app.py- TFT outperforms ARIMA across all forecast horizons
- Learns complex seasonal and weather-driven traffic patterns
- Shows strong stability and accuracy for long-term predictions
- Suitable for real-world deployment in smart transportation systems
- Produces reliable and consistent 24-hour forecasts