Skip to content

A real-time traffic analysis tool for Bangalore using TomTom API and SVM. It classifies traffic as Normal or Congested and visualizes results on maps and charts.

License

Notifications You must be signed in to change notification settings

Shashwat-19/Real-Time-Traffic-Analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚦 Real-Time Traffic Analysis (Bangalore)

GitHub stars License: MIT Python


BannerBangalore Traffic Visualization Preview

🧭 Overview

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.


✨ Features

  • 📡 Live Traffic Data — Fetches real-time speed, free-flow speed, and confidence using TomTom API.
  • 🤖 Machine Learning Model — Uses SVM classifier from scikit-learn to label traffic as Normal or Congested.
  • 🧮 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

📍 Monitored Locations

📌 MG Road  
📌 Whitefield  
📌 Electronic City  
📌 Hebbal  
📌 Yelahanka

🔁 How It Works

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.

✅ Key Steps

  • 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

🧪 Try It on Google Colab

✅ No installation hassles
✅ All dependencies install automatically
✅ Results update in real-time

Open In Colab


🧰 Tech Stack

  • Language: Python 🐍
  • Libraries: Pandas, NumPy, Scikit-learn, Matplotlib, Folium
  • API: TomTom Traffic API
  • Visualization: Bar charts & interactive maps

📁 Project Structure

Real-Time-Traffic-Analysis/
├── Traffic_Analysis_Bangalore.ipynb
├── bangalore_traffic_data.csv
├── bangalore_traffic_map.html
├── utils/
│   └── preprocessing.py
├── assets/
│   └── screenshots/
└── README.md

📂 Output Files

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.

🔐 API Key Setup

To use the TomTom API:

  1. Sign up at developer.tomtom.com
  2. Create a project and generate a free API key
  3. Replace the placeholder in the notebook:
    TOMTOM_API_KEY = "YOUR_API_KEY_HERE"

🚀 Run Locally

# 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.ipynb

📖 Documentation

All code is heavily commented and documented in the notebook itself.
Additional notes and usage guides will be published on my blog.


🔒 License

This project is licensed under the MIT LICENSE. See the LICENSE file for details.


📩 Contact

Shashwat

Software Developer | Cloud & DevOps Enthusiast

🔹 Java Backend Development
🔹 Cloud Architecture & Containerization
🔹 DevOps & Scalable Systems

🚀 Open Source | Tech Innovation

Passionate about building scalable applications and contributing to transformative tech solutions.

📌 Find me here:


🔁 Fork it, run it, improve it — let’s make Bangalore traffic predictable together! 🚗

About

A real-time traffic analysis tool for Bangalore using TomTom API and SVM. It classifies traffic as Normal or Congested and visualizes results on maps and charts.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks