A Python library for Graph Domain Adaptation
Project description
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:
- Consistent APIs and comprehensive documentation.
- Cover 15+ 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.
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
BaseGDA
class. - implement your
fit()
,forward_model()
, andpredict()
functions.
Reference
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pygda-0.0.2.tar.gz
.
File metadata
- Download URL: pygda-0.0.2.tar.gz
- Upload date:
- Size: 64.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ac6c8eca89ab2287b03c1e57536b64d2aafe3d69114cfb137944740fb6c83e6 |
|
MD5 | 1b42e66a9f7e9912d877bff0cc12bc56 |
|
BLAKE2b-256 | 8fc49a80ca2387c9db2aeae17e3fc22c3aa83c5f9ef7e7dd6faa0a664d275349 |
File details
Details for the file pygda-0.0.2-py2.py3-none-any.whl
.
File metadata
- Download URL: pygda-0.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 109.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61655d38ad3fa44ee0b4b82f3ec8c8a4b54b5b5223f0bbc58a87a32963976c38 |
|
MD5 | 1718a2f8a8d5c5658e1df01994327fc6 |
|
BLAKE2b-256 | c6877d6c4a79fcd0675d3a03bd04040bfcbe2747600b3522d05dc08619d044f3 |