<jupyter_start><jupyter_text>Eval by group.<jupyter_code># preload font sizes, etc.
reload(p)
fig, ax = p.setup_uplot_ax()


ls = ['-','--', ':']
obj_names = ['ERM','IS', 'GDRO'] 
acc_key_plot = '1 - acc'

results_to_plot = [r_ERM, r_IS, r_GDRO]

for i, results in enumerate(results_to_plot):
    groups, subset_sizes, accs_total, accs_by_group = results

    subset_fracs = subset_sizes / subset_sizes.sum(axis=0)
    accs_total_avgs = {}

    p.plot_by_group(accs_by_group,
                    accs_total,
                    subset_fracs,
                    acc_key_plot, 
                    group_id_dict,
                    gammas = gammas,
                    pop_weights = 'by_gamma',
                    ls = ls[i],
                    label_append = obj_names[i],
                    range_type='stddev',
                    title='CIFAR-4 air/land prediction',
                    ylim=None,
                    plot_alpha_star=True, 
                    plot_gamma = True, 
                    gamma_annot_offset = (-0.24,0.09),
                    ax = ax)
    
plt.ylabel('0/1 loss')
#ax.set_yscale('log')#loglog()
#ax.grid(linewidth=1)
ax.set_ylim(0,0.16);

plt.savefig('../../figures/uplot_cifar_acc_90_10.pdf', bbox_inches='tight')<jupyter_output><empty_output><jupyter_text>flip so smaller group is A<jupyter_code># preload font sizes, etc.
reload(p)
fig, ax = p.setup_uplot_ax()

ls = ['-','--', ':']
obj_names = ['ERM','IS', 'GDRO'] 
acc_key_plot = '1 - acc'

results_to_plot = [r_ERM, r_IS, r_GDRO]

for i, results in enumerate(results_to_plot):
    groups, subset_sizes, accs_total, accs_by_group = results
    
#    flip results
    res_flipped = utils.flip_group_results(accs_by_group, subset_sizes, group_id_dict, gammas, group_names)
    accs_by_group_flipped, subset_size_flipped, group_id_dict_flipped, gammas_flipped, group_names = res_flipped


    subset_fracs_flipped = subset_size_flipped / subset_size_flipped.sum(axis=0)

    p.plot_by_group(accs_by_group_flipped,
                    accs_total,
                    subset_fracs_flipped,
                    acc_key_plot, 
                    group_id_dict_flipped,
                    gammas = gammas_flipped,
                    pop_weights = 'by_gamma',
                    ls = ls[i],
                    label_append = obj_names[i],
                    range_type='stddev',
                    title='CIFAR-4 air/land prediction',
                    ylim=None,
                    plot_alpha_star=True, 
                    plot_gamma = True, 
                    gamma_annot_offset = (0.03,0.085),
                    ax = ax)
    
plt.ylabel('0/1 loss')
#ax.set_yscale('log')#loglog()
#ax.grid(linewidth=1)
ax.set_ylim(0,0.16);

plt.savefig('../../figures/uplot_cifar_acc_90_10_flipped.pdf', bbox_inches='tight')

# preload font sizes, etc.
reload(p)
fig, ax = p.setup_uplot_ax_smaller()

ls = ['-','--', ':']
obj_names = ['ERM','IS', 'GDRO'] 
acc_key_plot = '1 - acc'

results_to_plot = [r_ERM, r_IS, r_GDRO]

for i, results in enumerate(results_to_plot):
    groups, subset_sizes, accs_total, accs_by_group = results
    
#    flip results
    res_flipped = utils.flip_group_results(accs_by_group, subset_sizes, group_id_dict, gammas, group_names)
    accs_by_group_flipped, subset_size_flipped, group_id_dict_flipped, gammas_flipped, group_names = res_flipped


    subset_fracs_flipped = subset_size_flipped / subset_size_flipped.sum(axis=0)

    p.plot_by_group(accs_by_group_flipped,
                    accs_total,
                    subset_fracs_flipped,
                    acc_key_plot, 
                    group_id_dict_flipped,
                    gammas = gammas_flipped,
                    pop_weights = 'by_gamma',
                    ls = ls[i],
                    label_append = obj_names[i],
                    range_type='stddev',
                    title='CIFAR-4 air/land prediction',
                    ylim=None,
                    plot_alpha_star=True, 
                    plot_gamma = True, 
                    gamma_annot_offset = (0.03,0.085),
                    group_labels_only=True,
                    ax = ax)
    
plt.ylabel('0/1 loss')
#ax.set_yscale('log')#loglog()
#ax.grid(linewidth=1)
ax.set_ylim(0,0.16);

plt.savefig('../../figures/uplot_cifar_acc_90_10_flipped_wide.pdf', bbox_inches='tight')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11370395790436971, 'fraction_numerical': 0.014184397163120567, 'mean_word_length': 2.0745428973277074, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '617727', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1606, 'n_tokens_neox': 1537, 'n_words': 230, 'path': 'cifar4/notebooks/read_uplot_results.ipynb', 'repo_name': 'estherrolf/representation-matters', 'size': '4371'}