Skip to content
Snippets Groups Projects
Commit ac8806e1 authored by Fize Jacques's avatar Fize Jacques
Browse files

Debug Node2vec

parent c2b03d9b
No related branches found
No related tags found
No related merge requests found
......@@ -42,11 +42,12 @@ log("Building link prediction dataset...")
# Create an evaluator and generate train/test edge split
traintest_split = LPEvalSplit()
try:
traintest_split.compute_splits(G, split_alg="spanning_tree", train_frac=args.train_frac, fe_ratio=1)
traintest_split.compute_splits(G, split_alg="random", train_frac=args.train_frac, fe_ratio=1)
except ValueError:
traintest_split.compute_splits(G, split_alg="fast", train_frac=args.train_frac, fe_ratio=1)
print("BEFORE", len(traintest_split.test_edges))
nee = LPEvaluator(traintest_split)
print("AFTER",len(traintest_split.test_edges))
log("Dataset Built !")
# Create a Scoresheet to store the results
......@@ -93,9 +94,12 @@ if args.network_embedding:
pbar = tqdm(enumerate(methods), disable=(not args.verbose))
for i,method in pbar:
pbar.set_description("Evaluate "+method)
is_weighted = nx.is_weighted(G)
command = commands[i] + " --input {} --output {} --representation-size {}"
if is_weighted:
command = command + " --weighted"
results = nee.evaluate_cmd(method_name=methods[i], method_type='ne', command=command,
edge_embedding_methods=edge_emb, input_delim=' ', output_delim=' ', verbose=args.verbose,write_weights=nx.is_weighted(G))
edge_embedding_methods=edge_emb, input_delim=' ', output_delim=' ', verbose=args.verbose,write_weights=is_weighted)
scoresheet.log_results(results)
except ImportError:
......
......@@ -18,7 +18,7 @@ args = parser.parse_args()
GRAPH_SIZE = [80,800]
EDGE_SIZE = [2,3]
EDGE_SIZE = [2,4,5]
sample_per_params = 4
OUTPUT_DIR = args.output_dir
......
......@@ -16,6 +16,7 @@ parser.add_argument("dataset_dir")
parser.add_argument("output_filename")
parser.add_argument("-f", "--format", default="gexf", choices=["gexf", "gml", "txt"])
parser.add_argument("-t","--train-frac",default=0.9,type=float)
parser.add_argument("-v","--verbose",action="store_true")
args = parser.parse_args()
fns = sorted(glob.glob(args.dataset_dir + "/*." + args.format))
......@@ -24,9 +25,9 @@ all_res = []
pbar = tqdm(fns)
for fn in pbar:
pbar.set_description("run eval on "+ fn)
verbose_cmd = "-v" if args.v else ""
if not os.path.exists(fn + "_results_lp"):
command = "python evalNE_script.py {0} -f {1} -n --train-frac {2}".format(fn, args.format,args.train_frac).split()
command = "python evalNE_script.py {0} -f {1} -n --train-frac {2} {3}".format(fn, args.format,args.train_frac,verbose_cmd).split()
output = subprocess.run(command)
if not output.returncode == 0:
print("Error! for the command :", " ".join(command))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment