Advanced Machine Learning for Geospatial Sciences Next-day wildfire danger prediction across Greece and the Eastern Mediterranean, comparing Transformer, and Vision Transformer architectures.
This builds on Kondylatos et al. (2022), "Wildfire Danger Prediction and Understanding With Deep Learning" — we matched their feature set, lag window, and sampling strategy for comparability, then extended their work with a spatial generalisation test and a three-architecture comparison.
Assignment_final/
├── Wildfire_Presentation.pptx ← our final presentation slides
└── wildfire_pkg/ ← the full code + results package
├── dataset.py ← builds train/val/test splits from the raw .nc file
├── main.py ← trains a model, evaluates it, runs MC Dropout + SHAP
├── visualize.py ← generates all the charts (ROC, prediction maps, etc.)
├── models/
│ ├── transformer.py ← Transformer architecture
│ └── vit.py ← Vision Transformer architecture
├── xai/
│ ├── monte_carlo.py ← MC Dropout uncertainty estimation
│ └── shap_analysis.py ← SHAP feature importance (GradientExplainer)
├── splits/ ← helper code for loading .npy data into TensorFlow
├── input_data/ ← normalisation mean/std files (small, included)
├── data_splits/ ← extracted train/val/test .npy arrays
│ ├── temporal/ (train 2009-2018, val 2019, test 2020)
│ └── spatial/ (train east 60%, val/test west 40%)
└── results/
├── temporal/
│ ├── transformer/ ← trained model + every chart + metrics
│ └── vit/ ← trained model + every chart + metrics
├── spatial/
│ ├── transformer/
│ └── vit/
←
1. Set up the environment (we used conda — plain pip/venv had issues with file encoding on our system, so conda was more reliable):
conda create -n wildfire python=3.11 -y
conda activate wildfire
conda install -c conda-forge numpy pandas xarray netCDF4 dask matplotlib scikit-learn -y
pip install tensorflow-macos tensorflow-metal shap ipykernel2. If you already have the .npy files (they're included in
data_splits/), you can skip straight to training or just regenerate
charts from the already-trained models:
python main.py --split both --models transformer vit
python visualize.py --split both --models transformer vit3. If you need to rebuild from the raw .nc file (only if you don't
trust our extracted .npy files, or want to extend this with a different
lag window, sampling ratio, etc.):
python dataset.py path/to/dataset_greece.nc path/to/spatiotemporal_only_means.ncThis re-scans the whole dataset and rebuilds every split from scratch — it takes a while (a few minutes for the fire-pixel scan alone), since it has to read the entire ~9.8GB file day by day.
| Model | Split | AUROC | AUPRC |
|---|---|---|---|
| Transformer | Temporal | 0.9207 | 0.8005 |
| ViT | Temporal | 0.8990 | 0.7715 |
| Transformer | Spatial | 0.9084 | 0.7135 |
| ViT | Spatial | 0.8863 | 0.6526 |
Transformer outperform ViT. Transformer actually generalises best across the spatial split — it has the smallest drop in performance going from temporal to spatial, and its uncertainty estimates (from Monte Carlo Dropout) are also the most reliable of the three.