<jupyter_start><jupyter_text>LabelMatch<jupyter_code>models = ['LXMERT', 'ViLBERT', 'VL-BERT', 'VisualBERT', 'UNITER']
model2label = {x: x for x in models}
colors = ['#009E73', '#E69F00', '#CC79A7', '#0072B2', '#56B4E9', '#F0E442']
markers = ['d', 'D', 'P', 'o', 's']
f = plt.figure(figsize=(14,8))

ylim  = [2.9, 2.98]
ylim2 = [.4, .75]
ylimratio = (ylim[1]-ylim[0])/(ylim2[1]-ylim2[0]+ylim[1]-ylim[0])
ylim2ratio = (ylim2[1]-ylim2[0])/(ylim2[1]-ylim2[0]+ylim[1]-ylim[0])
gs = gridspec.GridSpec(2, 2, height_ratios=[ylimratio, ylim2ratio], width_ratios=[1,1])
ax1 = f.add_subplot(gs[0,0])
ax2 = f.add_subplot(gs[1,0])
ax3 = f.add_subplot(gs[0,1])
ax4 = f.add_subplot(gs[1,1])
ax1.grid(alpha=0.2)
ax2.grid(alpha=0.2)
ax3.grid(alpha=0.2)
ax4.grid(alpha=0.2)

xs = ["None"] + ["Phrase"] + ["All"]
ys = np.zeros((len(xs), len(models)))
for im, m in enumerate(models):
    for ix, x in enumerate(xs):
        ys[ix, im] = mrc_df[(mrc_df['Model'] == m) & (mrc_df['Mask'] == x)]['MRC-KL'].values[0]
for iy, y in enumerate(range(ys.shape[1])):
    ax1.plot(xs, ys[:,iy], color=colors[iy], ms=8, marker=markers[iy], markeredgecolor='k', lw=4, label=model2label[models[iy]])
    ax2.plot(xs, ys[:,iy], color=colors[iy], ms=8, marker=markers[iy], markeredgecolor='k', lw=4, label=model2label[models[iy]])
    
lgd = ax1.legend(loc='upper left', ncol=3, bbox_to_anchor=(0.15, 2.5, 0.5, 0.5), fontsize=24)
        
ax1.set_ylim(ylim)
ax2.set_ylim(ylim2)

ax1.spines['bottom'].set_visible(False)
ax2.spines['top'].set_visible(False)
ax1.xaxis.tick_top()
ax1.tick_params(top=False, labeltop=False)  # don't put tick labels at the top
ax2.xaxis.tick_bottom()

d = .5  # proportion of vertical to horizontal extent of the slanted line
kwargs = dict(marker=[(-1, -d), (1, d)], markersize=12, linestyle="none", color='k', mec='k', mew=1, clip_on=False)
ax1.plot([0, 1], [0, 0], transform=ax1.transAxes, **kwargs)
ax2.plot([0, 1], [1, 1], transform=ax2.transAxes, **kwargs)

ax2.set_ylabel("               bit", fontsize=32)
ax1.set_title("MRC-KL", fontsize=32)
ax2.set_xticklabels(["None", "Phrase", "All"])
ax1.tick_params(labelsize=24, pad=10)
ax2.tick_params(labelsize=24, pad=10)

ax1.margins(x=0.2)
ax2.margins(x=0.2)


xs = ["None"] + ["Phrase"] + ["All"]
ys = np.zeros((len(xs), len(models)))
for im, m in enumerate(models):
    for ix, x in enumerate(xs):
        ys[ix, im] = mrc_df[(mrc_df['Model'] == m) & (mrc_df['Mask'] == x)]['MRC-XE-VG'].values[0]
for iy, y in enumerate(range(ys.shape[1])):
    ax3.plot(xs, ys[:,iy], color=colors[iy], ms=8, marker=markers[iy], markeredgecolor='k', lw=4, label=model2label[models[iy]])
    ax4.plot(xs, ys[:,iy], color=colors[iy], ms=8, marker=markers[iy], markeredgecolor='k', lw=4, label=model2label[models[iy]])

ylim  = [6.84, 6.92]
ylim2 = [4.8, 5.15]
ax3.set_ylim(ylim)
ax4.set_ylim(ylim2)

ax3.spines['bottom'].set_visible(False)
ax4.spines['top'].set_visible(False)
ax3.xaxis.tick_top()
ax3.tick_params(top=False, labeltop=False)  # don't put tick labels at the top
ax4.xaxis.tick_bottom()

d = .5  # proportion of vertical to horizontal extent of the slanted line
kwargs = dict(marker=[(-1, -d), (1, d)], markersize=12, linestyle="none", color='k', mec='k', mew=1, clip_on=False)
ax3.plot([0, 1], [0, 0], transform=ax1.transAxes, **kwargs)
ax4.plot([0, 1], [1, 1], transform=ax2.transAxes, **kwargs)

ax3.set_title(r"MRC-XE$^{(LM)}$", fontsize=32)
ax4.set_xticklabels(["None", "Phrase", "All"])
ax3.tick_params(labelsize=24, pad=10)
ax4.tick_params(labelsize=24, pad=10)

ax3.margins(x=0.2)
ax4.margins(x=0.2)

plt.gcf().subplots_adjust(bottom=0.2)
f.savefig("figures/standard_labelmatch_mrckl_mrcxevg.pdf", bbox_extra_artists=(lgd,), bbox_inches='tight')<jupyter_output><empty_output><jupyter_text>LabelMatch AgreementWhere Faster R-CNN’s prediction match with gold labels<jupyter_code>mrc_pp_df = pd.read_csv("val_labelmatch-agree_0.5_lang4vis.tsv", sep='\t')
mrc_pp_df.tail()
f = plt.figure(figsize=(14,8))

ylim  = [3.05, 3.15]
ylim2 = [.3, .65]
ylimratio = (ylim[1]-ylim[0])/(ylim2[1]-ylim2[0]+ylim[1]-ylim[0])
ylim2ratio = (ylim2[1]-ylim2[0])/(ylim2[1]-ylim2[0]+ylim[1]-ylim[0])
gs = gridspec.GridSpec(2, 2, height_ratios=[ylimratio, ylim2ratio], width_ratios=[1,1])
ax1 = f.add_subplot(gs[0,0])
ax2 = f.add_subplot(gs[1,0])
ax3 = f.add_subplot(gs[0,1])
ax4 = f.add_subplot(gs[1,1])
ax1.grid(alpha=0.2)
ax2.grid(alpha=0.2)
ax3.grid(alpha=0.2)
ax4.grid(alpha=0.2)

xs = ["None"] + ["Phrase"] + ["All"]
ys = np.zeros((len(xs), len(models)))
for im, m in enumerate(models):
    for ix, x in enumerate(xs):
        ys[ix, im] = mrc_pp_df[(mrc_pp_df['Model'] == m) & (mrc_pp_df['Mask'] == x)]['MRC-KL'].values[0]
for iy, y in enumerate(range(ys.shape[1])):
    ax1.plot(xs, ys[:,iy], color=colors[iy], ms=8, marker=markers[iy], markeredgecolor='k', lw=4, ls='-', label=model2label[models[iy]])
    ax2.plot(xs, ys[:,iy], color=colors[iy], ms=8, marker=markers[iy], markeredgecolor='k', lw=4, ls='-', label=model2label[models[iy]])
    
lgd = ax1.legend(loc='upper left', ncol=3, bbox_to_anchor=(0.15, 2.5, 0.5, 0.5), fontsize=24)
        
ax1.set_ylim(ylim)
ax2.set_ylim(ylim2)

ax1.spines['bottom'].set_visible(False)
ax2.spines['top'].set_visible(False)
ax1.xaxis.tick_top()
ax1.tick_params(top=False, labeltop=False)  # don't put tick labels at the top
ax2.xaxis.tick_bottom()

d = .5  # proportion of vertical to horizontal extent of the slanted line
kwargs = dict(marker=[(-1, -d), (1, d)], markersize=12, linestyle="none", color='k', mec='k', mew=1, clip_on=False)
ax1.plot([0, 1], [0, 0], transform=ax1.transAxes, **kwargs)
ax2.plot([0, 1], [1, 1], transform=ax2.transAxes, **kwargs)

# # ax1.set_title("MRC-KL", fontsize=24)
ax2.set_ylabel("               bit", fontsize=32)
ax1.set_title("MRC-KL", fontsize=32)
ax2.set_xticklabels(["None", "Phrase", "All"])
ax1.tick_params(labelsize=24, pad=10)
ax2.tick_params(labelsize=24, pad=10)

ax1.margins(x=0.2)
ax2.margins(x=0.2)


xs = ["None"] + ["Phrase"] + ["All"]
ys = np.zeros((len(xs), len(models)))
for im, m in enumerate(models):
    for ix, x in enumerate(xs):
        ys[ix, im] = mrc_pp_df[(mrc_pp_df['Model'] == m) & (mrc_pp_df['Mask'] == x)]['MRC-XE-VG'].values[0]
for iy, y in enumerate(range(ys.shape[1])):
    ax3.plot(xs, ys[:,iy], color=colors[iy], ms=8, marker=markers[iy], markeredgecolor='k', lw=4, ls='-', label=model2label[models[iy]])
    ax4.plot(xs, ys[:,iy], color=colors[iy], ms=8, marker=markers[iy], markeredgecolor='k', lw=4, ls='-', label=model2label[models[iy]])

ylim  = [4.2, 4.5]
ylim2 = [1.2, 1.5]
ax3.set_ylim(ylim)
ax4.set_ylim(ylim2)

ax3.spines['bottom'].set_visible(False)
ax4.spines['top'].set_visible(False)
ax3.xaxis.tick_top()
ax3.tick_params(top=False, labeltop=False)  # don't put tick labels at the top
ax4.xaxis.tick_bottom()

d = .5  # proportion of vertical to horizontal extent of the slanted line
kwargs = dict(marker=[(-1, -d), (1, d)], markersize=12, linestyle="none", color='k', mec='k', mew=1, clip_on=False)
ax3.plot([0, 1], [0, 0], transform=ax1.transAxes, **kwargs)
ax4.plot([0, 1], [1, 1], transform=ax2.transAxes, **kwargs)

ax3.set_title(r"MRC-XE$^{(LM)}$", fontsize=32)
ax4.set_xticklabels(["None", "Phrase", "All"])
ax3.tick_params(labelsize=24, pad=10)
ax4.tick_params(labelsize=24, pad=10)
# ax.legend(loc='upper left', title="Model", ncol=2, title_fontsize=16, fontsize=12)

ax3.margins(x=0.2)
ax4.margins(x=0.2)

plt.gcf().subplots_adjust(bottom=0.2)
f.savefig("figures/standard_labelmatch-agree_mrckl_mrcxevg.pdf", bbox_extra_artists=(lgd,), bbox_inches='tight')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.22254564699655993, 'fraction_numerical': 0.05808414924583223, 'mean_word_length': 6.097652582159625, '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': '634317', 'license': 'MIT', 'n_tokens_mistral': 3576, 'n_tokens_neox': 3420, 'n_words': 573, 'path': 'notebooks/Plot-LabelMatch.ipynb', 'repo_name': 'e-bug/cross-modal-ablation', 'size': '7558'}