A Python-based traffic forecasting system that uses machine learning (XGBoost) to estimate road traffic intensity based on various weather and calendar data. The project includes a data processing unit, a model training script, and a modern, dark-mode graphical user interface (GUI).
- Automated Data Processing: Cleaning raw traffic data and extracting key features.
- XGBoost Regression Model: High-precision traffic estimation based on historical data.
- Interactive Dashboard: User-friendly interface for adjusting prediction parameters.
- Live Weather Integration: Real-time forecast retrieval using the Open-Meteo API.
- Visual Analysis: 24-hour traffic trend visualization on a graph.
The project consists of three main components:
ConverterV2.py: Data preparation script. It converts units (Kelvin -> Celsius), handles missing data, and calculates calendar variables (weekend, holiday).Learning.py: Machine learning module. It loads the prepared data, trains theXGBRegressormodel, and saves it into a.pklfile.App.py: The main application. Acustomtkinter-based interface where predictions can be run using manually entered or API-fetched data.
Using the system involves three simple steps:
Run the ConverterV2.py script to transform the raw database (Metro_Interstate_Traffic_Volume.csv):
python scripts/ConverterV2.pyThis will create the AI_ready_traffic_data.csv file.
Train the AI model on the processed data:
python scripts/Learning.pyAt the end of the process, the traffic_model(Regressor).pkl file containing the trained model will be created.
Start the graphical dashboard:
python scripts/App.py- Training Data: UCI Machine Learning Repository - Metro Interstate Traffic Volume
- Weather Forecast: Open-Meteo API (No API key required)
It is free to use and modify.