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
Support StellarGraph input and output in EdgeSplitter #1032
Conversation
Check out this pull request on You'll be able to see Jupyter notebook diff and discuss changes. Powered by ReviewNB. |
Code Climate has analyzed commit a4b3cd2 and detected 0 issues on this pull request. View more on Code Climate. |
Codecov Report
@@ Coverage Diff @@
## develop #1032 +/- ##
=========================================
- Coverage 85.6% 85.1% -0.4%
=========================================
Files 53 53
Lines 5552 5375 -177
=========================================
- Hits 4751 4576 -175
+ Misses 801 799 -2
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## develop #1032 +/- ##
=========================================
- Coverage 85.6% 85.1% -0.4%
=========================================
Files 53 53
Lines 5552 5375 -177
=========================================
- Hits 4751 4576 -175
+ Misses 801 799 -2
Continue to review full report at Codecov.
|
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.
Hi,
this looks good. There is only one update necessary for the ensemble link prediction demo. This is a pre-existing error that can be easily fixed.
When calling model.compile(...)
please change weighted_metrics=["acc"]
to metrics=["acc"]
and then when calling model.fit_generator(...)
please change early_stopping_monitor="val_weighted_acc"
to early_stopping_monitor="val_acc"
.
The above will remove the tensorflow warning, WARNING:tensorflow:Early stopping conditioned on metric
val_weighted_acc which is not available. Available metrics are: loss,acc,val_loss,val_acc
that the call to fit_generator
outputs. Our generators do not output sample weights and the call to fit_generator
does not specify class_weight
so weighted metrics are not available. It looks like this was an error in the original notebook. We can fix it as part of this pull request or have it as a separate ticket if you prefer.
P.
This adjust the
stellargraph.data.EdgeSplitter
class so that it can consume and emit aStellarGraph
object: if it is constructed likeEdgeSplitter(some_stellargraph)
, thentrain_test_split
will return aStellarGraph
object. For backwards-compatibility,EdgeSplitter(some_networkx)
still works, and returns a NetworkX object; that is, existing code will not be affected.For now, this compatibility is useful even just for our own code as there's still quite a few of our demos that would require a lot more code to switch to use this new form, and so I have not switched them here:
demos/link-prediction/gcn/cora-gcn-links-example.ipynb
,demos/link-prediction/graphsage/cora-links-example.ipynb
: unlike other demos that use the Cora dataset, these use the subject as a feature (rather than as a target), and so the graph returned byCora().load()
can't be used directly (New StellarGraph: remove use of networkx from Cora link prediction examples #1039)demos/link-prediction/random-walks/main.py
,demos/link-prediction/random-walks-cora-lp-demo.ipynb
: these seem to have their own implementation of node2vec and metapath2vec built on top of NetworkX and so aren't using StellarGraph objects anyway (or, it seems, anything from thestellargraph
library other thanEdgeSplitter
) (related to Update demos/link-prediction/random-walks/main.py to use new datasets module #810, Demo directory for link prediction via random walks contains a very large amount of code #896 and Create a demo notebook to replace script for random walk link prediction #934)However, some notebooks can be updated without too much code, in particular
demos/calibration/calibration-pubmed-link-prediction.ipynb
anddemos/ensembles/ensemble-link-prediction-example.ipynb
can move over to usingCora().load()
(per #812 and #717) by passing the returnedStellarGraph
object directly intoEdgeSplitter
, with not many other code changes required.See: #174