def dcsbm_objective(adj, labels): # class1_var = np.var(input[class1_inds]) # class2_var = np.var(input[class2_inds]) dcsbm = SBMEstimator() dcsbm.fit(adj, y=labels) objective = dcsbm.score(adj) return objective
temp_dict = base_dict.copy() temp_dict["Metric"] = "GMM likelihood" temp_dict["Score"] = score out_dicts.append(temp_dict) # GMM BIC score = gmm.model_.bic(latent) temp_dict = base_dict.copy() temp_dict["Metric"] = "GMM BIC" temp_dict["Score"] = score out_dicts.append(temp_dict) # SBM likelihood sbm = SBMEstimator(directed=True, loops=False) sbm.fit(bin_adj, y=pred_labels) score = sbm.score(bin_adj) temp_dict = base_dict.copy() temp_dict["Metric"] = "SBM likelihood" temp_dict["Score"] = score out_dicts.append(temp_dict) # DCSBM likelihood dcsbm = DCSBMEstimator(directed=True, loops=False) dcsbm.fit(bin_adj, y=pred_labels) score = dcsbm.score(bin_adj) temp_dict = base_dict.copy() temp_dict["Metric"] = "DCSBM likelihood" temp_dict["Score"] = score out_dicts.append(temp_dict) # ARI of the subset with labels
np.random.seed(8888) n_init = 200 clip = 1 / (right_graph.size - right_graph.shape[0]) heatmap_kws = dict(vmin=0, vmax=1, font_scale=1.5, hier_label_fontsize=20, cbar=False) fig, ax = plt.subplots(4, 2, figsize=(15, 30)) # A priori SBM ap_estimator = SBMEstimator() ap_estimator.fit(right_graph, y=right_labels) lik = ap_estimator.score(right_graph, clip=clip) heatmap( right_graph, inner_hier_labels=right_labels, title="Right MB (by cell type)", ax=ax[0, 0], **heatmap_kws, ) heatmap( ap_estimator.p_mat_, inner_hier_labels=right_labels, title=f"A priori SBM, lik = {lik:.2f}", ax=ax[0, 1], **heatmap_kws, )