An Unsupervised Machine Learning Approach to Rainfall Pattern Clustering.
Climatological Regionalization of Zambia
An Unsupervised Machine Learning Approach to Rainfall Pattern Clustering
Project Overview
This project applies K-Means clustering to 20 years (2003–2023) of district-level daily rainfall data
from Zambia to objectively classify districts into homogeneous rainfall zones. The pipeline replaces
the static Agro-Ecological Zone (AEZ) framework with a data-driven, reproducible classification that
captures onset dates, cessation dates, dry spell dynamics, and seasonal totals.
Repository Structure
zambia_rainfall_clustering/
│
├── data/
│ ├── raw/ # Original ZMD/NASA POWER data (do not modify)
│ ├── processed/ # Cleaned daily data, engineered features, standardized features
│ ├── reference/ # District shapefiles, AEZ mappings, station metadata
│ └── outputs/ # Cluster assignments, maps, reports, validation metrics
│
├── src/
│ ├── data_ingest.py # Module 1: Data acquisition with ZMD/NASA POWER merge-switch logic
│ ├── preprocess.py # Module 2: Missing value handling, outlier detection, standardization
│ ├── feature_engineer.py # Module 3: 13-feature extraction from daily time-series
│ ├── cluster.py # Module 4: PCA + K-Means with Elbow/Silhouette optimal-K selection
│ ├── validate.py # Module 5: Internal metrics + AEZ external comparison
│ ├── visualize.py # Module 6: GIS maps, cluster profiles, risk zones
│ └── pipeline.py # Orchestrator: runs all modules end-to-end
│
├── tests/
│ ├── test_ingest.py
│ ├── test_preprocess.py
│ ├── test_feature_engineer.py
│ ├── test_cluster.py
│ └── test_validate.py
│
├── notebooks/
│ └── exploratory_analysis.ipynb
│
├── docs/
│ └── methodology_notes.md
│
├── dashboard.py # Streamlit interactive dashboard (Iteration 4 deliverable)
├── requirements.txt # Exact pinned versions for pip
├── environment.yml # Conda environment s …