MargGanit
High-performance Python and NumPy analytics engine quantifying highway risk indices

MargGanit
High-performance Python and NumPy analytics engine quantifying highway risk indices

How It Connects
MargGanit is a scientific data analytics engine built with Python and vectorized NumPy routines. Designed to replace ad-hoc traffic safety spreadsheets, it ingests 8,000+ historical highway crash records, partitions highway corridors into discrete 10-km chainage segments, and computes a Relative Composite Risk Indicator (RCRI). The model factors in spatial accident density, mean casualty severity, and temporal concentration using hourly Shannon entropy, refined with a small-sample Bayesian reliability weighting factor.
Components
System Components
How It Works
Raw Data Ingestion
Loads 8,000+ historical accident records with timestamp, chainage km, fatalities, injuries, and road condition.
Spatial Chainage Partitioning
Maps each accident to its corresponding 10-kilometer chainage bin along national highway corridors.
Severity & Fatality Weighting
Applies weighted severity scores (fatalities weighted 5x relative to minor injuries) per segment.
Hourly Entropy Assessment
Computes Shannon entropy across the 24-hour crash distribution curve for each segment.
Composite Risk Ranking (RCRI)
Combines spatial density, severity index, and entropy with small-sample reliability corrections.
Raw Data Ingestion
Loads 8,000+ historical accident records with timestamp, chainage km, fatalities, injuries, and road condition.
Spatial Chainage Partitioning
Maps each accident to its corresponding 10-kilometer chainage bin along national highway corridors.
Severity & Fatality Weighting
Applies weighted severity scores (fatalities weighted 5x relative to minor injuries) per segment.
Hourly Entropy Assessment
Computes Shannon entropy across the 24-hour crash distribution curve for each segment.
Composite Risk Ranking (RCRI)
Combines spatial density, severity index, and entropy with small-sample reliability corrections.
Technical Breakdown
Granular architectural layers, runtime dependencies, and audited production decisions.
- Pure Python 3 with zero bloated runtime dependenciescopy
- Extensive use of vectorized NumPy operations for sub-second processing across thousands of rowscopy
Engineering Tradeoffs & Key Decisions
Why this architecture over alternativesVectorized NumPy over Heavy Dataframe Frameworks
Implemented core math directly with NumPy structured arrays instead of heavy multi-gigabyte analytical stacks.
Provides 15x faster calculation speeds and minimal memory footprint, allowing execution on edge civil engineering laptops.
Small-Sample Bayesian Weighting
Incorporated empirical Bayes adjustment on low-traffic segments with few data points.
Prevents statistical anomalies where a single fatal accident on a remote road artificially tops risk tables.