Closed DinosL closed 5 years ago
Apparently i am using the ROCPlotter function wrong but i cannot find anything helpful anywhere.
Sorry for replying late.
Short answer is that you cannot really use ROCPlotter
this way. It will only 'do' things if it receives signals. Currently these are sent in LinkPred.process_predictions
. This has turned out to be a bad choice but it would require quite some effort to rework this.
That being said, a basic ROC plot can quite easily be obtained this way:
plt.plot(evaluation.fallout(), evaluation.recall()
Does that help?
No. I am using the code above with your suggestion and i get the Measure is undefined if universe is unknown
error. My input file is an .edgelist file with the following format
0 1
2 1
3 1
...
Ah yes, for ROC plots (specifically for 'fallout' or false positive rate, the values on the horizontal axis) we need to know the total number of possibilities, in order to calculate the number of true negatives (non-edges in the test network that are not predicted).
If I understand your setup correctly, you can achieve this by changing the last few lines as follows:
# Determine 'universe', number of all possible edges that could be predicted
n = len(test)
num_universe = n * (n - 1) // 2
test_set = set(linkpred.evaluation.Pair(u, v) for u, v in test.edges())
evaluation = linkpred.evaluation.EvaluationSheet(cn_results, test_set, num_universe)
plt.plot(evaluation.fallout(), evaluation.recall())
plt.show()
The code you provided does the job. Thank you for your help.
I followed the example provided #12 using an edgelist as input and common neighbours as predictor but the roc plot is empty. Maybe i dont pass the correct arguments to ROCPlotter but i couldn't find any example.My code is this
Any suggestion? Thank you in advance