This repository contains the complete methodology pipeline and implementation for the project "Teenage Pregnancy in Ghana Using Explainable Artificial Intelligence" — an end-to-end machine learning and causal inference study designed to predict, explain, and understand the determinants of teenage pregnancy using demographic and health data.
# Teenage Pregnancy in Ghana – Explainable AI Methodology Pipeline
# Overview
This repository provides the complete **methodology pipeline** for predicting and understanding **teenage pregnancy in Ghana** using advanced **machine learning, explainable AI (XAI), causal inference, and fairness auditing techniques**.
The project demonstrates how predictive models can go beyond classification tasks by integrating interpretability, counterfactual reasoning, causal insights, and bias mitigation — all aimed at informing **evidence-based public health interventions**.
---
## Pipeline Structure
The codebase is organised into sequential stages, each represented as a notebook or Python module. Together, these stages form a complete analytical workflow:
### 1. Data Collection and Preprocessing
- Load secondary demographic and health survey data (e.g., GDHS).
- Handle missing values using **MICE (Multiple Imputation by Chained Equations)**.
- Encode categorical features using **one-hot** or **ordinal encoding**.
### 2. Data Cleaning and Encoding
- Normalize and transform features.
- Ensure consistent data types.
- Address outliers and scale numeric features where necessary.
### 3. Predictive Base Modeling Framework
- Train multiple models:
- `RandomForestClassifier`
- `XGBoostClassifier`
- `LogisticRegression`
- `SVC`
- Handle class imbalance using **SMOTE**.
- Split data into **70% train / 30% test** with stratification.
### 4. Threshold Tuning
- Explore alternative probability thresholds (`0.3`, `0.4`, `0.45`, etc.)
- Select the optimal threshold based on **recall** and **F1-score** for the minority class.
### 5. Evaluation Metrics
- Accuracy
- Precision
- Recall (Sensitivity)
- F1-score
- ROC-AUC Curve
- Precision–Recall Curve
---
## Explainability and Counterfactual Analysis
### 6. Global Explainability (SHAP)
- Compute SHAP values with `TreeExplainer`.
- Visualise **feature importance** with bar plots and beeswarm plots.
- Identify the most influential predict …