This repository contains the code to reproduce the results presented in the article Deep learning meets tree phenology modeling: PhenoFormer vs. process-based models, Garnot et al. published in Methods in Ecology and Evolution.
The present repository contains :
- the PyTorch implementation of PhenoFormer (
model/architecture) - the python scripts used to train the different variants of PhenoFormer presented in the paper (
run-phenoformer-x-x.py). - the R scripts used to evaluate the performance of process-based models on our dataset (see
/process-based-models). - the python scipts used to train the traditional machine learning baselines used in the paper (
run-traditional-ml-baselines.py) - our detailed numerical results (
results/full_results.csv)
You can retrieve our dataset from our Zenodo archive. This dataset contains two subfolders: one version of the dataset formatted for R scripts and the other one for python scripts. Please use the learning-models-data subfolder for all python scripts.
git clone [email protected]:VSainteuf/PhenoFormer.git
cd PhenoFormer
conda create --name phenoformer python==3.10
conda activate phenoformer
pip install -r requirements.txt
We recommend to create a new virtual environment with python==3.10 :
⚠️ If you run into issues , make sure that your pip version is < 24.1 by running:
pip install pip==24.0
For the deep learning scripts, we recommend using a machine with GPU to have reasonable training times. Our models are still quite small (for deep learning standards) so a small GPU of even 4 or 8GB VRAM would do.
There are four scripts to run the different configurations of PhenoFormer:
run-phenoformer-singlespecies-spring.pyto train the single-species PhenoFormer for spring phenology (variant (a) in Table 6)run-phenoformer-multispecies-spring.pyto train the multi-species variants of PhenoFormer for spring phenology (variants (b->e) in Table 6)run-phenoformer-singlespecies-autumn.pyto train the single-species variants of PhenoFormer for autumn phenology (variants (a,f) in Table 9)run-phenoformer-multispecies-autumn.pyto train the multi-species variants of PhenoFormer for autumn phenology (variants (b,d) in Table 9)
To run each of these script:
- Complete the
data_folderfield with the path to thelearning-models-datadataset folder on your machine. - Complete the
save_dirfield with the path to the folder where to write the results. - (Optional) Comment/Uncomment the configuration of the variant you would like to train.
- Activate the proper python environement and run the script.
The results of each configuration (model x dataset split) gets written in a separate subdirectory in save_dir.
The scripts will execute the 40 runs for each configuration by default.
So in each subdirectory you will find one result file per fold with the following name run_summary_foldX.json .
The result files contain all the values of the different hyperparameters as well as the performance metrics on the train, validation, and test sets.
The present repository also contains the code to reproduce the results of the traditional machine learning baselines.
To do so use the run-traditional-ml-baselines.py script and follow these steps:
- Complete the
data_folderfield with the path to thelearning-models-datadataset folder on your machine. - Complete the
save_dirfield with the path to the folder where to write the results. - Comment/Uncomment the configuration of the variant you would like to train.
- Activate the proper python environement and run the script.
To cite this work please use:
@article{phenoformer2025,
title={Deep learning meets tree phenology modeling: PhenoFormer vs. process-based models},
author={Garnot, Vivien Sainte Fare and Spafford, Lynsay and Lever, Jelle and
Sigg, Christian and Pietragalla, Barbara and Vitasse, Yann
and Gessler, Arthur and Wegner, Jan Dirk},
journal={{Methods in Ecology and Evolution}},
year={2025}
} - Data source: Federal Office of Meteorology and Climatology (MeteoSwiss)
- Meteorological data processing: Swiss Federal Institute for Forest, Snow and Landscape Research (WSL)
- This project was co-financed by the Federal Office for Meteorology and Climatology MeteoSwiss within the framework of GAW-CH.