<jupyter_start><jupyter_text>plot on the basis of the best silhouette score<jupyter_code>### get the best silhouette score for each dataset, class_, dim_
metrics_df_max_iter = []
for dataset in metrics_df.dataset.unique():
    for class_ in metrics_df.class_.unique():
        for dim in metrics_df.dim.unique():
            subset_df = metrics_df[
                (dataset == metrics_df.dataset.values) &
                (class_ == metrics_df.class_.values) &
                (dim == metrics_df.dim.values) 
            ]
            if len(subset_df) > 0:
                #print(np.argmax(subset_df.silhouette))
                metrics_df_max_iter.append(subset_df.iloc[np.argmax(subset_df.silhouette)])
metrics_max_df = pd.concat(metrics_df_max_iter, axis=1).T.reset_index()
metrics_max_df[:3]
metrics_max_df
metrics_max_df.class_.unique()
from tfumap.paths import FIGURE_DIR, save_fig
#sns.set(font_scale=1.0)
import matplotlib as mpl
axes = {'labelsize': 14,
        'titlesize': 14,}
mpl.rc('axes', **axes)
mpl.rcParams['xtick.labelsize'] = 14

hue_list = ["TSNE", "parametric-tsne", "umap-learn",  'direct', "network", "autoencoder", 'vae', 'ae_only', "PCA"]
fg = sns.catplot(
    x="dataset",
    y="v_measure",
    hue="class_",
    hue_order=hue_list,
    order = ['mnist', 'fmnist', 'macosko2015', 'cassins_dtw', 'cifar10'],
    col="dim",
    height=2.75, #2.65, 
    aspect=2.5,#3,
    data=metrics_max_df,
    kind="bar",
    palette=[hue_dict[i] for i in hue_list],
    legend=False
)
(fg.despine(bottom=True)
 .set_xticklabels(['MNIST', 'FMNIST', 'Retina', 'Cassin\'s', 'CIFAR10'])
 .set_axis_labels("", "NMI")
)
ax = fg.axes[0][0]
ax.tick_params(axis=u'both', which=u'both',length=0)
#fg._legend.texts[2].set_text("P. UMAP")
#fg._legend.texts[3].set_text("UMAP AE")
ax.set_title('2 Dimensions')
if len(fg.axes[0])>1:
    ax = fg.axes[0][1]
    ax.tick_params(axis=u'both', which=u'both',length=0)
    ax.set_title('64 Dimensions')

if True:
    leg = plt.legend(loc='upper left', bbox_to_anchor=(1.0, 1.1))
else:
    leg = fg._legend
    
leg.get_frame().set_edgecolor('w')
    
leg._legend_title_box._text.set_text("")
leg.texts[np.where((np.array([i._text for i in leg.texts]) == 'umap-learn'))[0][0]].set_text('UMAP (UMAP-learn)')
leg.texts[np.where((np.array([i._text for i in leg.texts]) == 'network'))[0][0]].set_text('P. UMAP')
leg.texts[np.where((np.array([i._text for i in leg.texts]) == 'direct'))[0][0]].set_text('UMAP (TF)')
leg.texts[np.where((np.array([i._text for i in leg.texts]) == 'autoencoder'))[0][0]].set_text('UMAP AE')
leg.texts[np.where((np.array([i._text for i in leg.texts]) == 'parametric-tsne'))[0][0]].set_text('P. TSNE')
leg.texts[np.where((np.array([i._text for i in leg.texts]) == 'ae_only'))[0][0]].set_text('AE')
leg

save_fig(FIGURE_DIR/'NMI', save_pdf=True, dpi=300)<jupyter_output><empty_output><jupyter_text>plot on the basis of best score<jupyter_code>### get the best silhouette score for each dataset, class_, dim_
metrics_df_max_iter = []
for dataset in metrics_df.dataset.unique():
    for class_ in metrics_df.class_.unique():
        for dim in metrics_df.dim.unique():
            subset_df = metrics_df[
                (dataset == metrics_df.dataset.values) &
                (class_ == metrics_df.class_.values) &
                (dim == metrics_df.dim.values) 
            ]
            if len(subset_df) > 0:
                #print(np.argmax(subset_df.silhouette))
                metrics_df_max_iter.append(subset_df.iloc[np.argmax(subset_df.v_measure)])
metrics_max_df = pd.concat(metrics_df_max_iter, axis=1).T.reset_index()
metrics_max_df[:3]
fg = sns.catplot(
    x="dataset",
    y="v_measure",
    hue="class_",
    hue_order=hue_list,
    order = ['mnist', 'fmnist', 'macosko2015', 'cassins_dtw', 'cifar10'],
    col="dim",
    height=2.75, #2.65, 
    aspect=2.5,#3,
    data=metrics_max_df,
    kind="bar",
    palette=[hue_dict[i] for i in hue_list],
    #legend=False
)
(fg.despine(bottom=True)
 .set_xticklabels(['MNIST', 'FMNIST', 'Retina', 'Cassin\'s', 'CIFAR10'])
 .set_axis_labels("", "V-measure")
)
ax = fg.axes[0][0]
ax.tick_params(axis=u'both', which=u'both',length=0)
fg._legend._legend_title_box._text.set_text("")
#fg._legend.texts[2].set_text("P. UMAP")
#fg._legend.texts[3].set_text("UMAP AE")
ax.set_title('2 Dimensions')
if len(fg.axes[0])>1:
    ax = fg.axes[0][1]
    ax.tick_params(axis=u'both', which=u'both',length=0)
    ax.set_title('64 Dimensions')


fg._legend.texts[np.where((np.array([i._text for i in fg._legend.texts]) == 'umap-learn'))[0][0]].set_text('UMAP (UMAP-learn)')
fg._legend.texts[np.where((np.array([i._text for i in fg._legend.texts]) == 'network'))[0][0]].set_text('P. UMAP')
fg._legend.texts[np.where((np.array([i._text for i in fg._legend.texts]) == 'autoencoder'))[0][0]].set_text('UMAP AE')
fg._legend.texts[np.where((np.array([i._text for i in fg._legend.texts]) == 'parametric-tsne'))[0][0]].set_text('P. TSNE')

#save_fig(FIGURE_DIR/'v-measure', save_pdf=True, dpi=300)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19096876864929382, 'fraction_numerical': 0.02068828327034016, 'mean_word_length': 4.172839506172839, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '334238', 'license': 'MIT', 'n_tokens_mistral': 2099, 'n_tokens_neox': 1999, 'n_words': 315, 'path': 'notebooks/dataset-projections/clustering-quality-plot-with-vae.ipynb', 'repo_name': 'timsainb/ParametricUMAP_paper', 'size': '5027'}