-
Notifications
You must be signed in to change notification settings - Fork 46
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
AssertionError with self-loops from Python but not from command line #26
Comments
Thanks for the report. Very strange, I'll have to investigate more... |
Thanks for the fast response ! |
Got it working by removing self-loop edges before calling the predictor. The accuracy is not good though but I don't have any comparison point so I can't say if the bad accuracy is a consequence of this fix. Here is the code: G = linkpred.read_network("training.net")
# This line is the fix to avoid the AssertionError
G.remove_edges_from(G.selfloop_edges())
test = G.subgraph(random.sample(G.nodes(), 300))
# Exclude test network from learning phase
training = G.copy()
training.remove_edges_from(test.edges())
simrank = linkpred.predictors.SimRank(training, excluded=training.edges())
simrank_results = simrank.predict(c=0.5)
evaluation = linkpred.evaluation.EvaluationSheet(simrank_results, test.edges())
plt.plot(evaluation.recall(), evaluation.precision()) |
Ah, this is the code I gave as an example in #18, right? If your data contains self-loops, you should indeed remove them. If you call linkpred from the command-line, it will do something similar. Low accuracy indicates that this predictor does not work well on your data but has nothing to do with the self-loops. You may want to try experimenting with a few of the other predictors to see if they give better results. |
I think this can be closed, but please reopen if there is still an issue here relating to the self-loops. Thanks! |
The code given in the README is issuing a
AssertionError: Predicted link (981, 981) is a self-loop!
, but the terminal command with the exact same training file is doing the job.The text was updated successfully, but these errors were encountered: