This repository contains code to train a Graph Neural Network to predict whether a given bee in a hive survives a given number of days into the future using age, location, and relational information about interactions between pairs of bees. Used libraries include PyTorch Geometric, PyTorch Lightning, and Optuna.
- Either create the directories
/kaggle/working/
and/kaggle/input/honey-bee-temporal-social-network/
, or changeINPUT_PATH
andOUTPUT_PATH
in./source/config.py
. - Download the files
bee_daily_data.csv
andinteraction_networks_20160729to20160827.h5
at the bottom of the page https://doi.org/10.5281/zenodo.4438013 under 'Files' and move them into the directory atINPUT_PATH
. pip install optuna torch torch_geometric pytorch_lightning scikit-learn matplotlib h5py numpy pandas swifter
- In
./source/config.py
, set theMODEL_NAME
to 'MLP' for vanilla neural network, or 'GNN' for graph convolutional neural network. Other run parameters can also be changed there. - To skip hyperparameter tuning, comment out the first line in
./source/best_hyperparameters
, and uncomment thebest_hyperparameters
dictionary in that file. - For all the imports to work properly, set an environment variable via
export BEESDIR='/full/path/to/local/repository'
, with '/full/path/to/local/repository' replaced accordingly. - Run
python ./source/experiment.py
- Create a Kaggle dataset called 'your-user-name/bees-source' containing all the scripts in
./source/
. - Create a Kaggle script from
./source/experiments.py
, and add both your newly created dataset from step 1., and the bees dataset as inputs. - Run the Kaggle script created in 2.
The MLP and GNN code were both tested to run with Python 3.7.12 on GPU. In addition, the MLP code was tested to run with Python 3.9.12 on CPU.
Wild, Benjamin, Dormagen, David and Landgraf, Tim (2021) Social networks predict the life and death of honey bees - Data