This repository contains the full data pipeline, exploratory analysis, machine learning models, and forecasting code for study examining the drivers of carbon intensity of energy across 46 Sub-Saharan African (SSA) nations from 2000 to 2023, with projections to 2035.
# Machine Learning-Based Forecasting of Energy Carbon Intensity in Sub-Saharan Africa
> **The Role of Energy Composition in Decarbonization Trajectories**
---
## Overview
This repository contains the full data pipeline, exploratory analysis, machine learning models, and forecasting code for study examining the drivers of carbon intensity of energy across 46 Sub-Saharan African (SSA) nations from 2000 to 2023, with projections to 2035.
Carbon intensity of energy, measured in grams of CO₂ per kilowatt-hour (gCO₂/kWh) is a critical metric for evaluating clean energy transitions. Unlike total emissions studies, this work places **energy mix composition** at the center of the analysis, offering a mechanistically grounded framework for understanding and forecasting decarbonization trajectories in a region that remains underrepresented in the ML literature.
---
## Key Findings
- **XGBoost outperformed all models** with a test R² of 0.8946 and RMSE of 46.77 gCO₂/kWh
- **Linear Regression failed** (R² = -0.003), confirming that carbon intensity dynamics are non-linear and cannot be captured by linear models
- **Fossil fuel consumption volume, population size, and per capita energy use** are the dominant predictors of carbon intensity
- **Most SSA countries are projected to see worsening or stagnant carbon intensity by 2035** under current trends, with Djibouti (731 gCO₂/kWh) and Eswatini (572 gCO₂/kWh) projected as the highest-intensity nations
- **Mozambique, Comoros, and DRC** are projected to have the lowest carbon intensity by 2035, driven by hydropower dominance
---
## Repository Structure
```
Carbon Intensity Project/
│
├── Data/
│ ├── co2-per-unit-energy.csv # Target variable - Our World in Data
│ ├── elec-fossil-nuclear-renewables.csv # Electricity mix - Our World in Data
│ ├── gdp-per-capita-worldbank.csv # GDP per capita - World Bank via OWID
│ ├── per-capita-energy-use.csv # Energy consumption - Our World in Data
│ ├─ …