Deepwalk在线学习社会表现。
deepwalk的Python项目详细描述
deepwalk使用短随机游动来学习图中顶点的表示。
用法
- 示例用法
- $deepwalk --input example_graphs/karate.adjlist --output karate.embeddings
–输入:输入文件名
^{tt2}$ for an adjacency list, e.g:
1 2 3 4 5 6 7 8 9 11 12 13 14 18 20 22 32 2 1 3 4 8 14 18 20 22 31 3 1 2 4 8 9 10 14 28 29 33 ...^{tt3}$ for an edge list, e.g:
1 2 1 3 1 4 ...
- ^{tt4}$ for a Matlab .mat file containing an adjacency matrix
(note, you must also specify the variable name of the adjacency matrix ^{tt5}$)
–输出:output_filename
The output representations in skipgram format - first line is header, all other lines are node-id and d dimensional representation:
34 64 1 0.016579 -0.033659 0.342167 -0.046998 ... 2 -0.007003 0.265891 -0.351422 0.043923 ... ...
- full命令列表
- 命令行选项的完整列表可用于$deepwalk --help
评估
在这里,我们将展示如何在deepwalk paper中使用的blogcatalog数据集上评估deepwalk。 首先,我们运行以下命令以生成其deepwalk嵌入:
deepwalk --format mat --input example_graphs/blogcatalog.mat --max-memory-data-size 0 --number-walks 80 --representation-size 128 --walk-length 40 --window-size 10 --workers 1 --output example_graphs/blogcatalog.embeddings
此处指定的参数与论文中的参数相同。 如果您使用的是多核机器,请尝试将--workers设置为更大的数字,以便更快地进行训练。 在具有24个xeon e5-2620@2.00ghz CPU的单机上,此命令大约需要20分钟才能完成(--workers设置为20)。 然后,我们使用example_graphs/scoring.py:
评估多标签节点分类任务中学习到的嵌入。python example_graphs/scoring.py --emb example_graphs/blogcatalog.embeddings --network example_graphs/blogcatalog.mat --num-shuffle 10 --all
此命令在同一台计算机上8分钟后完成。为了更快地计算,您可以将--num-shuffle设置为较小的数字,但期望性能有更大的波动。不同标记节点比例得到的微观f1和宏观f1得分如下:
% Labeled Nodes | 10% | 20% | 30% | 40% | 50% | 60% | 70% | 80% | 90% |
---|---|---|---|---|---|---|---|---|---|
Micro-F1 (%) | 35.86 | 38.51 | 39.96 | 40.76 | 41.51 | 41.85 | 42.27 | 42.35 | 42.40 |
Macro-F1 (%) | 21.08 | 23.98 | 25.71 | 26.73 | 27.68 | 28.28 | 28.88 | 28.70 | 28.21 |
请注意,当前版本的deepwalk基于较新版本的gensim,它可能具有word2vec模型的不同实现。要完全复制本文中的结果,您可能需要安装较旧版本的gensim(版本0.10.2)。
要求
- 努比
- scipy
(可能必须独立安装)
安装
- CD deepwalk
- pip install-r requirements.txt
- python setup.py安装
引用
如果您发现deepwalk对您的研究有用,我们请您引用以下论文:
@inproceedings{Perozzi:2014:DOL:2623330.2623732, author = {Perozzi, Bryan and Al-Rfou, Rami and Skiena, Steven}, title = {DeepWalk: Online Learning of Social Representations}, booktitle = {Proceedings of the 20th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining}, series = {KDD '14}, year = {2014}, isbn = {978-1-4503-2956-9}, location = {New York, New York, USA}, pages = {701--710}, numpages = {10}, url = {http://doi.acm.org/10.1145/2623330.2623732}, doi = {10.1145/2623330.2623732}, acmid = {2623732}, publisher = {ACM}, address = {New York, NY, USA}, keywords = {deep learning, latent representations, learning with partial labels, network classification, online learning, social networks}, }
历史记录
1.0.3(2018-03-23)
- 现在与最新版本的Gensim和Sklearn兼容
- 更好地支持Python3
1.0.2(2014-09-19)
- 固定gensim为0.10.2
1.0.1(2014-09-19)
- 添加实用程序以支持为较大图形生成的嵌入
- 支持其他输入文件格式
1.0.0(2014-08-24)
- pypi上的第一个版本。