return B #%% import pandas as pd from src.io import readcsv alphas = np.geomspace(0.0005, 0.05, 20) n_init = 100 basename = f"-n_init={n_init}-left-only" exp_name = "144.0-BDP-revamp-gm-sf" perm_df = readcsv("permuatations" + basename, foldername=exp_name, index_col=0) meta = readcsv("meta" + basename, foldername=exp_name, index_col=0) # adj_df = pd.DataFrame(adj, index=meta.index, columns=meta.index) adj_df = readcsv("adj" + basename, foldername=exp_name, index_col=0) adj = adj_df.values alpha = 0.00021 alpha = np.round(alpha, decimals=5) str_alpha = f"a{alpha}" perm_inds = perm_df[str_alpha] perm_adj = adj[np.ix_(perm_inds, perm_inds)] perm_meta = meta.iloc[perm_inds].copy() fig, ax = plt.subplots(1, 1, figsize=(20, 20)) adjplot( perm_adj, meta=perm_meta,
# ## # parameters for the experiment metric = "bic" bic_ratio = 1 d = 8 # embedding dimension method = "iso" # parameters for plotting lowest_level = 7 width = 0.5 gap = 10 basename = f"-method={method}-d={d}-bic_ratio={bic_ratio}" title = f"Method={method}, d={d}, BIC ratio={bic_ratio}" exp = "137.0-BDP-omni-clust" # load data pair_meta = readcsv("meta" + basename, foldername=exp, index_col=0) pair_meta["lvl0_labels"] = pair_meta["lvl0_labels"].astype(str) pair_adj = readcsv("adj" + basename, foldername=exp, index_col=0) pair_mg = MetaGraph(pair_adj.values, pair_meta) pair_meta = pair_mg.meta lp_inds, rp_inds = get_paired_inds(pair_meta) left_adj = pair_adj[np.ix_(lp_inds, lp_inds)] right_adj = pair_adj[np.ix_(rp_inds, rp_inds)] calc_blockmodel_df
level = 7 class_key = f"lvl{level}_labels" metric = "bic" bic_ratio = 1 d = 8 # embedding dimension method = "color_iso" basename = f"-method={method}-d={d}-bic_ratio={bic_ratio}" title = f"Method={method}, d={d}, BIC ratio={bic_ratio}" exp = "137.2-BDP-omni-clust" # load data pair_meta = readcsv("meta" + basename, foldername=exp, index_col=0) pair_meta["lvl0_labels"] = pair_meta["lvl0_labels"].astype(str) pair_adj = readcsv("adj" + basename, foldername=exp, index_col=0) pair_adj = pair_adj.values mg = MetaGraph(pair_adj, pair_meta) meta = mg.meta def sort_mg(mg, level_names): meta = mg.meta sort_class = level_names + ["merge_class"] class_order = ["sf"] total_sort_by = [] for sc in sort_class: for co in class_order: class_value = meta.groupby(sc)[co].mean()