Why did Tunisia's grid collapse under a 47°C heatwave? A full data science pipeline analyzing 22,000 hours of synthetic grid data to forecast demand, predict blackouts, and model intervention ROI.
# ⚡ Tunisia Electricity Crisis: Data-Driven Analysis & Solutions
> A complete data science pipeline analyzing Tunisia's July 2026 electricity crisis — from demand forecasting and outage prediction to smart load shedding optimization and investment portfolio modeling.
---
## The Problem
In July 2026, Tunisia faced its worst electricity crisis in decades. A severe heatwave pushed temperatures to **47°C in Tunis** and **49°C inland**, driving electricity demand to a record **~6,000 MW** against an installed capacity of only **~4,630 MW**. The resulting **1,370 MW supply gap** forced STEG (Tunisia's national utility) to implement rolling blackouts across neighborhoods, causing an estimated **$4.2 billion in economic losses**.
Cross-border imports from Algeria and Libya were unavailable — both countries faced their own demand surges. With **95% of generation gas-dependent**, declining domestic gas production, and STEG burdened by **7.3 billion TND in debt**, the crisis exposed deep structural vulnerabilities.
---
## What This Project Does
This repository contains a fully reproducible data science pipeline built on **synthetic but realistic hourly data** spanning January 2024 to July 2026. It demonstrates how data-driven approaches can inform crisis response and long-term planning.
### Models Built
| Model | Purpose | Key Output |
|-------|---------|------------|
| **Demand Forecaster** | Predict next-hour demand from weather + calendar features | R² = 0.95, MAE ≈ 45 MW |
| **Outage Predictor** | Classify whether an outage will occur | Identifies temperature > 35°C and supply margin as top predictors |
| **Smart Load Shedding Optimizer** | Allocate power cuts to minimize economic loss | **40–60% cost reduction** vs uniform blackouts |
| **Solution Impact Simulator** | Model 7 interventions (solar, wind, storage, demand response, etc.) | ROI ranking, payback periods, outage prevention |
| **Portfolio Optimizer** | Find best solution combination within any bud …