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
def get_features(params, info, **kwargs): res = params_handler(params, info) return dh.load_as_pickle(params["file_path"])