Giter Site home page Giter Site logo

mirjunaid26 / graphsmote Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tianxiangzhao/graphsmote

0.0 0.0 0.0 59 KB

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

Python 100.00%

graphsmote's Introduction

GraphSmote

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

Dependencies

CPU

  • python3
  • ipdb
  • pytorch1.0
  • network 2.4
  • scipy
  • sklearn

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.

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

  • Pretrain the auto-encoder

python main.py --imbalance --no-cuda --dataset=cora --setting='recon'

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

  • Finetune

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

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.

  • Oringinal model: Vanilla backbone models. '--setting='no''
  • Over-sampling in raw input domain: Repeat nodes in the minority classes. '--setting='upsampling''
  • Reweight: Give samples from minority classes a larger weight when calculating the loss. '--setting='reweight''
  • Embed-SMOTE: Perform SMOTE in the intermediate embedding domain. '--setting='embed_up''

Use over-sampling as an example:

python main.py --imbalance --no-cuda --dataset=cora --setting='upsampling'

Citation

If any problems occurs via running this code, please contact us at [email protected].

Thank you!

graphsmote's People

Contributors

tianxiangzhao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.