raise a # Load the largest one and make plots model = comparison_model with open('exp10-99174-data.pkl', 'rb') as fp: _, X, mask = pickle.load(fp) # For the latent space we will just use a corner plot. component_cmap = mpl_utils.discrete_cmap(16, base_cmap="tab20") fig = mpl_utils.plot_latent_space(model, X, ellipse_kwds=dict(alpha=0), s=10, edgecolor="none", alpha=1, c=[component_cmap(_) for _ in np.argmax(model.tau_, axis=1)], show_ticks=True, label_names=[r"$\mathbf{{S}}_{{{0}}}$".format(i + 1) for i in range(model.n_latent_factors)]) for ax in fig.axes: if ax.is_last_row(): ax.set_ylim(-1, 1) ax.set_yticks([-1, 0, 1]) fig.tight_layout() fig.savefig("exp10-size-all-latent-space.pdf", dpi=300) # Get X_H from mask import galah_dr2 as galah elements = [ea.split("_")[0].title() for ea in label_names] X_H, label_names = galah.get_unflagged_abundances_wrt_h(elements, mask)
ax.set_xlim(0.5, D + 0.5) ax.set_ylim(-ylim, +ylim) ax.set_yticks([-ylim, 0, ylim]) fig_factor_loads.tight_layout() savefig(fig_factor_loads, "factor_loads") # Plot the latent space. cmap = mpl_utils.discrete_cmap(data_kwds["n_components"], "Spectral") label_names = [ f"$\\mathbf{{S}}_{{{i}}}$" for i in range(data_kwds["n_latent_factors"]) ] fig_latent = mpl_utils.plot_latent_space(model, Y, cmap=cmap, label_names=label_names) for ax in fig_latent.axes: if ax.get_visible(): if ax.is_last_row(): ax.xaxis.set_major_locator(MaxNLocator(3)) if ax.is_first_col(): ax.yaxis.set_major_locator(MaxNLocator(3)) xlim = np.max(np.abs(ax.get_xlim())) ylim = np.max(np.abs(ax.get_ylim())) ax.set_xlim(-xlim, +xlim) ax.set_ylim(-ylim, +ylim) fig_latent.tight_layout() fig_latent.subplots_adjust(hspace=0, wspace=0) savefig(fig_latent, "latent")