Home

Awesome

GraphSmote

Pytorch implementation of paper 'GraphSMOTE: Imbalanced Node Classification on Graphs with Graph Neural Networks' on WSDM2021

Dependencies

CPU

Dataset

Two processed datasets are published, including BlogCatalog and Cora. For downloading them, please click. Please unzip them in the 'data' folder.

The twitter dataset is obtained from link, with fake id. For twitter dataset, node embeddings can be generated with Deepwalk, following this repo. Loading the twitter dataset is also provided in data_load.py.

Configurations

Architectures

We provide two base architectures, GCN and GraphSage. The default one is GraphSage, and can be set via '--model'.

Upscale ratios

The default value is 1. If want to make every class balanced instead of using pre-set ratios, please set it to 0 in '--up_scale'.

Finetuning the decoder

During finetune, set '--setting='newG_cls'' correponds to use pretrained decoder, and set '--setting='recon_newG'' corresponds to also finetune the decoder.

Besides, during finetune, '--opt_new_G' corresponds to update decoder with also classification losses. This option may cause more variance in performance, and usually need more careful hyper-parameter choices.

GraphSMOTE

Below is an example for the Cora dataset.

Train

<code>python main.py --imbalance --no-cuda --dataset=cora --setting='recon'</code>

Pretrained model can be found in the corresponding checkpoint folder. Rename and set the path to pretrained checkpoint as [dataset]\Pretrained.pth

<code>python main.py --imbalance --no-cuda --dataset=cora --setting='newG_cls' --load=Pretrained.pth</code>

Baselines

We provide four baselines in this code. They can be configured via the '--setting' arguments. Please refer to the 'get_parser()' function in utils.py.

Use over-sampling as an example:

<code>python main.py --imbalance --no-cuda --dataset=cora --setting='upsampling'</code>

Citation

If any problems occur via running this code, please contact us at tkz5084@psu.edu.

Thank you!