PyGDA is a Python library for Graph Domain Adaptation built upon PyTorch and PyG to easily train graph domain adaptation models in a sklearn style. PyGDA includes 15+ graph domain adaptation models. See examples with PyGDA below!
Graph Domain Adaptation Using PyGDA with 5 Lines of Code
from pygda.models import A2GNN
# choose a graph domain adaptation model
model = A2GNN(in_dim=num_features, hid_dim=args.nhid, num_classes=num_classes, device=args.device)
# train the model
model.fit(source_data, target_data)
# evaluate the performance
logits, labels = model.predict(target_data)
PyGDA is featured for:
We support graph-level domain adaptation task.
A2GNN
, AdaGCN
, CWGCN
, DANE
, GRADE
, SAGDA
, UDAGCN
are supported.FRANKENSTEIN
, Mutagenicity
and PROTEINS
.model = A2GNN(in_dim=num_features, hid_dim=args.nhid, num_classes=num_classes, mode='graph', device=args.device)
Note: PyGDA depends on PyTorch, PyG, PyTorch Sparse and Pytorch Scatter. PyGDA does not automatically install these libraries for you. Please install them separately in order to run PyGDA successfully.
Required Dependencies:
Installing with pip:
pip install pygda
or
Installation for local development:
git clone https://github.com/pygda-team/pygda
cd pygda
pip install -e .
from pygda.datasets import CitationDataset
source_dataset = CitationDataset(path, args.source)
target_dataset = CitationDataset(path, args.target)
from pygda.models import A2GNN
model = A2GNN(in_dim=num_features, hid_dim=args.nhid, num_classes=num_classes, device=args.device)
model.fit(source_data, target_data)
from pygda.metrics import eval_micro_f1, eval_macro_f1
logits, labels = model.predict(target_data)
preds = logits.argmax(dim=1)
mi_f1 = eval_micro_f1(labels, preds)
ma_f1 = eval_macro_f1(labels, preds)
In addition to the easy application of existing GDA models, PyGDA makes it simple to implement custom models.
BaseGDA
class.fit()
, forward_model()
, and predict()
functions.If you compare with, build on, or use aspects of PyGDA, please consider citing "Revisiting, Benchmarking and Understanding Unsupervised Graph Domain Adaptation":
@misc{liu2024pydga,
title={Revisiting, Benchmarking and Understanding Unsupervised Graph Domain Adaptation},
author={Meihan Liu and Zhen Zhang and Jiachen Tang and Jiajun Bu and Bingsheng He and Sheng Zhou},
year={2024},
eprint={2407.11052},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2407.11052},
}