PacktPublishing / Hands-On-Graph-Neural-Networks-Using-Python

Hands-On Graph Neural Networks Using Python, published by Packt
MIT License
663 stars 181 forks source link

What does node2vec expect in .wv method? #5

Open chuymtz opened 1 year ago

chuymtz commented 1 year ago

Hello,

I;m working through chapter 4. In the prediction of the test set, you use train_mask_str in the book but in your gh code you use train_mask. Depending on which one you use one gets very different results.

if you pass the integer mask you get something that won't go pass 60% accuracy.

y_pred = clf.predict(node2vec.wv[test_mask])
acc = accuracy_score(y_pred, labels[test_mask])
print(f'Node2Vec accuracy = {acc*100:.2f}%')
>>>Node2Vec accuracy = 59.09%

But if i pass the string mask i get what you report both in gh and the book . Which seems really high considering how many samples you pick out in the train and test.

y_pred = clf.predict(node2vec.wv[test_mask_str])
acc = accuracy_score(y_pred, labels[test_mask])
print(f'Node2Vec accuracy = {acc*100:.2f}%')
>>>Node2Vec accuracy = 95.45%

How can one explain this discrepancy?

mlabonne commented 10 months ago

Hi, sorry for the very late reply! Thank you for noticing this discrepancy between the book and the code. Unfortunately, I can't replicate your issue. The data type should not matter here because it's masking the same nodes.

chuymtz commented 10 months ago

No problem. thanks you for the reply (and amazing book). I think this is more of an issue with node2vec. I'll take what I learned conceptually and move on 😊 thanks!