thunlp / OpenNE

An Open-Source Package for Network Embedding (NE)
MIT License
1.68k stars 485 forks source link

why p=1 and q=1 (node2vec) performs much worse than deepwalk #64

Closed zhjzh1016 closed 5 years ago

zhjzh1016 commented 5 years ago

Hello, I apply node2vec method in a citation network generated myself. I want to compare the deepwalk and node2vec. In my opinion, the node2vec is better than deepwalk, but I have tried lots of p, q, the performance is not as good as deepwalk. When I set p and q to 1, the performance is much worse than deepwalk, but in fact, in this case it equals to deepwalk. The result shows below, both p and q equal 1, and other parameters are the same. I dont know why, could you please give me some advice, Thank you. start deepwalk starting computing RPrecision 1 in top 2 is 0.500000 2 in top 4 is 0.500000 4 in top 6 is 0.666667 5 in top 8 is 0.625000 5 in top 10 is 0.500000 6 in top 20 is 0.300000 11 in top 30 is 0.366667 17 in top 40 is 0.425000 21 in top 50 is 0.420000 37 in top 100 is 0.370000 182 in top 1000 is 0.182000 end deepwalk start node2vec starting computing RPrecision 1 in top 2 is 0.500000 1 in top 4 is 0.250000 1 in top 6 is 0.166667 1 in top 8 is 0.125000 1 in top 10 is 0.100000 1 in top 20 is 0.050000 1 in top 30 is 0.033333 2 in top 40 is 0.050000 5 in top 50 is 0.100000 22 in top 100 is 0.220000 139 in top 1000 is 0.139000 end node2vec

zzy14 commented 5 years ago

I think the difference between Deepwalk and node2vec (p=q=1) is that Deepwalk uses hierarchical softmax for training while node2vec uses negative sampling.

zhjzh1016 commented 5 years ago

I think the difference between Deepwalk and node2vec (p=q=1) is that Deepwalk uses hierarchical softmax for training while node2vec uses negative sampling.

Thanks. Can I change the negative sampling in node2vec to hierarchical softmax? If can, could you please tell me how.

zhjzh1016 commented 5 years ago

I think the difference between Deepwalk and node2vec (p=q=1) is that Deepwalk uses hierarchical softmax for training while node2vec uses negative sampling.

In OpenNE, I think both node2vec and deepwalk use the same model in word2vec (hierarchical softmax or negative sampling), so how to set different model for them repectively. I have not found the settings in sources.

zzy14 commented 5 years ago

You can change the arguments kwargs in node2vec.py.

zhjzh1016 commented 5 years ago

Thank you very much.