Skip to content
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 ratio adjustment in RandomLinkSplit when not enough negative edges exist #5642

Merged
merged 8 commits into from Oct 10, 2022

Conversation

Padarn
Copy link
Contributor

@Padarn Padarn commented Oct 10, 2022

This change addresses #5581

The problem being solved is that it is possible for there to not be enough negative edges available to satisfy the requested sampling ratio.

This change makes it so that in this case the ratio assigned to each split should reflect the desired ratio between the splits. I.e, the % assigned to each of train, test and validation is the same as requested.

@Padarn Padarn self-assigned this Oct 10, 2022
@codecov
Copy link

codecov bot commented Oct 10, 2022

Codecov Report

Merging #5642 (259e6ce) into master (d5e2e1e) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 259e6ce differs from pull request most recent head 185d9f9. Consider uploading reports for the commit 185d9f9 to get more accurate results

@@           Coverage Diff           @@
##           master    #5642   +/-   ##
=======================================
  Coverage   83.87%   83.87%           
=======================================
  Files         349      349           
  Lines       19207    19213    +6     
=======================================
+ Hits        16109    16115    +6     
  Misses       3098     3098           
Impacted Files Coverage Δ
torch_geometric/transforms/random_link_split.py 93.37% <100.00%> (+0.27%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@rusty1s rusty1s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

torch_geometric/transforms/random_link_split.py Outdated Show resolved Hide resolved
torch_geometric/transforms/random_link_split.py Outdated Show resolved Hide resolved
Comment on lines 209 to 211
assert len(train_data.neg_edge_label) != 0
assert len(val_data.neg_edge_label) != 0
assert len(test_data.neg_edge_label) != 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check here for the actual returned number of edges? I guess it may be

assert len(train_data.neg_edge_label) == 1
assert len(val_data.neg_edge_label) == 1
assert len(test_data.neg_edge_label) == 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're all non-zero, but yes we can check the exact size, I'll add that.

Padarn and others added 3 commits October 10, 2022 15:25
Co-authored-by: Matthias Fey <matthias.fey@tu-dortmund.de>
Co-authored-by: Matthias Fey <matthias.fey@tu-dortmund.de>
@rusty1s rusty1s enabled auto-merge (squash) October 10, 2022 07:40
@rusty1s rusty1s merged commit a6b92fd into master Oct 10, 2022
@rusty1s rusty1s deleted the random_link_split_ratio branch October 10, 2022 07:44
JakubPietrakIntel pushed a commit to JakubPietrakIntel/pytorch_geometric that referenced this pull request Nov 25, 2022
…ges exist (pyg-team#5642)

* add handling for not enough negative edges in random link split

* add readme

* Update torch_geometric/transforms/random_link_split.py

Co-authored-by: Matthias Fey <matthias.fey@tu-dortmund.de>

* Update torch_geometric/transforms/random_link_split.py

Co-authored-by: Matthias Fey <matthias.fey@tu-dortmund.de>

* update tests

* typos

* typo

Co-authored-by: Matthias Fey <matthias.fey@tu-dortmund.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants