# Spatiotemporal SHAP Analysis for Agricultural Drought Prediction
## A Multi-Source Machine Learning Framework in Semi-Arid Tunisia
---
## 📌 Overview
This repository contains the full reproducible codebase for the research paper:
> **Spatiotemporal SHAP Analysis for Agricultural Drought Prediction: A Multi-Source Machine Learning Framework in Semi-Arid Tunisia** > *Frontiers in Artificial Intelligence — Section: AI in Food, Agriculture and Water* >
> **Authors:** Argoubi Majdi, Khaled Mili
> **Paper DOI:** [Pending Publication]
> **Dataset DOI:** 10.5281/zenodo.18733246
### Study Area
Five semi-arid governorates of central Tunisia: **Kairouan, Kasserine, Sidi Bou Zid, Gafsa, and Siliana**.
### Objectives
1. Predict agricultural drought (SSMI) using multi-source environmental and socioeconomic data.
2. Evaluate 6 ML/DL models (XGBoost, LightGBM, CatBoost, RF, BPNN, LSTM) with a focus on extreme event generalization (2021–2022).
3. Use **Tree SHAP** to explain global drivers and spatiotemporal drought dynamics.
---
## Key Results
| Model | Test R² | Test SDI | Val R² (2021–22) | Val SDI |
|-------|---------|----------|------------------|---------|
| **BPNN** | **0.860** | **0.626** | 0.655 | 0.421 |
| XGBoost | 0.817 | 0.572 | **0.696** | **0.448** |
| LightGBM | 0.807 | 0.561 | — | — |
| LSTM | 0.790 | 0.541 | 0.667 | — |
| CatBoost | 0.756 | — | — | — |
| RF | 0.681 | — | — | — |
**Top SHAP predictors (XGBoost):**
- MERRA-2 Surface SM: 26.0%
- Temperature (T2M): 14.2%
- Sand content: 10.0%
- Precipitation: 8.6%
---
## Repository Structure
```
drought-prediction-tunisia/
├── data/ # Raw and processed data (see data/README.md)
├── notebooks/ # Jupyter notebooks (exploration → figures)
├── src/ # Python source modules
│ ├── data/ # Download and preprocessing scripts
│ ├── models/ # Training, evaluation, metrics
│ ├── shap/ # SHAP global, dependence, spatiotemporal
│ └── figures …