Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dongzy 2018-12-05 17:20:32 +08:00
commit 97fcf83cef
3 changed files with 69 additions and 53 deletions

17
.gitignore vendored
View File

@ -1,4 +1,10 @@
#chengbin--------------------------
# My configurations:
db.ini
deploy_key_rsa
log
bash
emb
# Windows:
Thumbs.db
ehthumbs.db
@ -13,15 +19,6 @@ dist
build
__pycache__
# My configurations:
db.ini
deploy_key_rsa
log
bash
emb
#zeyu--------------------------------
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]

104
README.md
View File

@ -1,42 +1,53 @@
# OpenANE: The first Open source framework specialized in Attributed Network Embedding (ANE)
We reproduce several ANE (Attributed Network Embedding) as well as PNE (Pure Network Embedding) methods in one unified framework, where they all share the same I/O and downstream tasks. We start this project based on [OpenNE](https://github.com/thunlp/OpenNE) that mainly integrates PNE methods under one unified framework.
# OpenANE: the first Open source framework specialized in Attributed Network Embedding (ANE)
We reproduce several ANE (Attributed Network Embedding) methods as well as PNE (Pure Network Embedding) methods in **one unified framework**, where they all share the same I/O, downstream tasks, etc. We start this project based on [OpenNE](https://github.com/thunlp/OpenNE) which mainly integrates PNE methods in one unified framework.
<br> OpenANE not only integrates those PNE methods that consider pure structural information, but also provides the state-of-the-art ANE methods that consider both structural and attribute information during embedding.
Authors: Chengbin HOU chengbin.hou10@foxmail.com & Zeyu DONG 2018
Authors: Chengbin HOU chengbin.hou10@foxmail.com & Zeyu DONG zeyu.dong@foxmail.com 2018
## Motivation
In many real-world scenarios, a network often comes with node attributes such as paper metadata in a citation network, user profiles in a social network, and even node degrees in any pure networks. Unfortunately, PNE methods cannot make use of attribute information that may further improve the quality of node embeddings.
<br> From engineering perspective, by offering more APIs to handle attribute information in graph.py and utils.py, OpenANE shall be very easy to use for embedding an attributed network. Except attributed networks, OpenANE can also deal with pure networks by calling PNE methods, or by assigning node degrees as node attributes and then calling ANE methods. Therefore, to some extent, ANE methods can be regarded as a generalization of PNE methods.
<br> From engineering perspective, by offering more APIs to handle attribute information in graph.py and utils.py, OpenANE shall be easy to use for embedding an attributed network. Except attributed networks, OpenANE can also deal with pure networks by calling PNE methods, or by assigning node degrees as node attributes and then calling ANE methods. Therefore, to some extent, ANE methods can be regarded as the generalization of PNE methods.
## Methods
ANE methods:
[ABRW](https://github.com/houchengbin/ABRW),
[SAGE-GCN](https://github.com/williamleif/GraphSAGE),
[SAGE-Mean](https://github.com/williamleif/GraphSAGE),
[ASNE](https://github.com/lizi-git/ASNE),
[TADW](https://github.com/thunlp/OpenNE),
[AANE](https://github.com/xhuang31/AANE_Python),
[SAGE-Mean](https://github.com/williamleif/GraphSAGE),
[SAGE-GCN](https://github.com/williamleif/GraphSAGE),
[TADW](https://github.com/thunlp/OpenNE),
AttrComb,
AttrPure <br>
PNE methods:
[DeepWalk](https://github.com/thunlp/OpenNE),
[Node2Vec](https://github.com/thunlp/OpenNE),
[LINE](https://github.com/thunlp/OpenNE),
[GraRep](https://github.com/thunlp/OpenNE),
AttrPure,
AttrComb
<br> Note: all NE methods in this framework are unsupervised, and so does not require any label during embedding phase.
[others](https://github.com/thunlp/OpenNE)
<br> All methods in this framework are **unsupervised**, and so do not require any label during embedding phase.
**For more details of each method, please have a look at our paper https://arxiv.org/abs/1811.11728**
<br> And if you find ABRW or this framework is useful for your research, please consider citing it.
For more details of each method, please have a look at our paper https://arxiv.org/abs/1811.11728. And if you find ABRW or this framework is useful for your research, please consider citing it.
```
@article{hou2018abrw,
title={Attributed Network Embedding for Incomplete Structure Information},
author={Hou, Chengbin and He, Shan and Tang, Ke},
journal={arXiv preprint arXiv:1811.11728},
year={2018}
}
```
## Usages
#### Requirements
```bash
cd OpenANE
pip install -r requirements.txt
```
Python 3.6.6 or above is required due to the new [*print(f' ')*](https://docs.python.org/3.6/reference/lexical_analysis.html#f-strings) feature
Python 3.6.6 or above is required due to the new [`print(f' ')`](https://docs.python.org/3.6/reference/lexical_analysis.html#f-strings) feature
#### To obtain node embeddings as well as evaluate the quality
```bash
python src/main.py --method abrw --emb-file emb/cora_abrw_emb --save-emb --task lp_and_nc
python src/main.py --method abrw --task lp_and_nc --emb-file emb/cora_abrw_emb --save-emb
```
#### To have an intuitive feeling in node embeddings
```bash
@ -46,46 +57,54 @@ python src/vis.py --emb-file emb/cora_abrw_emb --label-file data/cora/cora_label
## Testing (Cora)
### Parameter Settings
In this testing, we use the default parameters
The default parameters for SAGE-GCN and SAGE-Mean are in *src/libnrl/graphsage/\__init\__.py*. And for other parameters:
| AANE_lamb | AANE_maxiter | AANE_rho | ABRW_alpha | ABRW_topk | ASNE_lamb | AttrComb_mode | GraRep_kstep | LINE_negative_ratio | LINE_order | Node2Vec_p | Node2Vec_q | TADW_lamb | TADW_maxiter | batch_size | dim | dropout | epochs | label_reserved | learning_rate | link_remove | number_walks | walk_length | weight_decay | window_size | workers |
|-----------|--------------|----------|------------|-----------|-----------|---------------|--------------|---------------------|------------|------------|------------|-----------|--------------|------------|-----|---------|--------|----------------|---------------|-------------|--------------|-------------|--------------|-------------|---------|
| 0.05 | 10 | 5 | 0.8 | 30 | 1 | concat | 4 | 5 | 3 | 0.5 | 0.5 | 0.2 | 10 | 128 | 128 | 0.5 | 100 | 0.7 | 0.001 | 0.1 | 10 | 80 | 0.0001 | 10 | 24 |
### Testing Results
#### Link Prediction and Node Classification tasks:
#### Link Prediction (LP) and Node Classification (NC) tasks:
STEPS: Cora -> NE method -> node embeddings -> (downstream) LP/NC -> scores
| method | AUC | Micro-F1 | Macro-F1 | Time |
|----------|--------|----------|----------|----------|
| aane | 0.8158 | 0.7263 | 0.6904 | 26.48 |
| abrw | 0.9290 | 0.8721 | 0.8603 | 48.94 |
| asne | 0.7842 | 0.6076 | 0.5649 | 69.67 |
| attrcomb | 0.9111 | 0.8444 | 0.8284 | 60.32 |
| attrpure | 0.7857 | 0.7349 | 0.7039 | 0.49 |
| deepwalk | 0.8499 | 0.8100 | 0.8021 | 75.15 |
| grarep | 0.8936 | 0.7669 | 0.7607 | 10.31 |
| line | 0.6945 | 0.5873 | 0.5645 | 259.02 |
| node2vec | 0.7938 | 0.7977 | 0.7858 | 29.42 |
| sagegcn | 0.8929 | 0.7780 | 0.7622 | 207.49 |
| sagemean | 0.8882 | 0.8057 | 0.7902 | 183.65 |
| tadw | 0.9005 | 0.8383 | 0.8255 | 10.73 |
| Method | AUC (LP) | Micro-F1 (NC) | Macro-F1 (NC) |
|----------|--------|----------|----------|
| aane | 0.8081 | 0.7296 | 0.6941 |
| abrw | 0.9376 | 0.8612 | 0.8523 |
| asne | 0.7728 | 0.6052 | 0.5656 |
| attrcomb | 0.9053 | 0.8446 | 0.8318 |
| attrpure | 0.7993 | 0.7368 | 0.7082 |
| deepwalk | 0.8465 | 0.8147 | 0.8048 |
| grarep | 0.8935 | 0.7632 | 0.7529 |
| line | 0.6930 | 0.6130 | 0.5949 |
| node2vec | 0.7935 | 0.7938 | 0.7856 |
| sagegcn | 0.8926 | 0.7964 | 0.7828 |
| sagemean | 0.8948 | 0.7899 | 0.7748 |
| tadw | 0.8877 | 0.8442 | 0.8321 |
*We take the average of six runs. During embedding phase, 10% links are removed. During downstream phase, the removed 10% links and the equal number of non-existing links are used for LP testing; and 30% of labels are used for NC testing.
#### 2D Visualization task:
STEPS: Cora -> NE method -> node embeddings -> (downstream) PCA to 2D -> vis
#### 2D Visualization task
<br> ![Cora vis](https://github.com/houchengbin/OpenANE/blob/master/log/vis.jpg) <br>
<br> Steps: Cora -> NE method -> node embeddings -> PCA -> 2D vis
<br> The different colors indicate different ground truth labels.
*The different colors indicate different ground truth labels.
## Other Datasets
More well-prepared (attributed) network datasets are available at [NetEmb-Datasets](https://github.com/houchengbin/NetEmb-Datasets)
### Your Own Dataset
*--------------- Structural Info (each row) --------------------*
adjlist: node_id1 node_id2 node_id3 ... (neighbors of node_id1)
or edgelist: node_id1 node_id2 weight (weight is optional)
*--------------- Attribute Info (each row) ---------------------*
node_id1 attr1 attr2 ...
*--------------- Label Info (each row) -------------------------*
node_id1 label1 label2 ...
```
*--------------- Structural Info (each row) --------------------*
adjlist: node_id1 node_id2 node_id3 ... (neighbors of node_id1)
or edgelist: node_id1 node_id2 weight (weight is optional)
*--------------- Attribute Info (each row) ---------------------*
node_id1 attr1 attr2 ...
*--------------- Label Info (each row) -------------------------*
node_id1 label1 label2 ...
```
### Parameter Tuning
For different dataset, one may need to search the optimal parameters instead of taking the default parameters.
@ -93,8 +112,7 @@ For the meaning and suggestion of each parameter, please see main.py.
## Contribution
We highly welcome and appreciate your contribution on fixing bugs, reproducing new ANE methods, etc. And we hope this OpenANE framework would become influential on both academic research and industrial usage.
We highly welcome and appreciate your contribution in fixing bugs, reproducing new ANE methods, etc. Please use the *pull requests* and your contribution will automatically appear in this project once accepted. We will add you to authors list, if your contribution is significant to this project.
## References
todo...
To do...

View File

@ -0,0 +1 @@
# where your node embeddings can be stored under this file