AI Traffic Accident Severity Prediction is an intelligent system designed to predict the severity level of traffic accidents in real-time based on multiple environmental, vehicular, and driver-related factors. The system leverages machine learning algorithms to assess accident risk and provide actionable safety recommendations.
Develop a production-ready ML-powered application that:
- Predicts accident severity (Minor, Serious, Fatal)
- Analyzes distance-based hotspot risk zones
- Provides real-time travel recommendations
- Integrates spatial analysis for accident-prone locations across Asia
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β AI Traffic Accident Prediction β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Frontend (React.js) Backend (Flask) β
β ββ PredictionForm ββ ML Model (joblib) β
β ββ ResultPage ββ Feature Encoding β
β ββ ResultCard ββ Hotspot Analysis β
β ββ Risk Scoring (1-5 scale) β
β β
β Database: CSV-based Hotspot Data (Asia) β
β Model: RandomForest / XGBoost Classification β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Real-world traffic accident records from India
- ~10,000 accident records with 25+ attributes
- Geospatial data for 25+ accident hotspots across Asia
| Category | Features |
|---|---|
| Temporal | Hour, Day of Week, Rush Hour Flag, Weekend Flag |
| Environmental | Weather, Road Type, Road Condition |
| Vehicle | Vehicle Type, Vehicle Condition |
| Driver | Age, License Status, Experience (years), Speed Habit |
| Safety | Lighting Conditions, Traffic Control, Alcohol Involvement |
- Cleaning: Removed duplicates, handled missing values
- Feature Engineering: Created risk scores (1-5 scale) for subjective features
- Encoding: Categorical variables mapped to numerical codes
- Validation: Removed outcome variables (Speed Limit, Casualties, Fatalities) to prevent data leakage
Output: Severity Classification
- 0 = Minor β Low injury accidents
- 1 = Serious β Moderate to serious injuries
- 2 = Fatal β Fatal accidents
- 5: < 6 months β Extreme Risk
- 4: 6-12 months β Very High Risk
- 3: 1-2 years β High Risk
- 2: 2-5 years β Medium Risk
- 1: 5+ years β Low Risk
- 5: Storm, Tornado, Hurricane β Extreme Risk
- 4: Heavy Rain, Snow, Hail β Very High Risk
- 3: Rain, Fog, Mist β High Risk
- 2: Cloudy, Drizzle β Medium Risk
- 1: Clear, Sunny β Low Risk
- 5: < 20 years β Very High Risk
- 4: 20-25 or > 70 β High Risk
- 3: 60-70 β Medium Risk
- 1: 25-60 β Low Risk
- 1: < 60 km/h β Safe/Moderate
- 2: 60-80 km/h β Slightly Risky
- 3: 80-100 km/h β Risky
- 4: > 100 km/h β Very Risky
- 5: Poor/Bad/Terrible β Extreme Risk
- 3: Average/Medium/OK β Medium Risk
- 1: Good/Excellent β Low Risk
| Model | Type | Advantages |
|---|---|---|
| RandomForest | Ensemble | Fast inference, handles non-linear patterns |
| XGBoost | Gradient Boosting | Superior performance on imbalanced data |
| Logistic Regression | Linear | Baseline for comparison |
Selected Model: RandomForest/XGBoost (Best performance on validation set)
- GridSearchCV for parameter optimization
- Cross-validation (5-fold) for robust evaluation
- Class weight balancing for imbalanced dataset
- Framework: Flask (Python)
- ML Libraries: scikit-learn, XGBoost, joblib
- Data Processing: pandas, NumPy
- Geospatial: DBSCAN Clustering,Distance-based hotspot analysis
- API: RESTful with CORS support
- Framework: React.js
- Styling: Bootstrap 5 + Custom CSS
- State Management: React Hooks (useState)
- Routing: React Router v6
- HTTP Client: Axios
- Backend: Flask development server (Production-ready with gunicorn)
- Frontend: Node.js + npm
- Database: CSV-based (Scalable to PostgreSQL)
- Real-time accident risk classification
- Probability scoring (0-100%)
- Risk level mapping (Low/Medium/High)
- Proximity-based risk assessment
- 5-zone classification system:
- 0-10 km: π΄π΄π΄ High Critical Red Zone
- 10-50 km: π΄π΄ Critical Zone
- 50-150 km: π‘ Medium Risk Zone
- 150-300 km: π’ Low Risk Zone
- 300+ km: β No Risk
- ML prediction + Hotspot risk integration
- Travel permission system (ALLOWED/NOT ALLOWED)
- Real-time safety alerts
- Geospatial visualization of accident zones
- Dynamic map generation with Folium
- Risk zone color-coding
POST /predict
Input: Accident parameters (time, location, weather, driver info, etc.)
Output: Severity prediction + probability + hotspot analysis
POST /hotspot_analysis
Input: Latitude, Longitude, Radius (km)
Output: Distance-based risk classification + nearby hotspots
POST /generate_hotspot_map
Output: Interactive HTML map with accident zones
- Precision: Class-wise precision for each severity level
- Recall: Sensitivity for identifying high-risk scenarios
- F1-Score: Balanced performance metric
- ROC-AUC: Classification performance across thresholds
- Confusion Matrix: True/False positives and negatives
- Safe extraction from predict_proba() output
- NaN detection and fallback to 0.0
- Validation of array shape before indexing
- Probability formatter handles undefined/null values
- Graceful fallback to "N/A" for invalid data
- Type conversion validation
ai-traffic-prediction/
βββ backend/
β βββ models/
β β βββ best_model.joblib
β β βββ severity_mapping.joblib
β β βββ feature_names.joblib
β βββ data/
β β βββ processed/
β β βββ asia_accident_hotspots_enhanced.csv
β βββ prediction_api.py
β βββ spatial_analysis.py
βββ frontend/
β βββ src/
β β βββ components/
β β β βββ PredictionForm.js
β β β βββ ResultPage.js
β β β βββ ResultCard.js
β β βββ pages/
β βββ package.json
βββ README.md
cd backend
python prediction_api.py
# Server runs on http://127.0.0.1:5000cd frontend
npm install
npm start
# App runs on http://localhost:3000- Fill in accident details in the form
- Submit for real-time prediction
- View severity level + probability + recommendations
- Analyze hotspot risks on interactive map
{
"datetime": "2025-11-10T13:00",
"State Name": "Maharashtra",
"City Name": "Mumbai",
"Driver Age": 35,
"Driver License Status": "Valid",
"driver_experience": "8 years",
"driver_speed_habit": 45,
"vehicle_condition": "good",
"Weather Conditions": "Clear",
"Road Type": "Urban Road",
"Road Condition": "Dry",
"Lighting Conditions": "Bright",
"Traffic Control Presence": "Lights",
"Vehicle Type Involved": "Car",
"alcohol_flag": 0
}Output:
{
"prediction_summary": {
"severity": "Minor",
"severity_code": 0,
"ml_probability": 78.45,
"ml_risk_level": "LOW"
},
"combined_risk": {
"travel_safe": "YES",
"combined_recommendation": "β
Location safe - travel allowed"
}
}- Multi-language support
- Mobile app development (Flutter/React Native)
- Real-time traffic data integration
- Police/Hospital location proximity analysis
- Historical accident trend analysis
- User feedback loop for model retraining
- Cloud deployment (AWS/GCP/Azure)
- Advanced geospatial clustering
This project is open-source and available under the MIT License.
Project Leader: Biswajit Sow
Team: AI/ML Development Team
**Institution:**UEM