Logo Lanfrica

Munyuki/african_banking_crises_prediction

Domaine:

socioeconomic

Type de record:

model
Créateur:
Mun
Hôte:
ML model to predict banking crises in African economies using macroeconomic indicators (1860-2014). # Predicting Banking Crises in African Economies **Author:** Nicodimus Munyuki **Tools:** Python, pandas, scikit-learn, matplotlib, seaborn --- ## Overview Banking crises can devastate economies — wiping out savings, collapsing businesses, and triggering recessions. This project builds a machine learning model to **predict banking crises before they happen** using macroeconomic indicators across 13 African countries from 1860 to 2014. --- ## Dataset - **Source:** Historical macroeconomic data from 13 African countries - **Countries:** Algeria, Angola, Central African Republic, Ivory Coast, Egypt, Kenya, Mauritius, Morocco, Nigeria, South Africa, Tunisia, Zambia, Zimbabwe - **Time period:** 1860 – 2014 - **Size:** 1,059 observations, 14 features - **Target variable:** `banking_crisis` (crisis vs. no_crisis) ### Class Distribution (Imbalanced) | Class | Percentage | |-------|------------| | No Crisis | 91.1% | | Crisis | 8.9% | This imbalance reflects real-world rarity of banking crises but makes prediction challenging. --- ## Approach ### 1. Data Preprocessing - One-hot encoding for categorical variables - Feature scaling using `StandardScaler` - Train-test split (80/20) with stratification ### 2. Handling Class Imbalance - **SMOTE** (Synthetic Minority Over-sampling) to balance training data - **Class weights** for Random Forest ### 3. Models Tested | Model | Accuracy | ROC-AUC | |-------|----------|---------| | Logistic Regression | 93% | 0.968 | | K-Nearest Neighbors | 96% | 0.938 | | Random Forest | **98%** | **0.988** | ### 4. Hyperparameter Tuning Used GridSearchCV to find optimal parameters for all three models. --- ## Key Results - **Best model:** Random Forest with **98% accuracy** and **0.988 ROC-AUC** - **Precision for crisis class:** 94% (few false alarms) - **Recall for crisis class:** 79% (catches 15 out of 19 actual crises) ### Confusion Matrix (Random Forest) ``` [[192 1] ← No crisis predicted correctly [ 4 15]] ← Crises pre …