-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add attract-repel link prediction example #10107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add attract-repel link prediction example #10107
Conversation
for more information, see https://pre-commit.ci
puririshi98
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before i review the code,
@tommyly201 if you see where it says link_pred.py in https://github.com/tommyly201/pytorch_geometric/blob/feature/ar-link-pred-example/examples/README.md
please add something below that explaining how you can get better accuracy (share the range of improvement across your benchmarks as an estimate in parenthesis). then link the example and the corresponding paper.
Update README.md to include ar_link_pred.py example
Update README.md to include ar_link_pred.py example
for more information, see https://pre-commit.ci
For a flexible implementation that can enhance any GNN model with attract-repel capabilities, see [`attract_repel_wrapper.py`](./attract_repel_wrapper.py).
puririshi98
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise LGTM i can merge once we get #10105 (review) merged
for more information, see https://pre-commit.ci
…myly201/pytorch_geometric into feature/ar-link-pred-example
for more information, see https://pre-commit.ci
|
LGTM, will approve and merge once we get #10105 in |
# Add Attract-Repel Embeddings for Link Prediction This PR adds an implementation of Attract-Repel embeddings from the paper "Pseudo-Euclidean Attract-Repel Embeddings for Undirected Graphs" by Peysakhovich et al. ## Overview Attract-Repel embeddings address a fundamental limitation in traditional graph embeddings: their inability to effectively represent non-transitive relationships. The method splits node representations into two components: - Attract component: nodes with similar attract vectors are likely to connect - Repel component: nodes with similar repel vectors are unlikely to connect Link prediction scores are calculated as: attract_dot_product - repel_dot_product ## Implementation - Added `ARLinkPredictor` class that implements the core functionality - Added thorough tests to validate the implementation - The implementation is minimal and focused on the core concept ## Benefits - Improves link prediction performance on graphs with non-transitive relationships - Requires minimal architectural changes to existing models - Provides useful information about graph structure through R-fraction analysis - Example PR [#10107 ](#10107) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Rishi Puri <[email protected]> Co-authored-by: Rishi Puri <[email protected]>
puririshi98
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
# Add Attract-Repel Embeddings for Link Prediction This PR adds an implementation of Attract-Repel embeddings from the paper "Pseudo-Euclidean Attract-Repel Embeddings for Undirected Graphs" by Peysakhovich et al. ## Overview Attract-Repel embeddings address a fundamental limitation in traditional graph embeddings: their inability to effectively represent non-transitive relationships. The method splits node representations into two components: - Attract component: nodes with similar attract vectors are likely to connect - Repel component: nodes with similar repel vectors are unlikely to connect Link prediction scores are calculated as: attract_dot_product - repel_dot_product ## Implementation - Added `ARLinkPredictor` class that implements the core functionality - Added thorough tests to validate the implementation - The implementation is minimal and focused on the core concept ## Benefits - Improves link prediction performance on graphs with non-transitive relationships - Requires minimal architectural changes to existing models - Provides useful information about graph structure through R-fraction analysis - Example PR [pyg-team#10107 ](pyg-team#10107) --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Rishi Puri <[email protected]> Co-authored-by: Rishi Puri <[email protected]>
# Attract-Repel Link Prediction Example This PR adds an example implementation showcasing the attract-repel embeddings (from PR pyg-team#10105) on link prediction tasks. The example demonstrates how attract-repel embeddings can significantly improve performance on citation networks. ## Overview The example: - Compares traditional vs attract-repel embeddings on link prediction - Works with standard Planetoid datasets (Cora, CiteSeer, PubMed) - Shows performance improvements across different networks - Calculates and reports the R-fraction for analysis ## Results | Dataset | Method | Test AUC | |---------|--------|----------| | Cora | Traditional | 0.6624 | | Cora | Attract-Repel | 0.8945 | | PubMed | Traditional | 0.8977 | | PubMed | Attract-Repel | 0.9607 | | CitiSeer | Traditional | 0.8067 | | CitiSeer | Attract-Repel | 0.8206 | The attract-repel approach shows consistent improvements across datasets: - **Cora**: +0.2321 AUC (R-fraction: 0.4075) - **PubMed**: +0.0630 AUC (R-fraction: 0.5062) - **CitiSeer**: +0.0139 AUC (R-fraction: 0.4869) The varying R-fractions indicate that the model adapts to different graph structures, with PubMed using more of the repel component than Cora. ## Usage Traditional approach: python examples/ar_link_pred.py --dataset Cora Attract-Repel approach python examples/ar_link_pred.py --dataset Cora --use_ar This example complements the attract-repel embeddings implementation in PR pyg-team#10105. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Rishi Puri <[email protected]> Co-authored-by: Rishi Puri <[email protected]>
Attract-Repel Link Prediction Example
This PR adds an example implementation showcasing the attract-repel embeddings (from PR #10105) on link prediction tasks. The example demonstrates how attract-repel embeddings can significantly improve performance on citation networks.
Overview
The example:
Results
The attract-repel approach shows consistent improvements across datasets:
The varying R-fractions indicate that the model adapts to different graph structures, with PubMed using more of the repel component than Cora.
Usage
Traditional approach:
python examples/ar_link_pred.py --dataset Cora
Attract-Repel approach
python examples/ar_link_pred.py --dataset Cora --use_ar
This example complements the attract-repel embeddings implementation in PR #10105.