How rishavsvault/road-accident-severity-and-hotspot-analysis works
This is a synthetic-data prototype for explainable road-accident severity and hotspot analysis for Kolkata/KMDA. The principal workflow is pipeline execution: generate or load crash, road-network, and weather inputs; spatially align crashes; build features; rank hotspots; train and evaluate severity models; then explain risks and recommend engineering interventions. A Streamlit dashboard presents hotspot exploration, segment deep dives, counterfactual simulation, and policy briefs; the repository also includes an API. Pipeline-stage links are supported by the README and the run_pipeline.py reference index. Some internal calls and dashboard data wiring were not sampled, so those links are omitted.
Main entry points: run_pipeline.py Pipeline runner · app.py Streamlit dashboard · build_features.py Feature matrix · intervention_engine.py Intervention advice
Components 25
Input and alignment
- Pipeline runner
run_pipeline.py - Synthetic crashes
src/data/mock_data_generator.py - Crash cleaning
src/data/crash_cleaner.py - Road network
src/data/osm_loader.py - Weather loading
src/data/weather_loader.py - Spatial snapping
src/data/spatial_snapper.py
Risk analysis
- Feature matrix
src/features/build_features.py - Road features
src/features/road_features.py - Temporal features
src/features/temporal_features.py - Weather features
src/features/weather_features.py - Network KDE
src/hotspots/network_kde.py - Spatial statistics
src/hotspots/spatial_stats.py - Segment ranking
src/hotspots/segment_ranker.py
Model and decisions
- Severity training
src/models/xgboost_trainer.py - Spatial validation
src/models/spatial_cv.py - Model evaluation
src/models/evaluate.py - SHAP explanations
src/explainability/shap_explainer.py - Intervention advice
src/explainability/intervention_engine.py
User interfaces
- Streamlit dashboard
dashboard/app.py - Hotspot explorer
dashboard/pages/1_Hotspot_Explorer.py - Segment deep dive
dashboard/pages/2_Segment_Deep_Dive.py - What-if simulator
dashboard/pages/3_What_If_Simulator.py - KMDA policy brief
dashboard/pages/4_KMDA_Policy_Brief.py - Analysis API
src/api/main.py
Other components
- KMDA analyst
Connections 29
- KMDA analyst → Pipeline runner: runs pipeline
- Pipeline runner → Synthetic crashes: generates inputs
run_pipeline.py - Pipeline runner → Crash cleaning: cleans crashes
run_pipeline.py - Pipeline runner → Road network: loads roads
run_pipeline.py - Pipeline runner → Weather loading: loads weather
run_pipeline.py - Pipeline runner → Spatial snapping: aligns crashes
run_pipeline.py - Pipeline runner → Feature matrix: builds features
run_pipeline.py - Feature matrix → Road features: uses
src/features/build_features.py - Feature matrix → Temporal features: uses
src/features/build_features.py - Feature matrix → Weather features: uses
src/features/build_features.py - Pipeline runner → Network KDE: computes density
run_pipeline.py - Pipeline runner → Spatial statistics: tests clusters
run_pipeline.py - Pipeline runner → Segment ranking: ranks segments
run_pipeline.py - Pipeline runner → Severity training: trains severity model
run_pipeline.py - Severity training → Spatial validation: uses folds
src/models/xgboost_trainer.py - Severity training → Model evaluation: evaluates predictions
src/models/xgboost_trainer.py - Pipeline runner → Model evaluation: exports metrics
run_pipeline.py - Pipeline runner → SHAP explanations: explains predictions
run_pipeline.py - Pipeline runner → Intervention advice: recommends fixes
run_pipeline.py - KMDA analyst → Streamlit dashboard: opens dashboard
- Streamlit dashboard → Segment deep dive: presents page
- Streamlit dashboard → Hotspot explorer: presents page
- Streamlit dashboard → What-if simulator: presents page
- Streamlit dashboard → KMDA policy brief: presents page
- Segment deep dive → SHAP explanations: uses explanations
dashboard/pages/2_Segment_Deep_Dive.py - Segment deep dive → Intervention advice: uses recommendations
dashboard/pages/2_Segment_Deep_Dive.py - What-if simulator → Intervention advice: uses recommendations
dashboard/pages/3_What_If_Simulator.py - Analysis API → Intervention advice: uses recommendations
src/api/main.py - Analysis API → Spatial statistics: uses statistics
src/api/main.py