-
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
Complete example #12
Comments
Hi, unfortunately this is a bit ugly and I would like to rework the whole evaluation logic at some point to use scikit-learn's implementation of evaluation measures. That being said, here is a full example: import linkpred
import random
from matplotlib import pyplot as plt
random.seed(100)
# Read network
G = linkpred.read_network('examples/inf1990-2004.net')
# Create test network
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)
test_set = set(linkpred.evaluation.Pair(u, v) for u, v in test.edges())
evaluation = linkpred.evaluation.EvaluationSheet(simrank_results, test_set)
plt.plot(evaluation.recall(), evaluation.precision()) Note that the |
Things to do here:
|
I followed @rafguns example but got a key error message: KeyError Traceback (most recent call last) ~\Anaconda3\lib\site-packages\linkpred\predictors\base.py in predict_and_postprocess(*args, **kwargs) ~\Anaconda3\lib\site-packages\linkpred\predictors\eigenvector.py in predict(self, c, num_iterations, weight) ~\Anaconda3\lib\site-packages\networkx\classes\reportviews.py in getitem(self, n) KeyError: 0 |
Thanks for pointing that out, @menghaoli001. At first sight, I think this is due to changes in networkx 2.x, where |
@menghaoli001 I spun the issue you mention off into a separate bug (#15), which has now been fixed on master. |
i have linkpred & dataset(test and train) , I want to convert dataset(just a part, inf_test_0) to list with python , and i want to account score precision ,auc-roc ,graph,table, (fp,fn,tp,tn) if you can send me the full exemple with source code as soon as possible , with all my respects. |
Not sure if I fully understand your question, especially the part about "convert dataset(just a part, inf_test_0) to list." Can you show me (part of) the dataset you have (e.g. post it as gist)? Precision, ROC, and (tp, tn, fp, fn) tables are in linkpred. AUC currently is not. Not sure what you mean by "graph" in this context - some kind of visualization? Linkpred does not do that but if you have a |
thank you for help , i find what i need in this site "
http://scikit-learn.org/stable/auto_examples/model_selection/plot_roc.html#sphx-glr-auto-examples-model-selection-plot-roc-py
"
but i have another question how to account top100 , seuil and arragement ,
2018-06-05 10:52 GMT+02:00 rafguns <notifications@github.com>:
… Not sure if I fully understand your question, especially the part about
"convert dataset(just a part, inf_test_0) to list." Can you show me (part
of) the dataset you have (e.g. post it as gist)?
Precision, ROC, and (tp, tn, fp, fn) tables are in linkpred. AUC currently
is not. Not sure what you mean by "graph" in this context - some kind of
visualization? Linkpred does not do that but if you have a nx.Graph, you
can always draw it with nx.draw(G). That being said, networkx's
visualization capacities are relatively limited and sometimes it is more
useful to save the file to disk and use sofwtare like Gephi for
visualization.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Al7SeN1XKnUmXAB953Zi7-VPuHYrEO0zks5t5ka0gaJpZM4NER3p>
.
|
hi! i am also trying to predict new connections in my network file and i would like to ask how i can use other techniques such as jaccard or adamic adar, and not only simrank. thanks in advance! |
@bk3karim could you perhaps share how you succeeded with the scikit-learn website link? |
@intStdu It works the same way for other predictors. That is, these lines:
can be replaced with (e.g.):
The only difference between predictors is that their |
hi how are , there are another methods divided to 3 part
you can used common neighbors , cosine .......in local methods for get good
result.
2018-06-25 13:01 GMT+02:00 rafguns <notifications@github.com>:
… @intStdu <https://github.com/intStdu> It works the same way for other
predictors. That is, these lines:
simrank = linkpred.predictors.SimRank(training, excluded=training.edges())
simrank_results = simrank.predict(c=0.5)
can be replaced with (e.g.):
jaccard = linkpred.predictors.Jaccard(G, excluded=test.edges())
jaccard_results = jaccard.predict()
The only difference between predictors is that their predict methods
sometimes take additional parameters.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Al7SeO7DzMg5mVmnd3rlt-CsAa9evmqZks5uAML5gaJpZM4NER3p>
.
|
for the work afer and i share't
2018-06-25 22:41 GMT+02:00 bouatmane abdelkrim <bk3.karim@gmail.com>:
… hi how are , there are another methods divided to 3 part
you can used common neighbors , cosine .......in local methods for get
good result.
2018-06-25 13:01 GMT+02:00 rafguns ***@***.***>:
> @intStdu <https://github.com/intStdu> It works the same way for other
> predictors. That is, these lines:
>
> simrank = linkpred.predictors.SimRank(training, excluded=training.edges())
> simrank_results = simrank.predict(c=0.5)
>
> can be replaced with (e.g.):
>
> jaccard = linkpred.predictors.Jaccard(G, excluded=test.edges())
> jaccard_results = jaccard.predict()
>
> The only difference between predictors is that their predict methods
> sometimes take additional parameters.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#12 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/Al7SeO7DzMg5mVmnd3rlt-CsAa9evmqZks5uAML5gaJpZM4NER3p>
> .
>
|
hi @rafguns i used your linkpred package for my bachelor thesis, how could i cite your work best to your preference? I work with bibtex! |
@intStdu Thanks, good question. The best way is probably to cite this book chapter, which is a basic introduction to link prediction using linkpred (open access version). |
I am going to close this issue, because its focus has become unclear. I will file separate issues for the oustanding items from #12 (comment). |
AssertionError Traceback (most recent call last) d:\for_python_3.7\lib\site-packages\linkpred\predictors\base.py in predict_and_postprocess(*args, **kwargs) d:\for_python_3.7\lib\site-packages\linkpred\evaluation\scoresheet.py in delitem(self, key) d:\for_python_3.7\lib\site-packages\linkpred\evaluation\scoresheet.py in init(self, *args) AssertionError: Predicted link (NARIN F, NARIN F) is a self-loop! how to deal with the problem of self-loop? |
what database used
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Garanti
sans virus. www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
Le jeu. 2 mai 2019 à 12:23, LuckyCatSecret <notifications@github.com> a
écrit :
… AssertionError Traceback (most recent call last)
in
16
17 simrank = linkpred.predictors.SimRank(training,
excluded=training.edges())
---> 18 simrank_results = simrank.predict(c=0.5)
19
20 test_set = set(linkpred.evaluation.Pair(u, v) for u, v in test.edges())
d:\for_python_3.7\lib\site-packages\linkpred\predictors\base.py in
predict_and_postprocess(*args, **kwargs)
65 for u, v in self.excluded:
66 try:
---> 67 del scoresheet[(u, v)]
68 except KeyError:
69 pass
d:\for_python_3.7\lib\site-packages\linkpred\evaluation\scoresheet.py in
*delitem*(self, key)
193
194 def *delitem*(self, key):
--> 195 return dict.*delitem*(self, Pair(key))
196
197 def process_data(self, data, weight='weight'):
d:\for_python_3.7\lib\site-packages\linkpred\evaluation\scoresheet.py in
*init*(self, *args)
125 "*init*() takes 1 or 2 arguments in addition to self")
126 # For link prediction, a and b are two different nodes
--> 127 assert a != b, "Predicted link (%s, %s) is a self-loop!" % (a, b)
128 self.elements = self._sorted_tuple((a, b))
129
AssertionError: Predicted link (NARIN F, NARIN F) is a self-loop!
how to deal with the problem of self-loop?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJPNE6FZOMVXNG5PKLFUDW3PTK6I3ANCNFSM4DIRDXUQ>
.
|
i find what i need thank you for help , if you need need any thing tell me
|
Hi I am unable to run SimRank for a given graph. Can you please help me. I am using lates anaconda. But there is a unicode error while reading a graph. |
Can you show what you are doing (code+data) and which error you encounter? |
But my taks is given a list of edges from a text file. And apply Simrank for all pairs until converge. |
That error has nothing to do with linkpred. It is because the backslahes in your string are interpreted as escape sequences, see https://docs.python.org/3/reference/lexical_analysis.html#literals. Either write |
Than You Sir.
regards
TR RAO
…On Thu, Aug 22, 2019 at 6:21 PM rafguns ***@***.***> wrote:
That error has nothing to do with linkpred. It is because the backslahes
in your string are interpreted as escape sequences, see
https://docs.python.org/3/reference/lexical_analysis.html#literals.
Either write "C:\\Users\\TR (etc.)" or writer"C:\Users\TR (etc.)".
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#12?email_source=notifications&email_token=AEGLRSN54XPSGG76QENAY33QF2DWVA5CNFSM4DIRDXU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD447K4Q#issuecomment-523892082>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEGLRSJ7DDTLMP4YTMDQGIDQF2DWVANCNFSM4DIRDXUQ>
.
|
I would like to use your link prediction library, but I am missing the complete example, including evaluation code. For now I have the following code:
Could you please provide full example, i.e., how to calculate precision, recall, ROC curve, etc.
The text was updated successfully, but these errors were encountered: