Skip to content

Codebase for paper "Exploring Time Granularity on Temporal Graphs for Dynamic Link Prediction in Real-world Networks" (accepted by TGL workshop @ NeurIPS2023)

License

Notifications You must be signed in to change notification settings

SilenceX12138/Time-Granularity-on-Temporal-Graphs

Repository files navigation

Exploring Time Granularity on Temporal Graphs for Dynamic Link Prediction in Real-world Networks

Arxiv-Paper Video presentation Poster License: MIT Python 3.9+

Official code for the paper Exploring Time Granularity on Temporal Graphs for Dynamic Link Prediction in Real-world Networks accepted at TGL workshop @ NeurIPS2023

by Xiangjian Jiang and Yanyi Pu

Introduction

Dynamic Graph Neural Networks (DGNNs) have emerged as the predominant approach for processing dynamic graph-structured data. However, the influence of temporal information on model performance and robustness remains insufficiently explored, particularly regarding how models address prediction tasks in the absence of corresponding temporal information. In this study, we explore the optimal choice of time granularity for training DGNNs on dynamic graphs through extensive experimentation. We examined graphs derived from various domains and compared three different DGNNs to the baseline model across four varied time granularities. We mainly consider the interplay between time granularities, model architectures, and negative sampling strategies to obtain general conclusions. Our experiments reveal that a sophisticated memory mechanism and proper time granularity are crucial for a DGNN to deliver exceptional and robust performance in the dynamic link prediction task. We also discuss drawbacks in selected models and datasets and propose promising directions for future research on the time granularity of temporal graphs.

image

Running the experiments

Set up Environment

conda create -n dgb python=3.9

then run

source install.sh

Datasets and Processing

All dynamic graph datasets can be downloaded from here. Then, they can be located in "DG_data" folder. For conducting any experiments, the required data should be in the data folder under each model of interest.

  • For example, to train a TGN model on Wikipedia dataset, we can use the following command to move the edgelist to the right folder:
cp DG_data/wikipedia.csv tgn/data/wikipedia.csv
  • Then, the edgelist should be pre-processed to have the right format. Considering the example of Wikipedia edgelist, we can use the following command for pre-processing the dataset:
# JODIE, DyRep, or TGN
python tgn/utils/preprocess_data.py --data wikipedia

Model Training

  • Example of training different graph representation learning models on Wikipedia dataset:
data=wikipedia
n_runs=5

# JODIE
method=jodie
prefix="${method}_rnn"
python tgn/train_self_supervised.py -d $data --use_memory --memory_updater rnn --embedding_module time --prefix "$prefix" --n_runs "$n_runs" --gpu 0

# DyRep
method=dyrep
prefix="${method}_rnn"
python tgn/train_self_supervised.py -d "$data" --use_memory --memory_updater rnn --dyrep --use_destination_embedding_in_message --prefix "$prefix" --n_runs "$n_runs" --gpu 0

# TGN
method=tgn
prefix="${method}_attn"
python tgn/train_self_supervised.py -d $data --use_memory --prefix "$prefix" --n_runs "$n_runs" --gpu 0
  • Example of using EdgeBank for dynamic link prediction with standard random negative sampler:
data=Wikipedia
mem_mode=unlim_mem
n_runs=5
neg_sample=rnd  # can be one of these options: "rnd": standard randome, "hist_nre": Historical NS, or "induc_nre": Inductive NS
python EdgeBank/link_pred/edge_bank_baseline.py --data "$data" --mem_mode "$mem_mode" --n_runs "$n_runs" --neg_sample "$neg_sample"

Testing Trained Models

  • Testing trained models with different negative edge sampling strategies:
n_runs=5
data=wikipedia
neg_sample=hist_nre  # can be either "hist_nre" for historical NS, or "induc_nre" for inductive NS

# JODIE
method=jodie
python tgn/tgn_test_trained_model_self_sup.py -d "$data" --use_memory --memory_updater rnn --embedding_module time --model $method --neg_sample $neg_sample --n_runs $n_runs --gpu 0

# DyRep
method=dyrep
python tgn/tgn_test_trained_model_self_sup.py -d "$data" --use_memory --memory_updater rnn --dyrep --use_destination_embedding_in_message --model $method --neg_sample $neg_sample --n_runs $n_runs --gpu 0

# TGN
method=tgn
python tgn/tgn_test_trained_model_self_sup.py -d $data --use_memory --model $method --neg_sample $neg_sample --n_runs $n_runs --gpu 0

Environment Requirements

  • python >= 3.7, PyTorch >= 1.4
  • Other requirements:
pandas==1.1.0
scikit_learn==0.23.1
tqdm==4.41.1
numpy==1.16.4
matploblib==3.3.1

Citation

Please cite our work if you use code from this repo:

@inproceedings{jiang2023exploring,
  title={Exploring Time Granularity on Temporal Graphs for Dynamic Link Prediction in Real-world Networks},
  author={Jiang, Xiangjian and Pu, Yanyi},
  booktitle={Temporal Graph Learning Workshop@ NeurIPS 2023},
  year={2023}
}

About

Codebase for paper "Exploring Time Granularity on Temporal Graphs for Dynamic Link Prediction in Real-world Networks" (accepted by TGL workshop @ NeurIPS2023)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •