This project analyses crime trends across South Africa and builds a machine learning model to predict crime incidents and assess risk levels across provinces and police stations.
# South Africa Crime Analytics and Risk Prediction System
## 📌 Project Overview
This project analyses crime trends across South Africa and builds machine learning models to predict crime incidents and assess risk levels across provinces and police stations.
The goal is to provide data-driven insights that support:
- Public safety planning
- Resource allocation
- Crime prevention strategies
---
## 🚨 Problem Statement
Crime rates vary significantly across regions, but decision-making is often reactive rather than predictive.
This project aims to:
- Identify high-risk provinces and crime categories
- Analyse historical crime patterns
- Predict future crime incidents
- Assign risk levels (Low, Medium, High)
This enables proactive intervention and smarter policing strategies.
---
## 📊 Dataset
- South Africa Crime Statistics dataset
- Province population dataset
### Key Features:
- Province
- Police Station
- Crime Category
- Yearly crime data (2005–2016)
Data was cleaned, transformed, and structured for analysis and machine learning.
---
## 🔍 Exploratory Data Analysis
Key insights:
- Crime trends fluctuate over time with noticeable peaks
- Certain provinces consistently record higher crime volumes
- Crime per capita reveals different risk rankings compared to total crime
- Property and violent crimes dominate the top categories
---
## 📈 Visualisations
### Crime Trends Over Time
### Crime by Province
### Crime per 100,000 People
### Top Crime Categories
---
## 🤖 Machine Learning Models
Two models were developed and compared:
### 1. Random Forest Regressor (Final Model)
- MAE: **12.30**
- R² Score: **0.9590**
### 2. XGBoost Regressor
- MAE: 53.71
- R² Score: 0.6407
### ✅ Model Selection
Random Forest was selected as the final model due to:
- Lower prediction error (MAE)
- Higher explanatory power (R²)
- Better generalisation across categories
---
## ⚠️ Risk Scoring System
Crime levels were categorised into:
- Low Risk
- Medium Risk
- Hig …