Deploying advanced neural telemetry to mitigate road hazards before they manifest.
97.0% Model Accuracy · 94.8% Risk Sensitivity · 58,347 Telemetry Vectors
- Introduction
- Problem Statement
- Objective
- Our Solution
- Tech Stack
- System Architecture
- Database Design
- Results & Conclusion
- Future Scope
Road accidents remain one of the leading causes of preventable death and injury worldwide. Despite advances in vehicle safety technology, the underlying danger often lies in the road environment itself — specific geographic locations, time windows, and environmental conditions that systematically produce higher incident rates.
SafeRoute AI is an intelligent, full-stack geospatial safety platform that leverages machine learning and real-time telemetry to predict accident hotspots before a user even reaches them. Rather than reacting to accidents after they occur, SafeRoute AI shifts the paradigm to proactive, data-driven road safety intelligence.
The platform combines:
- A trained ML model built on 58,347 localized incident records
- A real-time interactive map (Atlas Traffic Grid) powered by live traffic APIs
- A neural risk prediction engine that evaluates risk probability from GPS coordinates
- A model analytics dashboard presenting performance benchmarks in real-time
SafeRoute AI is not just a mapping tool — it is a paradigm shift in urban mobility, enabling drivers, city planners, and emergency responders with absolute spatial awareness so that the safest path is always known before the journey even begins.
Road accident data is widely collected but rarely acted upon proactively. The core issues are:
| Problem | Impact |
|---|---|
| Lack of real-time hotspot visibility | Drivers enter high-risk zones uninformed |
| Reactive safety measures | Interventions happen after accidents occur |
| Underutilized historical accident data | Black-spot patterns go undetected at scale |
| Disconnected data sources | Weather, traffic, and geography are siloed |
| Limited access to predictive tools | Risk intelligence is not available to everyday drivers |
Specifically:
- High-density urban corridors exhibit recurring accident clusters that are invisible to navigation systems.
- Time-of-day and day-of-week patterns are strong predictors of accident probability but are ignored by conventional GPS apps.
- Emergency responders lack predictive spatial intelligence to pre-position resources optimally.
- City planners have no real-time feedback loop to evaluate infrastructure risk zones.
The absence of a unified, ML-driven, accessible platform for proactive road hazard prediction leaves millions of road users vulnerable to preventable incidents every day.
The primary objectives of SafeRoute AI are:
-
Identify Historical Accident Hotspots — Process and geocode historical incident data to identify statistically significant accident clusters across road networks.
-
Build a Predictive ML Model — Train a high-accuracy machine learning model capable of predicting accident probability at any given coordinate with >95% accuracy.
-
Enable Real-Time Risk Assessment — Deploy the model behind a live API that evaluates user-submitted GPS coordinates and returns risk scores with contextual safety recommendations.
-
Visualize Live Traffic Incidents — Integrate real-time traffic data APIs to overlay current incidents, delays, and road hazards onto an interactive map.
-
Provide Actionable Safety Insights — Surface concise, prioritized safety protocols and routing recommendations based on the predicted risk level.
-
Deliver an Intuitive User Interface — Design a premium, accessible frontend that presents complex geospatial intelligence clearly to non-technical users.
-
Benchmark & Validate Model Performance — Provide a transparent analytics dashboard showing model evaluation metrics, confusion matrix, and class-level performance.
SafeRoute AI delivers a four-layer intelligent safety platform:
An interactive map (powered by Leaflet.js + React-Leaflet) that:
- Fetches live traffic incident data from a FastAPI backend (sourced from TomTom traffic APIs)
- Visualizes incidents as colour-coded polylines (Green → Red based on magnitude of delay)
- Allows users to double-tap/click any geographic location to pin a custom target
- Instantly scans a 1 km² grid around the pinned location by calling the ML model API
- Displays a Safe Zone or High Risk Zone alert based on historical accident cluster proximity
- Supports 3 map tile modes: Dark, Light, and Satellite (ArcGIS)
A dedicated prediction interface that:
- Accepts latitude/longitude coordinates (manual entry or auto-filled from device GPS)
- Sends coordinates to the FastAPI
/predictendpoint, which runs the trained ML model - Returns a risk score (probability), risk level (Low/Medium/High/Critical), and confidence %
- Displays a Correlation Matrix — impact values for Historical Data, Spatial Correlation, Severity Index, and Cluster Density
- Provides Safety Protocol recommendations tailored to the predicted risk level
A comprehensive metrics dashboard presenting:
- Overall Accuracy: 97.0% across 29,113 validation samples
- Risk Sensitivity (Recall): 94.8% — True Positive Rate for risky locations
- Safe Specificity: 98.1% — True Negative Rate for safe locations
- Macro F1-Score: 97.0%
- Radar Chart — multidimensional performance profile
- Confusion Matrix — True Safe (17.6K), True Risky (10.5K), False Risky (340), False Safe (577)
- Synthetic Evaluation Bar Chart — Precision, Recall, F1 for LOW/MEDIUM/HIGH hazard classes
A dataset-level visualization showing the geographic spread of the 58,000+ localized telemetry records used to train the neural architecture, giving users confidence in the model's spatial coverage.
| Technology | Purpose |
|---|---|
| React 18 | Component-based UI framework |
| TypeScript 5 | Type-safe development |
| Vite 5 | Lightning-fast dev server and bundler |
| TailwindCSS 3 | Utility-first responsive styling |
| GSAP 3 + ScrollTrigger | Premium scroll-driven animations |
| Framer Motion 12 | Micro-animations and transitions |
| React Router DOM v6 | Client-side multi-page routing |
| Leaflet.js + React-Leaflet | Interactive geospatial mapping |
| Recharts | Radar, Bar, and Pie charts for analytics |
| Radix UI (Shadcn/ui) | Accessible, headless UI components |
| TanStack React Query | Server state management |
| Lucide React | Icon library |
| Lenis | Smooth scroll engine |
| Zod + React Hook Form | Form validation |
| Technology | Purpose |
|---|---|
| FastAPI (Python) | High-performance REST API server |
| Uvicorn | ASGI server for async Python |
| HTTPS (SSL/TLS) | Secure communication for location permissions |
| TomTom Traffic API | Live traffic incident data feed |
| Technology | Purpose |
|---|---|
| Python | ML model development |
| Scikit-learn / Ensemble Models | Classification model training |
| Dataset: 58,347 records | Historical accident telemetry vectors |
| Feature set: (58347, 8) | 8-dimensional spatial + temporal features |
| Validation set: 29,113 samples | Held-out evaluation split |
┌─────────────────────────────────────────────────────────────────────┐
│ USER BROWSER │
│ │
│ ┌──────────┐ ┌──────────┐ ┌────────────┐ ┌──────────────────┐ │
│ │ Landing │ │ Hotspot │ │ Risk │ │ Analytics │ │
│ │ Page │ │ Map │ │ Prediction │ │ Dashboard │ │
│ └────┬─────┘ └────┬─────┘ └─────┬──────┘ └──────────────────┘ │
│ │ │ │ │
│ ┌────▼──────────────▼──────────────▼──────────────────────────┐ │
│ │ React + TypeScript SPA (Vite) │ │
│ │ React Router │ GSAP Animations │ Zustand │ TanStack Query │ │
│ └────────────────────────────┬────────────────────────────────┘ │
│ │ HTTPS Requests │
└───────────────────────────────┼─────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────────┐
│ FASTAPI BACKEND (Python) │
│ │
│ POST /predict POST /traffic POST /scan │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ ML Model │ │ TomTom │ │ Grid │ │
│ │ Inference│ │ Traffic │ │ Scanner │ │
│ │ Engine │ │ API Proxy│ │ (Batch │ │
│ └──────────┘ └──────────┘ │ Predict) │ │
│ └──────────┘ │
└──────────────────────────────────────────────────────────────────────┘
│ │
▼ ▼
┌────────────────┐ ┌──────────────────────┐
│ Trained ML │ │ TomTom Traffic │
│ Model (Pickle │ │ Incident Data API │
│ / Joblib) │ │ (Live Feed) │
└────────────────┘ └──────────────────────┘
- User opens app → React SPA loads, geolocation requested
- Hotspot Map → User location fetched →
/scanAPI called → ML model predicts risk for a grid of nearby coordinates → Results overlaid on Leaflet map - Traffic Layer → Frontend sends map bounding box to
/traffic→ FastAPI proxies to TomTom API → Incidents rendered as coloured polylines - Risk Prediction → User enters coordinates →
/predictcalled → Model returns probability score and risk level - Analytics → Static chart data derived from actual validation metrics of the trained model
The ML model is trained on a structured accident telemetry dataset with the following schema:
Every row is one live traffic incident fetched from the TomTom Traffic API across 200 + global seed locations. Geometry (Point / LineString) is reduced to a single centroid coordinate via geometry_to_point().
| Column | Type | Description |
|---|---|---|
lat |
FLOAT |
Incident centroid latitude |
lng |
FLOAT |
Incident centroid longitude |
severity |
INT (0–4) |
magnitudeOfDelay from TomTom (0 = unknown / no delay) |
startTime |
DATETIME str |
Incident start timestamp (ISO-8601) |
cell_lat |
FLOAT |
Snapped grid-cell latitude (GRID_SIZE resolution) |
cell_lng |
FLOAT |
Snapped grid-cell longitude |
hour |
INT (0–23) |
Hour extracted from startTime |
night |
BINARY (0/1) |
1 if hour ≥ 20 or hour ≤ 6, else 0 |
Incidents are grouped by (cell_lat, cell_lng) to produce one row per spatial grid cell, giving the model stable, spatially-averaged features.
| Column | Type | Description |
|---|---|---|
cell_lat |
FLOAT |
Grid-cell centre latitude |
cell_lng |
FLOAT |
Grid-cell centre longitude |
incident_count |
INT |
Total incidents in cell |
avg_severity |
FLOAT |
Mean magnitudeOfDelay across incidents |
max_severity |
FLOAT |
Maximum magnitudeOfDelay in cell |
night_ratio |
FLOAT |
Fraction of incidents occurring at night |
hotspot |
INT |
Label — 1 if count ≥ Q75 and avg_severity ≥ 2 |
| Stage | Detail |
|---|---|
| Input shape | (58,347, 8) — raw incident records before aggregation |
| Feature matrix | [incident_count, avg_severity, max_severity, night_ratio] (4 features) |
| Label | hotspot (binary — derived from 75th-percentile threshold + severity gate) |
| Algorithm | RandomForestClassifier — 200 trees, max_depth 10, min_samples_leaf 5 |
| Saved artefacts | hotspot_model.pkl, cell_df.pkl, grid_size.pkl |
| Spatial inference | For unseen coords → 5-nearest-cell distance-weighted feature interpolation |
| Class | Samples | Percentage |
|---|---|---|
| Safe (0) | 17,945 | 61.6% |
| Risky (1) | 11,168 | 38.4% |
| Total | 29,113 | 100% |
POST /predict
// Request
{ "lat": 31.3260, "lng": 75.5762 }
// Response
{ "probability": 0.82, "risk": "HIGH" }POST /scan
// Request
{ "lat": 31.3260, "lng": 75.5762 }
// Response
[{ "lat": 31.326, "lng": 75.576, "risk": 1 }, ...]POST /traffic
// Request
{ "bbox": "75.55,31.31,75.60,31.34" }
// Response
[{ "geometry": {...}, "properties": { "magnitudeOfDelay": 3, "iconCategory": 1, ... } }]| Metric | Score |
|---|---|
| Overall Accuracy | 97.0% |
| Risk Sensitivity (Recall) | 94.8% |
| Safe Specificity | 98.1% |
| Macro F1-Score | 97.0% |
| Training Set Size | 58,347 records |
| Validation Set Size | 29,113 samples |
| Hazard Class | Precision | Recall | F1-Score |
|---|---|---|---|
| LOW | 0.90 | 0.52 | 0.66 |
| MEDIUM | 0.90 | 0.99 | 0.94 |
| HIGH | 0.94 | 0.48 | 0.63 |
| Predicted Safe | Predicted Risky | |
|---|---|---|
| True Safe | 17,605 ✅ | 340 ❌ |
| True Risky | 577 ❌ | 10,536 ✅ |
SafeRoute AI successfully demonstrates that historical accident telemetry data alone is sufficient to build a high-accuracy spatial risk model when combined with proper geospatial feature engineering. Key takeaways:
- The model achieves 97% overall accuracy — well above the baseline (61.6% from majority class)
- 94.8% recall on risky zones ensures that dangerous locations are flagged with very few misses — critical for a safety-critical application
- 98.1% specificity means safe zones are rarely false-alarmed, preventing alert fatigue
- The full-stack integration from ML model → FastAPI → React frontend demonstrates a production-viable architecture for real-world deployment
- Real-time traffic overlay and GPS-based scanning provide immediate, actionable utility beyond just a research prototype
The platform proves that proactive safety intelligence is achievable at scale, and that making this intelligence accessible through a polished consumer interface is equally important as the underlying model performance.
SafeRoute AI is designed as an extensible platform with significant potential for enhancement:
- Weather API Integration — Incorporate live weather data (rain, fog, ice) as dynamic risk multipliers
- Time-Aware Predictions — Factor current time and day-of-week into real-time risk scoring
- Route Safety Scoring — Evaluate the aggregate risk of an entire proposed route, not just a single point
- Push Notifications — Alert users when they approach a detected hotspot during navigation
- Mobile Application (React Native) — Native iOS/Android app with background hotspot monitoring
- City-Level Heatmaps — Aggregated density maps for urban planners and traffic authorities
- Fleet Management API — B2B SDK for logistics companies to route fleets through safest paths
- Multimodal Data Fusion — Integrate CCTV analytics, sensor networks, and V2X (Vehicle-to-Everything) data
- Federated Learning — Enable privacy-preserving model updates from anonymized on-device incident data
- Reinforcement Learning for Dynamic Routing — RL agent that continuously learns and adapts routing recommendations based on real-world outcomes
- Emergency Services Integration — Pre-position ambulances, fire engines, and police units based on predicted hotspot activation probability
- Government Dashboard — Policy-maker interface for data-driven road infrastructure investment decisions
- Global Deployment — Multi-country model variants trained on regional datasets with localization support
SafeRoute AI — Towards Zero Accidents
Built with ❤️ using React · TypeScript · FastAPI · Machine Learning