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

implement faster Node2Vec with scipy and numba. #51

Merged
merged 1 commit into from
Mar 19, 2021

Conversation

EdisonLeeeee
Copy link
Contributor

I improve the code of Node2Vec and remove the requirement of node2vec==0.3.2.
The implement is based on scipy and numba, which is 10x faster than before. See the following comparison:

Node2Vec in node2vec:

  • before attack
%%time
model = Node2Vec()
model.fit(adj)
model.evaluate_node_classification(labels, idx_train, idx_test)

Computing transition probabilities: 100%|██████████| 2810/2810 [00:01<00:00, 1542.39it/s]
Micro F1: 0.8091637010676157
Macro F1: 0.7912831590583134
Wall time: 47.9 s
  • after attack
%%time
model = Node2Vec()
model.fit(modified_adj)
model.evaluate_node_classification(labels, idx_train, idx_test)

Computing transition probabilities: 100%|██████████| 2810/2810 [00:02<00:00, 1002.49it/s]
Micro F1: 0.7415480427046264
Macro F1: 0.7106148220982006
Wall time: 41.1 s

Now

  • before attack
%%time
model = Node2Vec()
model.fit(adj)
model.evaluate_node_classification(labels, idx_train, idx_test)

Micro F1: 0.8207295373665481
Macro F1: 0.7911009841941256
Wall time: 5.48 s
  • after attack
%%time
model = Node2Vec()
model.fit(modified_adj)
model.evaluate_node_classification(labels, idx_train, idx_test)

Micro F1: 0.75711743772242
Macro F1: 0.7171709903118675
Wall time: 4.12 s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants