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 20+ 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:
- Consistent APIs and comprehensive documentation.
- Cover 20+ graph domain adaptation models.
- Scalable architecture that efficiently handles large graph datasets through mini-batching and sampling techniques.
- Seamlessly integrated data processing with PyG, ensuring full compatibility with PyG data structures.
📢 What's New?
[08/2025]. We have added support for very recent graph domain adaptation models.
- 2 recent models including
TDSSandDGSDAare supported.
[03/2025]. We now support multi-source-free setting of graph domain adaptation.
- To perform a multi-source-free domain adaptation task, simply modify one parameter in the model as follows:
model = GraphATA(in_dim=num_features, hid_dim=args.nhid, num_classes=num_classes, num_src_domains=n, device=args.device)
model.fit([source_data, source_data2, ...], target_data)
[12/2024]. We now support source-free setting of graph domain adaptation.
- 3 recent models including
GTrans,SOGAandGraphCTAare supported.
[08/2024]. We support graph-level domain adaptation task.
- 7 models including
A2GNN,AdaGCN,CWGCN,DANE,GRADE,SAGDA,UDAGCNare supported. - Various TUDatasets are supported including
FRANKENSTEIN,MutagenicityandPROTEINS. - To perform a graph-level domain adaptation task, only one parameter is added to the model as follows:
model = A2GNN(in_dim=num_features, hid_dim=args.nhid, num_classes=num_classes, mode='graph', device=args.device)
Installation
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:
- torch>=1.13.1
- torch_geometric>=2.4.0
- torch_sparse>=0.6.15
- torch_scatter>=2.1.0
- python3
- scipy
- sklearn
- numpy
- cvxpy
- tqdm
Installing with pip:
pip install pygda
or
Installation for local development:
git clone https://github.com/pygda-team/pygda
cd pygda
pip install -e .
Quick Start
Step 1: Load Data
from pygda.datasets import CitationDataset
source_dataset = CitationDataset(path, args.source)
target_dataset = CitationDataset(path, args.target)
Step 2: Build Model
from pygda.models import A2GNN
model = A2GNN(in_dim=num_features, hid_dim=args.nhid, num_classes=num_classes, device=args.device)
Step 3: Fit Model
model.fit(source_data, target_data)
Step 4: Evaluation
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)
Create your own GDA model
In addition to the easy application of existing GDA models, PyGDA makes it simple to implement custom models.
- the customed model should inherit
BaseGDAclass. - implement your
fit(),forward_model(), andpredict()functions.
Reference
Cite
If you compare with, build on, or use aspects of PyGDA, please consider citing "Revisiting, Benchmarking and Understanding Unsupervised Graph Domain Adaptation":
@inproceedings{liu2024revisiting,
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},
booktitle={The Thirty-eight Conference on Neural Information Processing Systems Datasets and Benchmarks Track},
year={2024},
url={https://openreview.net/forum?id=ZsyFwzuDzD}
}
Metadata
Release files for pygda 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pygda-1.2.1.tar.gz | 139.0 kB | Without provenance | Details for pygda-1.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pygda-1.2.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for pygda-1.2.1-py2.py3-none-any.whl |
Total release size: 355.7 kB
Release files / pygda-1.2.1.tar.gz
| Download URL | pygda-1.2.1.tar.gz |
|---|---|
| Size | 139.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99bbe5799ef3766db445cc26d9b7aae2fbcdd850c27175c19ce50bf7b4c7c427
|
|
BLAKE2b-256 checksum How to use checksums |
e75f172f4376f55b1eed3328ba7374370e2c9457f4ff833615ab346df1a29d52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / pygda-1.2.1-py2.py3-none-any.whl
| Download URL | pygda-1.2.1-py2.py3-none-any.whl |
|---|---|
| Size | 216.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
27ddf2a74b84fe50a686f51c413111f549a3077a842b297f0a2eaaea883c7694
|
|
BLAKE2b-256 checksum How to use checksums |
3baf0a78bf865f72e4e3d49456a79799d89c2f92e2d33b167506453fadae77f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for pygda 1.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.