Machine learning and reinforcement learning system for analysing and predicting South African road accident severity using ensemble models and Q-learning.
#South Africa Road Accident Analysis & Intelligent Decision System (2017)
Project Overview
This project is a complete data science and machine learning system that analyzes road accident data in South Africa (2017). It includes data preprocessing, exploratory data analysis (EDA), ensemble machine learning models and a reinforcement learning (RL) system for accident prevention recommendations.
The goal is to predict accident severity and recommend traffic interventions using AI techniques.
## Dataset Source
The dataset used in this project is publicly available and contains road accident records from South Africa (2017).
Source:
kaggle.com
## Dataset Description
The dataset contains 120 records and 16 features, including:
- Accident severity
- Location type
- Province and city
- Vehicle type
- Speed and speed zone
- Number of vehicles and casualties
- Date and time of accident
- Road conditions (Occasions)
## Technologies Used
- Python
- Pandas
- NumPy
- Matplotlib
- Seaborn
- Scikit-learn
- XGBoost
- CatBoost
## Data Preprocessing
The dataset was cleaned and prepared using the following steps:
- Artificial missing values (8%) introduced for simulation
- Missing values handled using:
- Mode imputation (categorical variables)
- Median imputation (numerical variables)
- Date and Time converted into usable formats
- Outliers detected using IQR method and capped (Winsorisation)
- Feature engineering:
- Hour extracted from Time
- Month extracted from Date
- Label encoding applied to categorical variables
- Target variable encoded:
- 0 = Bumper Accident
- 1 = Headon Accident
- 2 = Fatal Accident
---
## Exploratory Data Analysis (EDA)
EDA was performed to understand:
- Accident severity distribution
- High-risk provinces
- Vehicle types involved
- Casualty distribution patterns
- Time and seasonal trends
## Machine Learning Models
Three ensemble models were used:
- Random Forest Classifier
- XGBoost Classifier
- CatBoost Classifier
### E …