# Geospatial Flood-Risk Modelling using Climate Data and Hidden Markov Models in Rwanda
**Capstone project — BSc Software Engineering, African Leadership University**
Author: Kellen Murerwa · Supervisor: Emmanuel Adjei
A reproducible machine-learning + Hidden Markov Model framework that estimates
**daily Low / Moderate / High flood-pressure states** for the **Nyabugogo–Nyabarongo
corridor in Kigali, Rwanda**, by fusing real rainfall, terrain, hydrology and
urban-exposure data, and validates the result against the official flood-risk
polygons.
---
## What it does
1. Builds a **250 m grid** over the study corridor (729 cells).
2. Pulls **real, free, keyless data** per cell-day, 2018–2024:
- **Rainfall** (1/3/7/14-day totals) — Open-Meteo **ERA5** archive
- **Elevation + slope** — Open-Meteo **SRTM** elevation
- **Distance-to-river, road & building density** — **OpenStreetMap** (Overpass)
- **Official flood-risk polygons** — Rwanda GeoPortal / **geodata.rw** (Ministry of Environment)
3. Derives **flood-pressure labels** (rainfall trigger × terrain susceptibility, with
an unobserved drainage latent + noise so the task is not trivially circular).
4. Trains and benchmarks: rainfall-threshold & static-polygon baselines, Logistic
Regression, Decision Tree, **Random Forest**, **XGBoost** (+ SHAP), and an
**HMM** temporal layer — evaluated on a **temporal train/validation/test split**
(train 2018–2022, validation 2023, test 2024).
5. Validates spatially against the official polygons and ships a **Streamlit dashboard**.
## Headline results (2024 test hold-out)
| Model | Macro-F1 | High-recall |
|---|---|---|
| XGBoost (deployed) | **0.813** | 0.843 |
| Random Forest | 0.813 | 0.849 |
| Rainfall-threshold baseline | 0.626 | — |
| Static-polygon baseline | 0.324 | — |
Train/validation/test macro-F1 are near-identical for both ensembles (XGBoost
0.804 / 0.805 / 0.813; RF 0.813 / 0.806 / 0.813) — no over-fitting. Spatial
validation vs official polygons: containment 0.30, * …