def load_graph(params): """ params: data file path Return: en2oid: the dictionary mapping str to original id tag2oid: the dictionary mapping str to original id edge_lst: entity relations mix_edge_lst: entity and tag relations """ en2oid = dh.load_name(os.path.join(params["name"], params["entity"])) tag2oid = dh.load_name(os.path.join(params["name"], params["tag"])) edge_lst = dh.load_edge(os.path.join(params["name"], params["edge"])) mix_edge_lst = dh.load_edge(os.path.join(params["name"], params["mix_edge"])) return en2oid, tag2oid, edge_lst, mix_edge_lst
def metric(params, info, pre_res, **kwargs): res = params_handler(params, info) mus = dh.load_as_pickle(params["mus"]) sigs = dh.load_as_pickle(params["sigs"]) std_sigs = np.sqrt(sigs) row2name = dh.load_name( os.path.join(info["network_folder"]["name"], info["network_folder"]["tag"])) assert len(mus) > 0, "The mus file has no data" N = len(mus) M = len(mus[0]) # sigs is spherical or diagonal if len(std_sigs[0]) == 1: ones = np.ones_like(mus) tmp = std_sigs.reshape(N, 1) std_sigs = ones * tmp # dimension reduction if M > 2: mus, std_sigs = ct.reduce_dist_dim(mus, std_sigs, 2) if params["draw_ellipse"]: res["res_path"] = os.path.join(params["res_home"], "dist_ellipse.pdf") dg.draw_ellipse(mus, std_sigs, row2name, res["res_path"], params["timesOfSigma"], params["filter"], params["notation"]) else: res["res_path"] = os.path.join(params["res_home"], "dist_scatter.pdf") dg.draw_scatter(mus, std_sigs, row2name, res["res_path"], params["timesOfSigma"], params["filter"], params["notation"]) res["scatter_path"] = os.path.join(params["res_home"], "scatter.pdf") dg.draw_scatter(mus, std_sigs, row2name, res["scatter_path"]) return res