Predictive Adaptive Traffic Signal System
A Python prototype that simulates intelligent traffic signal control using machine learning — demonstrating measurable improvement over fixed-timer signal systems used in Indian cities today.
Built as part of a smart infrastructure research initiative aligned with NHAI's traffic management objectives.
PRAVAH reduced average vehicle wait time by 14.4% during peak hours and 5.1% overall in a simulated urban intersection environment.
Peak hours (7–9am, 5–7pm) show the highest gains — exactly when congestion costs the most. Off-peak hours intentionally favour simpler logic, since adaptive overhead isn't justified at low volumes. This is a deliberate design choice, not a limitation.
| Component | What it solves |
|---|---|
| Data Generator | Simulates 30 days of realistic 24hr traffic (2,880 records) with morning/evening peaks |
| Prediction Model | Polynomial regression with cyclical time encoding — predicts vehicle count per 15-min interval |
| Signal Logic | Compares fixed 30s green (current standard) vs PRAVAH adaptive green (scales with predicted load) |
| Visualizer | 3-panel dashboard: traffic volume, signal timing, wait time comparison |
traffic_data.csv
│
▼
data_generator.py ← synthetic 24hr traffic with realistic peaks
│
▼
model.py ← polynomial regression, cyclical feature encoding
│ (predicted volume)
▼
signal_logic.py ← adaptive_signal() vs fixed_signal() + wait time sim
│ (simulation results)
▼
visualize.py ← 3-panel matplotlib dashboard
Requirements
pip install pandas numpy scikit-learn matplotlibRun full pipeline
python main.pyThis runs all 4 phases in sequence and generates all output files.
Run individual modules
python data_generator.py # generate traffic data only
python model.py # train and evaluate model only
python signal_logic.py # run simulation only
python visualize.py # generate plots only| File | Description |
|---|---|
traffic_data.csv |
2,880-record synthetic dataset |
model.pkl |
Trained regression model |
simulation_results.csv |
Hour-by-hour fixed vs adaptive comparison |
pravah_results.png |
Full visualization dashboard |
- Algorithm: Polynomial Regression (degree 4) via scikit-learn Pipeline
- Features:
time_of_day,hour_sin,hour_cos(cyclical encoding),is_peak - Why cyclical encoding: Hour 23 and hour 0 are numerically distant but traffic-wise similar. sin/cos encoding preserves this continuity.
- Performance: MAE ≈ 7.3 vehicles | R² ≈ 0.937
# Fixed (current reality)
green = 30s # always, regardless of traffic
# PRAVAH Adaptive
ratio = predicted_volume / max_expected_volume
green = MIN_GREEN + ratio × (MAX_GREEN - MIN_GREEN)
green = clamp(green, 15s, 75s)Wait time is estimated using a Webster's formula approximation — standard in traffic engineering literature.
pravah/
├── main.py ← runs full pipeline
├── data_generator.py ← synthetic traffic data
├── model.py ← prediction model
├── signal_logic.py ← adaptive vs fixed simulation
├── visualize.py ← dashboard plots
├── traffic_data.csv ← generated dataset
├── simulation_results.csv ← comparison output
├── pravah_results.png ← visualization
└── README.md
- Single intersection simulation — real networks have cascading effects
- Synthetic data — real deployment needs live sensor/camera feeds
- No vehicle classification — trucks and motorcycles have different discharge rates
- Webster's approximation — full microsimulation (SUMO, VISSIM) would be more precise
These are known next steps, not unknown gaps.
| NHAI Priority | PRAVAH Contribution |
|---|---|
| Reduce urban congestion | Adaptive signal reduces peak wait time by 14.4% |
| Data-driven infrastructure | ML model trained on traffic patterns |
| Emergency vehicle priority | Architecture supports green corridor extension |
| Scalable deployment | Modular design — each component is independently replaceable |
Developed by Aryan — Delhi Technological University