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

Feature/attri2vec #470

Merged
merged 83 commits into from Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
ad12870
add space
daokunzhang Aug 7, 2019
ace4fec
Add the definition of the attri2vecLinkGenerator, which helps generat…
daokunzhang Aug 7, 2019
8df7576
Add the implementation of attri2vec, and investigate its performance …
daokunzhang Aug 7, 2019
46a77dd
reformat link_mappers.py with black
daokunzhang Aug 8, 2019
189a612
Update .gitignore
daokunzhang Aug 8, 2019
158f32b
Delete .DS_Store
daokunzhang Aug 8, 2019
1c24d09
Delete .DS_Store
daokunzhang Aug 8, 2019
c53a5cd
Delete .DS_Store
daokunzhang Aug 8, 2019
4517c9f
Update README.md
daokunzhang Aug 8, 2019
947c843
Update README.md
daokunzhang Aug 8, 2019
a37f67c
Update README.md
daokunzhang Aug 8, 2019
50ccc0c
rewrite the attri2vec demo by using the Attri2Vec model, Attri2VecNod…
daokunzhang Aug 21, 2019
fb7ce36
Add the module to define Attri2Vec class
daokunzhang Aug 21, 2019
094650e
Add the definition of the class: Attri2VecLinkGenerator
daokunzhang Aug 21, 2019
b9a81c9
Add the definition of the class: Attri2VecNodeGenerator
daokunzhang Aug 21, 2019
04dbc46
Add the test for Attri2VecNodeGenerator
daokunzhang Aug 21, 2019
3e90641
Add test for Attri2VecLinkGenerator
daokunzhang Aug 21, 2019
1a8a981
Add tests for Attri2Vec class
daokunzhang Aug 21, 2019
4085790
Add the Attri2Vec, Attri2VecNodeGenerator and Attri2VecLinkGenerator …
daokunzhang Aug 21, 2019
37ce44d
Add attri2vec module to the stellargraph/layer/__init__.py file
daokunzhang Aug 21, 2019
208835e
rerun the attri2vec demo
daokunzhang Aug 21, 2019
6179a3a
update the attri2vec demo by fixing some typos
daokunzhang Aug 22, 2019
f959e65
code update
daokunzhang Sep 25, 2019
36a7cd8
code update
daokunzhang Sep 25, 2019
a50390f
add attri2vec link prediction demo
daokunzhang Sep 25, 2019
181c75e
add attri2vec DBLP embeddings demo
daokunzhang Sep 25, 2019
5e12241
Add attrivec citeseer embeddings demo
daokunzhang Sep 25, 2019
67c3c45
Add demos/node-classification/attri2vec/README.md file
daokunzhang Sep 25, 2019
8fb54c1
add attri2vec description to demos/node-classification/README.md file
daokunzhang Sep 25, 2019
20046ec
add demos/link-prediction/attri2vec/README.md file
daokunzhang Sep 25, 2019
4121e33
add attri2vec description to demos/link-prediction/README.md file
daokunzhang Sep 25, 2019
7b65cab
add attri2vec description to demos/embeddings/README.md file
daokunzhang Sep 25, 2019
c68a62d
add attri2vec description to demos/README.md file
daokunzhang Sep 25, 2019
a00b4cd
add attri2vec description to README.md file
daokunzhang Sep 25, 2019
c0922ea
code update for node_mappers.py
daokunzhang Sep 25, 2019
645ca32
code update for link_mappers.py
daokunzhang Sep 25, 2019
c0dbb1f
code update for link_inference.py
daokunzhang Sep 25, 2019
bbe5700
add a function of get_index_for_nodes to graph.py
daokunzhang Sep 25, 2019
9639b4d
code update for attri2vec.py
daokunzhang Sep 25, 2019
535e39d
add attri2vec node classification demo on DBLP
daokunzhang Sep 25, 2019
1052ff5
add attri2vec node classification demo on citeseer
daokunzhang Sep 25, 2019
bcf934d
Delete attri2vec-citeseer-node-classification-example.ipynb
daokunzhang Sep 25, 2019
cc6d001
add attri2vec node classification demo on citeseer
daokunzhang Sep 25, 2019
ed4dd44
update demos/node-classification/attri2vec/README.md
daokunzhang Sep 25, 2019
5688345
fixed conflicts.
daokunzhang Sep 25, 2019
4e943db
rerun attri2vec out-of-sample link prediction demo on DBLP
daokunzhang Sep 25, 2019
80a0161
rerun the attri2vec DBLP embedding demo
daokunzhang Sep 25, 2019
02a8bb1
rerun attri2vec citeseer embedding demo
daokunzhang Sep 25, 2019
280daca
handle the conflict on node_mappers.py
daokunzhang Sep 25, 2019
1c5f819
handle the conflicts on link_mappers.py
daokunzhang Sep 25, 2019
9b30169
rerun the attri2vec DBLP node classification demo
daokunzhang Sep 25, 2019
e09fab2
rerun the attri2vec citeseer node classification demo
daokunzhang Sep 25, 2019
9646a7e
reformat link_mappers.py with black
daokunzhang Sep 25, 2019
cc67c88
reformat the node_mappers.py file with black
daokunzhang Sep 25, 2019
9270696
Add the unit test for fun get_index_for_nodes
daokunzhang Oct 1, 2019
3099658
update test_node_mappers.py
daokunzhang Oct 1, 2019
7f185da
update test_link_mappers.py
daokunzhang Oct 1, 2019
5e462f0
update test_attri2vec.py
daokunzhang Oct 1, 2019
c4cf43e
Revert "update test_link_mappers.py"
daokunzhang Oct 1, 2019
e89940f
test_attri2vec.py update
daokunzhang Oct 1, 2019
01c06eb
update attri2vec link prediction demo on DBLP
daokunzhang Oct 1, 2019
d592cbe
delete attri2vec DBLP embedding learning demo
daokunzhang Oct 1, 2019
e375e81
update attri2vec citeseer embedding learning demo
daokunzhang Oct 1, 2019
9916097
update demos/node-classification/attri2vec/README.md file
daokunzhang Oct 1, 2019
f74eadb
update demos/node-classification/README.md file
daokunzhang Oct 1, 2019
9a217cc
update demos/link-prediction/attri2vec/README.md file
daokunzhang Oct 1, 2019
536ade1
update demos/link-prediction/README.md file
daokunzhang Oct 1, 2019
8ae2f9b
update demos/embeddings/README.md file
daokunzhang Oct 1, 2019
6cf8cbe
update demos/README.md file
daokunzhang Oct 1, 2019
94cb345
update README.md file
daokunzhang Oct 1, 2019
291628f
update node_mappers.py
daokunzhang Oct 1, 2019
197f4de
update link_mappers.py
daokunzhang Oct 1, 2019
34ae2da
update attri2vec.py
daokunzhang Oct 1, 2019
a97ed36
delete attri2vec DBLP node classification demo
daokunzhang Oct 1, 2019
63f0a3b
update attri2vec citeseer node classification demo
daokunzhang Oct 1, 2019
5d1fb25
update test_stellargraph.py by adding test for the get_index_for_node…
daokunzhang Oct 1, 2019
6012994
update test_node_mappers.py
daokunzhang Oct 1, 2019
6ef707a
update test_link_mappers.py
daokunzhang Oct 1, 2019
6c35c6b
update node_mappers.py
daokunzhang Oct 1, 2019
2e168e5
update link_mappers.py
daokunzhang Oct 1, 2019
26a0ead
update attri2vec.py
daokunzhang Oct 1, 2019
2b290bb
update test_link_mappers.py
daokunzhang Oct 1, 2019
e70c557
update test_stellargraph.py with black format
daokunzhang Oct 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 16 additions & 10 deletions README.md
Expand Up @@ -73,7 +73,7 @@ The StellarGraph library can be used to solve tasks using graph-structured data,
- Representation learning for nodes and edges, to be used for visualisation and various downstream machine learning tasks;
- Classification and attribute inference of nodes or edges;
- Link prediction;
- Interpretation of node classification through calculated importances of edges and neighbours for selected nodes [7].
- Interpretation of node classification through calculated importances of edges and neighbours for selected nodes [8].

We provide [examples](https://github.com/stellargraph/stellargraph/tree/master/demos/) of using `StellarGraph` to solve such tasks using several real-world datasets.

Expand Down Expand Up @@ -130,7 +130,7 @@ can be downloaded and installed from [python.org](https://python.org/). Alternat
environment, available from [anaconda.com](https://www.anaconda.com/download/).

*Note*: while the library works on Python 3.7 it is based on Keras which does not officially support Python 3.7.
Therefore, there may be unforseen bugs and you there are many warnings from the Python libraries that
Therefore, there may be unforseen bugs and you there are many warnings from the Python libraries that
StellarGraph depends upon.

<!--
Expand Down Expand Up @@ -172,7 +172,7 @@ pip install .[demos]

* [stellargraph/stellargraph](https://hub.docker.com/r/stellargraph/stellargraph): Docker image with `stellargraph` installed.

Images can be pulled via `docker pull stellargraph/stellargraph`
Images can be pulled via `docker pull stellargraph/stellargraph`


## Running the examples
Expand All @@ -193,13 +193,16 @@ The StellarGraph library currently includes the following algorithms for graph m
The current implementation supports mean aggregation of neighbour nodes,
taking into account their types and the types of links between them.

* The Graph ATtention Network (GAT) [4]
* Attri2vec [4]
- Supports node representation learning, node classification, and out-of-sample node link prediction for homogeneous graphs with node attributes.

* The Graph ATtention Network (GAT) [5]
- The GAT algorithm supports representation learning and node classification for homogeneous graphs. There are versions of the graph attention layer that support both sparse and dense adjacency matrices.

* Graph Convolutional Network (GCN) [5]
* Graph Convolutional Network (GCN) [6]
- The GCN algorithm supports representation learning and node classification for homogeneous graphs. There are versions of the graph convolutional layer that support both sparse and dense adjacency matrices.

* Simplified Graph Convolutional network (SGC) [6]
* Simplified Graph Convolutional network (SGC) [7]
- The SGC network algorithm supports representation learning and node classification for homogeneous graphs. It is an extension of the GCN algorithm that smooths the graph to bring in more distant neighbours of nodes without using multiple layers.

* Node2Vec [2]
Expand Down Expand Up @@ -262,14 +265,17 @@ Neural Information Processing Systems (NIPS), 2017. ([link](https://arxiv.org/ab
ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD), 135–144, 2017
([link](https://ericdongyx.github.io/metapath2vec/m2v.html))

4. Graph Attention Networks. P. Velickovic et al.
4. Attributed Network Embedding via Subspace Discovery. D. Zhang, Y. Jie, X. Zhu and C. Zhang, arXiv:1901.04095,
[cs.SI], 2019. ([link](https://arxiv.org/abs/1901.04095))

5. Graph Attention Networks. P. Velickovic et al.
International Conference on Learning Representations (ICLR) 2018 ([link](https://arxiv.org/abs/1710.10903))

5. Graph Convolutional Networks (GCN): Semi-Supervised Classification with Graph Convolutional Networks. Thomas N. Kipf, Max Welling.
6. Graph Convolutional Networks (GCN): Semi-Supervised Classification with Graph Convolutional Networks. Thomas N. Kipf, Max Welling.
International Conference on Learning Representations (ICLR), 2017
([link](https://github.com/tkipf/gcn))

6. Simplifying Graph Convolutional Networks. F. Wu, T. Zhang, A. H. de Souza, C. Fifty, T. Yu, and K. Q. Weinberger.
7. Simplifying Graph Convolutional Networks. F. Wu, T. Zhang, A. H. de Souza, C. Fifty, T. Yu, and K. Q. Weinberger.
International Conference on Machine Learning (ICML), 2019. ([link](https://arxiv.org/abs/1902.07153))

7. Adversarial Examples on Graph Data: Deep Insights into Attack and Defense. H. Wu, C. Wang, Y. Tyshetskiy, A. Docherty, K. Lu, and L. Zhu. IJCAI 2019. ([link](https://arxiv.org/abs/1903.01610))
8. Adversarial Examples on Graph Data: Deep Insights into Attack and Defense. H. Wu, C. Wang, Y. Tyshetskiy, A. Docherty, K. Lu, and L. Zhu. IJCAI 2019. ([link](https://arxiv.org/abs/1903.01610))
27 changes: 15 additions & 12 deletions demos/README.md
Expand Up @@ -7,10 +7,10 @@ examples demonstrate using the `StellarGraph` library to build machine learning
workflows on both homogeneous and heterogeneous networks.

Each folder contains one or more examples of using the StellarGraph implementations of the
state-of-the-art algorithms, GraphSAGE [3], HinSAGE, GCN [5], GAT [6], Node2Vec [1], and Metapath2Vec [2].
GraphSAGE, HinSAGE, and GAT are variants of Graph Convolutional Neural networks [5]. Node2Vec and
state-of-the-art algorithms, attri2vec [4], GraphSAGE [3], HinSAGE, GCN [6], GAT [7], Node2Vec [1], and Metapath2Vec [2].
GraphSAGE, HinSAGE, and GAT are variants of Graph Convolutional Neural networks [6]. Node2Vec and
Metapath2Vec are methods based on graph random walks and representation learning using the
Word2Vec [4] algorithm.
Word2Vec [5] algorithm.

The examples folder structure is shown below.

Expand All @@ -30,8 +30,8 @@ The examples folder structure is shown below.
* [`/ensembles`](https://github.com/stellargraph/stellargraph/tree/master/demos/ensembles)

Examples of using ensembles of graph convolutional neural networks, e.g., GraphSAGE, GCN, HinSAGE, etc., for
node classification and link prediction. Model ensembles usually yield better predictions than single models,
while also providing estimates of prediction uncertainty as a bonus.
node classification and link prediction. Model ensembles usually yield better predictions than single models,
while also providing estimates of prediction uncertainty as a bonus.

* [`/calibration`](https://github.com/stellargraph/stellargraph/tree/master/demos/calibration)

Expand All @@ -49,24 +49,27 @@ The examples folder structure is shown below.

## References

1. Node2Vec: Scalable Feature Learning for Networks. A. Grover, J. Leskovec. ACM SIGKDD International Conference on
1. Node2Vec: Scalable Feature Learning for Networks. A. Grover, J. Leskovec. ACM SIGKDD International Conference on
Knowledge Discovery and Data Mining (KDD), 2016. ([link](https://snap.stanford.edu/node2vec/))

2. Metapath2Vec: Scalable Representation Learning for Heterogeneous Networks. Yuxiao Dong, Nitesh V. Chawla, and
2. Metapath2Vec: Scalable Representation Learning for Heterogeneous Networks. Yuxiao Dong, Nitesh V. Chawla, and
Ananthram Swami. ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD), 135–144, 2017
([link](https://ericdongyx.github.io/metapath2vec/m2v.html))

3. Inductive Representation Learning on Large Graphs. W.L. Hamilton, R. Ying, and J. Leskovec arXiv:1706.02216
3. Inductive Representation Learning on Large Graphs. W.L. Hamilton, R. Ying, and J. Leskovec arXiv:1706.02216
[cs.SI], 2017. ([link](http://snap.stanford.edu/graphsage/))

4. Distributed representations of words and phrases and their compositionality. T. Mikolov,
4. Attributed Network Embedding via Subspace Discovery. D. Zhang, Y. Jie, X. Zhu and C. Zhang, arXiv:1901.04095,
[cs.SI], 2019. ([link](https://arxiv.org/abs/1901.04095))

5. Distributed representations of words and phrases and their compositionality. T. Mikolov,
I. Sutskever, K. Chen, G. S. Corrado, and J. Dean. In Advances in Neural Information Processing
Systems (NIPS), pp. 3111-3119, 2013. ([link](https://papers.nips.cc/paper/5021-distributed-representations-of-words-and-phrases-and-their-compositionality.pdf))

5. Semi-Supervised Classification with Graph Convolutional Networks. T. Kipf, M. Welling.
6. Semi-Supervised Classification with Graph Convolutional Networks. T. Kipf, M. Welling.
ICLR 2017. arXiv:1609.02907 ([link](https://arxiv.org/abs/1609.02907))

6. Graph Attention Networks. P. Velickovic et al. ICLR 2018 ([link](https://arxiv.org/abs/1710.10903))
7. Graph Attention Networks. P. Velickovic et al. ICLR 2018 ([link](https://arxiv.org/abs/1710.10903))

7. On Calibration of Modern Neural Networks. C. Guo, G. Pleiss, Y. Sun, and K. Q. Weinberger.
8. On Calibration of Modern Neural Networks. C. Guo, G. Pleiss, Y. Sun, and K. Q. Weinberger.
ICML 2017. ([link](https://geoffpleiss.com/nn_calibration))
22 changes: 14 additions & 8 deletions demos/embeddings/README.md
@@ -1,34 +1,40 @@
## Representation Learning Examples

This folder contains three [Jupyter](http://jupyter.org/) python notebooks demonstrating the use of unsupervised graph representation learning methods implemented in the `stellargraph` library for homogeneous and hetrogenous graphs with or without node features. The original works are referenced below.
This folder contains three [Jupyter](http://jupyter.org/) python notebooks demonstrating the use of unsupervised graph representation learning methods implemented in the `stellargraph` library for homogeneous and hetrogenous graphs with or without node features. The original works are referenced below.

**Node2Vec** and **Metapath2Vec** notebooks demonstrate the combined use of `stellargraph` and `Gensim` [4] libraries for representation learning on homogeneous and heterogeneous graphs.
**Node2Vec** and **Metapath2Vec** notebooks demonstrate the combined use of `stellargraph` and `Gensim` [4] libraries for representation learning on homogeneous and heterogeneous graphs.
**Unsupervised GraphSAGE** notebook demonstrates the use of `Stellargraph` library's GraphSAGE implementation for unsupervised learning of node embeddings for homogeneous graphs with node features.
**attri2vec** notebook demonstrates the implementation of attri2vec with the `Stellargraph` library for unsupervised inductive learning of node embeddings for homogeneous graphs with node features, and the evaluation for its ability to infer the representations of out-of-sample nodes with the out-of-sample node link prediction task.

The notebooks demonstrate the following algorithms.
- `stellargraph-node2vec.ipynb` The **Node2Vec** algorithm [1] for representation learning on homogeneous graphs
- `stellargraph-metapath2vec.ipynb` The **Metapath2Vec** algorithm [2] for representation learning on heterogeneous graphs.
- `embeddings-unsupervised-graphsage-cora.ipynb` The **Unsupervised GraphSAGE** algorithm [5] for representation learning on homogeneous graphs with node features.
- `stellargraph-attri2vec-citeseer.ipynb` The **attri2vec** algorithm [6] for representation learning on the homogeneous graph citeseer with node features.
- `stellargraph-attri2vec-DBLP.ipynb` The **attri2vec** algorithm [6] for representation learning on the homogeneous graph DBLP with node features.

All examples demonstrate how to calculate embedding vectors for a graph's nodes in just a few lines of Python code.
All examples demonstrate how to calculate embedding vectors for a graph's nodes in just a few lines of Python code.
The learned node representations can be used in numerous downstream tasks such as node attribute inference, link
prediction, and community detection.


## References

**1.** Node2Vec: Scalable Feature Learning for Networks. A. Grover, J. Leskovec. ACM SIGKDD International Conference
**1.** Node2Vec: Scalable Feature Learning for Networks. A. Grover, J. Leskovec. ACM SIGKDD International Conference
on Knowledge Discovery and Data Mining (KDD), 2016. ([link](https://snap.stanford.edu/node2vec/))

**2.** Metapath2Vec: Scalable Representation Learning for Heterogeneous Networks. Yuxiao Dong, Nitesh V. Chawla, and
Ananthram Swami. ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD), 135–144, 2017.
**2.** Metapath2Vec: Scalable Representation Learning for Heterogeneous Networks. Yuxiao Dong, Nitesh V. Chawla, and
Ananthram Swami. ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD), 135–144, 2017.
([link](https://ericdongyx.github.io/papers/KDD17-dong-chawla-swami-metapath2vec.pdf))

**3.** Distributed representations of words and phrases and their compositionality. T. Mikolov, I. Sutskever, K. Chen,
G. S. Corrado, and J. Dean. In Advances in Neural Information Processing Systems (NIPS), pp. 3111-3119, 2013.
**3.** Distributed representations of words and phrases and their compositionality. T. Mikolov, I. Sutskever, K. Chen,
G. S. Corrado, and J. Dean. In Advances in Neural Information Processing Systems (NIPS), pp. 3111-3119, 2013.
([link](https://papers.nips.cc/paper/5021-distributed-representations-of-words-and-phrases-and-their-compositionality.pdf))

**4.** Gensim: Topic modelling for humans. ([link](https://radimrehurek.com/gensim/))

**5.** Inductive Representation Learning on Large Graphs. W.L. Hamilton, R. Ying, and J. Leskovec arXiv:1706.02216
[cs.SI], 2017. ([link](http://snap.stanford.edu/graphsage/))

**6.** Attributed Network Embedding via Subspace Discovery. D. Zhang, Y. Jie, X. Zhu and C. Zhang, arXiv:1901.04095,
[cs.SI], 2019. ([link](https://arxiv.org/abs/1901.04095))