-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Labels
Description
We should give a full standalone code example in the README, including evaluation.
Spinoff from #12. The example I gave there is this (slightly reworked to take advantage of a7121f8):
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)
evaluation = linkpred.evaluation.EvaluationSheet(simrank_results, test.edges())
plt.plot(evaluation.recall(), evaluation.precision())