Real-Time Traffic Analysis is a machine learning project that leverages the TomTom Traffic API to analyze live traffic conditions in Bangalore. It classifies routes as Congested or Normal using a Support Vector Machine (SVM) and visualizes both predictions and real data on an interactive map and performance charts.
📦 Latest Version: v1.0
This version introduces live traffic monitoring, real-time predictions, and a visual map powered by Folium.
- 📡 Live Traffic Data — Fetches real-time speed, free-flow speed, and confidence using TomTom API.
- 🤖 Machine Learning Model — Uses SVM classifier from
scikit-learnto label traffic asNormalorCongested. - 🧮 Performance Metrics — View confusion matrix and classification report.
- 📊 Bar Chart Visualization — Displays actual vs predicted traffic labels.
- 🗺️ Interactive Folium Map — Highlights traffic status with colored markers:
- 🟢 Green = Normal
- 🔴 Red = Congested
📌 MG Road
📌 Whitefield
📌 Electronic City
📌 Hebbal
📌 Yelahanka
The project fetches real-time traffic data from the TomTom API for various Bangalore locations. It extracts features like current speed, free flow speed, and confidence, and labels traffic as either Normal or Congested based on defined thresholds. An SVM classifier is trained on this data to predict traffic conditions, and results are visualized using charts and an interactive map.
- Fetch live traffic data (speed, free flow speed, confidence)
- Label data based on speed drop and confidence
- Train and test SVM classifier
- Visualize predictions vs actuals in a bar chart
- Display traffic on a folium map with color-coded markers
✅ No installation hassles
✅ All dependencies install automatically
✅ Results update in real-time
- Language: Python 🐍
- Libraries: Pandas, NumPy, Scikit-learn, Matplotlib, Folium
- API: TomTom Traffic API
- Visualization: Bar charts & interactive maps
Real-Time-Traffic-Analysis/
├── Traffic_Analysis_Bangalore.ipynb
├── bangalore_traffic_data.csv
├── bangalore_traffic_map.html
├── utils/
│ └── preprocessing.py
├── assets/
│ └── screenshots/
└── README.md
| File | Description |
|---|---|
bangalore_traffic_data.csv |
Dataset with traffic features and labels |
bangalore_traffic_map.html |
Interactive traffic map for Bangalore |
| Inline graphs (in Colab) | Classification report, confusion matrix etc. |
To use the TomTom API:
- Sign up at developer.tomtom.com
- Create a project and generate a free API key
- Replace the placeholder in the notebook:
TOMTOM_API_KEY = "YOUR_API_KEY_HERE"
# Clone the repo
git clone https://github.com/Shashwat-19/Real-Time-Traffic-Analysis.git
cd Real-Time-Traffic-Analysis
# Open Jupyter Notebook
jupyter notebook Traffic_Analysis_Bangalore.ipynbAll code is heavily commented and documented in the notebook itself.
Additional notes and usage guides will be published on my blog.
This project is licensed under the MIT LICENSE. See the LICENSE file for details.
Software Developer | Cloud & DevOps Enthusiast
🔹 Java Backend Development
🔹 Cloud Architecture & Containerization
🔹 DevOps & Scalable Systems
Passionate about building scalable applications and contributing to transformative tech solutions.
🔁 Fork it, run it, improve it — let’s make Bangalore traffic predictable together! 🚗
