def run_fit(seed, param_grid, directed, n_init, n_jobs):
    # run left
    graph = load_drosophila_left()
    if not directed:
        graph = symmetrize(graph, method="avg")
    graph = binarize(graph)
    ddcsbm_left_df = select_dcsbm(
        graph,
        param_grid,
        directed=directed,
        degree_directed=False,
        n_jobs=n_jobs,
        n_init=n_init,
    )
    save_obj(ddcsbm_left_df, file_obs, "ddcsbm_left_df")

    # run right
    graph = load_drosophila_right()
    if not directed:
        graph = symmetrize(graph, method="avg")
    graph = binarize(graph)
    ddcsbm_right_df = select_dcsbm(
        graph,
        param_grid,
        directed=directed,
        degree_directed=False,
        n_jobs=n_jobs,
        n_init=n_init,
    )
    save_obj(ddcsbm_right_df, file_obs, "ddcsbm_right_df")

    return 0
Пример #2
0
def run_fit(seed, param_grid, directed, n_init, n_jobs):
    graph = load_drosophila_left()
    if not directed:
        graph = symmetrize(graph, method="avg")
    graph = binarize(graph)

    np.random.seed(seed)

    dcsbm_out_df = select_dcsbm(
        graph,
        param_grid,
        directed=directed,
        degree_directed=False,
        n_jobs=n_jobs,
        n_init=n_init,
    )

    ddcsbm_out_df = select_dcsbm(
        graph,
        param_grid,
        directed=directed,
        degree_directed=True,
        n_jobs=n_jobs,
        n_init=n_init,
    )

    save_obj(dcsbm_out_df, file_obs, "dcsbm_out_df")
    save_obj(ddcsbm_out_df, file_obs, "ddcsbm_out_df")
    return 0
def run_fit(
    seed,
    n_components_try_range,
    n_components_try_rdpg,
    n_block_try_range,
    directed,
    n_init,
    embed_kws_try_range,
    n_jobs,
):
    graph = load_drosophila_left()
    if not directed:
        graph = symmetrize(graph, method="avg")
    graph = binarize(graph)

    np.random.seed(seed)

    param_grid = {
        "n_components": n_components_try_range,
        "n_blocks": n_block_try_range,
        "embed_kws": embed_kws_try_range,
    }
    out_df = select_dcsbm(
        graph,
        param_grid,
        directed=directed,
        degree_directed=False,
        n_jobs=n_jobs,
        n_init=n_init,
    )

    print(out_df.head())

    save_obj(out_df, file_obs, "grid_search_out")
    return 0
Пример #4
0
        else:
            for j, label in enumerate(np.unique(right_labels)):
                inds = np.where(right_labels == label)[0]
                plot_data = latent[inds][:, i]
                sns.distplot(plot_data, color=cmap1[j], ax=a)

plt.tight_layout()
save("multipanel_dcsbm", fmt="png")
#%%
estimator = DCSBMEstimator()
ap_results = fit_a_priori(estimator, left_adj, left_labels)

param_grid = dict(n_blocks=list(range(1, 10)))
sweep_results = select_dcsbm(left_adj,
                             param_grid,
                             n_init=25,
                             n_jobs=-2,
                             metric=None)

sweep_results

best_results = get_best(sweep_results,
                        "n_params",
                        score_name=score,
                        small_better=False)

#
#
#
#
#