palash1992 / GEM

BSD 3-Clause "New" or "Revised" License
1.28k stars 362 forks source link

Use of Link prediction code #87

Open alimuham1 opened 4 years ago

alimuham1 commented 4 years ago

I want to use the link prediction code with my own embedding methods. Could you please explain me how i would use this.

I am using cora edgelist as dataset, and i have generated embeddings with the help of deepwalk method and now i want to try the task of link prediction.

Is it possible that i could use your link prediction file to generate the accuracy score. Sorry, may be i am bit confuse to use your code for my link prediction task.

Any help would be a great favor for me.

Thanks

XiHaKitty commented 4 years ago

Hello The problem I urgently need to solve is exactly similar to your goal. I generated the embedding in another way. I need to solve the task of link prediction. Could you please solve it. Any answer will be of great help to me. Thank you

claudiodtbarros commented 4 years ago

I have solved issues regarding link prediction by changing the following files and the following lines:

  1. File /gem/utils/evaluation.util.py Line 40: for (st, ed, w) in di_graph.edges_iter(data='weight', default=1):

I have changed to for (st, ed, w) in list(di_graph.edges(data='weight', default=1)): Reason: As far as I have understood, edges_iter was removed after NetworkX 2.0.

  1. File /gem/evaluation/evaluate_link_prediction.py Line 67: filtered_edge_list = [e for e in predicted_edge_list if not train_digraph.has_edge(node_l(e[0]), node_l(e[1]))]

I have changed to filtered_edge_list = [e for e in predicted_edge_list if not train_digraph.has_edge(node_l[e[0]], node_l[e[1]])]

Reason: If node_l is None (line 65), then node_l is defined as a list (line 66). Therefore, as lists being not callable, one must use node_l[...], and not node_l(...). I have not tested link prediction for labeled graphs yet.

Best regards!