From 9ee35151415dc70935e94a270fbbceb0ede59891 Mon Sep 17 00:00:00 2001 From: Fize Jacques <jacques.fize@cirad.fr> Date: Tue, 13 Apr 2021 10:29:53 +0200 Subject: [PATCH] debug --- eval_mixed_model.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/eval_mixed_model.py b/eval_mixed_model.py index 54cce18..36a16b4 100644 --- a/eval_mixed_model.py +++ b/eval_mixed_model.py @@ -49,7 +49,7 @@ NB_COM = args.nb_com NB_ITERATION = args.nb_iterations VERBOSE = args.verbose FEATURES = set(args.features.split(",")) - +TIMEOUT = 60 dist = lambda a,b : np.linalg.norm(a-b)**2 hash_func = lambda x:"_".join(sorted([str(x[0]),str(x[1])])) @@ -58,9 +58,12 @@ def get_aucs(G): traintest_split = LPEvalSplit() traintest_split.compute_splits(H, split_alg="spanning_tree", train_frac=0.90, fe_ratio=1) nee = LPEvaluator(traintest_split) - - auc_spatial = nee.evaluate_baseline(method="spatial_link_prediction").test_scores.auroc() - auc_sbm = nee.evaluate_baseline(method="stochastic_block_model").test_scores.auroc() + auc_spatial, auc_sbm = 0, 0 + try: + auc_spatial = nee.evaluate_baseline(method="spatial_link_prediction",timeout=TIMEOUT).test_scores.auroc() + auc_sbm = nee.evaluate_baseline(method="stochastic_block_model",timeout=TIMEOUT).test_scores.auroc() + except: + print("Could not compuyte AUC ! ") return auc_sbm,auc_spatial dist = lambda a,b : np.linalg.norm(a-b) @@ -82,7 +85,6 @@ block_assign = nx.get_node_attributes(G,"block") H = G.copy() float_epsilon = np.finfo(float).eps df_data["p_0"] = df_data.apply(lambda x:1 if G.has_edge(x.u,x.v) else 0,axis =1) -print(df_data) for i in range(1,NB_ITERATION+1): old_probs = dict(df_data["hash_ p_{0}".format(i-1).split()].values) auc_sbm,auc_spatial = get_aucs(H) @@ -116,7 +118,7 @@ for i in range(1,NB_ITERATION+1): G2.nodes[n]["pos"] = pos[n] H=G2.copy() - +if VERBOSE:print(df_data) edge_feature= {hash_func([int(row.u),int(row.v)]):[row["p_{0}".format(i)] for i in range(1,NB_ITERATION+1)] for ix,row in df_data.iterrows()} G, _ = pp.prep_graph(G,maincc=True) -- GitLab