Skip to content

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Risk-Aware Navigation System

A routing application tailored for Kozhikode, Kerala that helps users find the safest path to their destination by predicting accident risks along the route. It uses an XGBoost model trained on historical data, road features, and real-time conditions (like weather and time of day).

What it does

Standard navigation apps optimize for the shortest or fastest route. This project optimizes for safety. By analyzing factors like road curvature, junction frequency, speed limits, and current weather, it overlays a risk probability score on road segments and routes you around potential accident hotspots.

Tech Stack

  • Backend: Python, Flask
  • ML & Data: XGBoost, Scikit-Learn, Pandas
  • Routing & Maps: NetworkX, OSMnx, Shapely
  • Frontend: HTML/JS, Progressive Web App (PWA) support

Core Components

  • app_flask.py: The main Flask server endpoints and UI rendering.
  • risk_aware_navigation.py: The routing engine. Finds shortest paths and evaluates risk scores using the ML model.
  • train_accident_model.py: Script to train the XGBoost model on the kozhikode_accident_history.csv dataset.
  • csv_graph_loader.py: A custom fast-loader for OSM data, bypassing heavy spatial databases.
  • start_ngrok.py: Utility to quickly expose the local server using ngrok for mobile testing.

Getting Started

1. Installation

Windows users: Just double-click setup.bat or run it in your terminal. It will create a virtual environment (.venv) and install all dependencies automatically.

Linux / macOS users:

chmod +x setup.sh
./setup.sh

Manual installation:

python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -r requirements.txt

2. Running the App

Start the main Flask server:

python app_flask.py

It will run locally at http://localhost:5000.

(Optional) Expose it to the internet to test the PWA on your phone:

python start_ngrok.py

3. Usage

  1. Open the web interface.
  2. Enter an Origin (or leave it blank to use your current location) and a Destination.
  3. Click Analyze Route.
  4. The system calculates the path, highlights the top 5 most dangerous points, and outputs a Google Maps navigation link that routes you safely by setting risk zones as waypoints.

Retraining the Model

If you want to tweak features or add new data, run the training pipeline:

python train_accident_model.py

This searches for the best hyperparameters, plots metrics, and exports a new accident_model.pkl.

About

An Accident prediction system

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages