Esempio n. 1
0
    gJs, gKs, converged, meta = grid_search.grid_search(Js,
                                                        Ks,
                                                        X,
                                                        N_inits=N_inits,
                                                        mcfa_kwds=mcfa_kwds)
    mml = meta["message_length"]

    # Plot some contours.
    plot_filled_contours_kwds = dict(converged=converged,
                                     marker_function=np.nanargmin,
                                     N=100,
                                     cmap="Spectral_r")

    fig_mml = mpl_utils.plot_filled_contours(gJs,
                                             gKs,
                                             mml,
                                             colorbar_label=r"$\textrm{MML}$",
                                             **plot_filled_contours_kwds)
    savefig(fig_mml, f"size-{size}-gridsearch-mml")
    raise a

sizes = (100, 1000, 10000)  #, sum(possible_additions_mask))

saved_models = dict()

for size in sizes:

    if size <= 1000:
        Js = np.arange(J - delta_J, J + delta_J + 1)
        Ks = np.arange(K - delta_K, K + delta_K + 1)
Esempio n. 2
0
print(f"BIC is lowest at J = {jm_b} and K = {km_b}")
print(f"MML is lowest at J = {jm_m} and K = {km_m}")

print(f"True values are  J = {J_true} and K = {K_true}")

kwds = dict(converged=converged,
            marker_function=np.nanargmin,
            N=1000,
            cmap="Spectral_r",
            truth=(J_true, K_true))

fig_ll = mpl_utils.plot_filled_contours(
    J_grid,
    K_grid,
    -ll,
    colorbar_label=
    r"$-\log\mathcal{L}(\boldsymbol{\mathbf{Y}}|\boldsymbol{\mathbf{D}})$",
    **kwds)
fig_ll.axes[0].set_yticks([1, 5, 10, 15, 20])

fig_bic = mpl_utils.plot_filled_contours(J_grid,
                                         K_grid,
                                         bic,
                                         colorbar_label=r"$\textrm{BIC}$",
                                         **kwds)
fig_bic.axes[0].set_yticks([1, 5, 10, 15, 20])

fig_mml = mpl_utils.plot_filled_contours(
    J_grid,
    K_grid,
Esempio n. 3
0
message_length = meta["message_length"]

J_best_ll, K_best_ll = grid_search.best(Js, Ks, -ll)
J_best_bic, K_best_bic = grid_search.best(Js, Ks, bic)
J_best_mml, K_best_mml = grid_search.best(Js, Ks, message_length)

print(f"Best log likelihood  at J = {J_best_ll} and K = {K_best_ll}")
print(f"Best BIC value found at J = {J_best_bic} and K = {K_best_bic}")
print(f"Best MML value found at J = {J_best_mml} and K = {K_best_mml}")

# Plot some contours.
plot_filled_contours_kwds = dict(converged=converged,
                                 marker_function=np.nanargmin,
                                 cmap="Spectral_r")
fig_ll = mpl_utils.plot_filled_contours(Jg, Kg, -ll,
                                        colorbar_label=r"$-\log\mathcal{L}$",
                                        **plot_filled_contours_kwds)
savefig(fig_ll, "gridsearch-ll")


fig_ll = mpl_utils.plot_filled_contours(Jg, Kg, message_length,
                                        colorbar_label=r"$\textrm{MML}$",
                                        **plot_filled_contours_kwds)
savefig(fig_ll, "gridsearch-mml")


fig_bic = mpl_utils.plot_filled_contours(Jg, Kg, bic,
                                         colorbar_label=r"$\textrm{BIC}$",
                                         **plot_filled_contours_kwds)
savefig(fig_bic, "gridsearch-bic")