<jupyter_start><jupyter_text>Plot loss over number of keys<jupyter_code>dfq = df.copy()
dfq = dfq[dfq.with_replace == 1]
dfq = dfq[dfq.attn_name != "favor64"] # NaNs
dfq = dfq[dfq.attn_name != "favor128"] # NaNs

set(dfq.label)
filled_markers = ('o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd', 'P', 'X')

fig, ax = plt.subplots(figsize=(13,8))
scat = sns.scatterplot(x="n_keys",
                       y="loss", 
                       style="label",
                       hue="label",
                       data=dfq,
                       s=150,
                       alpha=0.8,
                       markers=filled_markers)
scat.axes.set_title("setting 2", fontsize=16)
scat.axes.set_xlabel("number of unique keys / sequence length", fontsize=17)
scat.axes.set_ylabel("loss", fontsize=18)
scat.axes.set_yscale('log', basey=10)
scat.axes.set(ylim=(0.0001, 1000.0))
scat.tick_params(labelsize=15)
plt.xticks(np.arange(0, 200, 40))

# sort both labels and handles by labels
handles, labels = scat.axes.get_legend_handles_labels()
labels, handles = zip(*sorted(zip(labels, handles), key=lambda t: t[0], reverse=True))
scat.axes.legend(handles, labels, loc="center left", bbox_to_anchor=(0.01,0.80), prop={'size': 12})
#scat.axes.legend(handles, labels, loc="best", prop={'size': 12})

# major and minor ticks
scat.axes.xaxis.set_major_locator(MultipleLocator(20))
scat.axes.xaxis.set_major_formatter(FormatStrFormatter('%d'))
scat.axes.xaxis.set_minor_locator(MultipleLocator(20))

#scat.axes.yaxis.set_major_locator(MultipleLocator(0.5))
#scat.axes.yaxis.set_minor_locator(MultipleLocator(0.5))

# grid 
scat.axes.xaxis.grid(True, which='both')
scat.axes.yaxis.grid(True, which='both')
fig, ax = plt.subplots(figsize=(13,8))
line = sns.lineplot(x="n_keys",
                    y="loss",
                    hue="label",
                    data=dfq,
                    alpha=0.7,
                    linewidth=3)
#line.axes.set_title("setting 1", fontsize=20)
line.axes.set_xlabel("number of unique keys / sequence length", fontsize=15)
line.axes.set_ylabel("loss", fontsize=15)
line.axes.set_yscale('log', basey=10)
line.tick_params(labelsize=12)
line.axes.legend(loc="center right", bbox_to_anchor=(0.3,0.85))
plt.xticks(np.arange(20, 201, 20))
plt.grid()<jupyter_output><empty_output><jupyter_text>Plot loss curve for specific experiments<jupyter_code>N_KEYS = 20

dfq = df.copy()
dfq = dfq[dfq.steps > 0]
dfq = dfq[dfq.n_keys == N_KEYS]
dfq = dfq[dfq.with_replace == 1]
dfq = dfq[dfq.attn_name != "dpfp2"]
dfq = dfq[dfq.attn_name != "favor64"] # NaNs
dfq = dfq[dfq.attn_name != "favor128"] # NaNs
dfq = dfq[dfq.attn_name != "linear"]

dfq
df_losses = pd.DataFrame(columns=["label", "loss", "step"])

for _, row in dfq.iterrows():
    df_csv = pd.read_csv(os.path.join(FOLDER, row.csvfile))
    for _, csv_row in df_csv.iterrows():
        df_losses = df_losses.append({
            "label": row.label,
            "loss": csv_row["eval-loss"],
            "step": csv_row.step
        }, ignore_index=True)
fig, ax = plt.subplots(figsize=(13,8))
line = sns.lineplot(x="step",
                    y="loss",
                    hue="label",
                    style="label",
                    data=df_losses,
                    alpha=0.7,
                    linewidth=5)
#line.axes.set_title(f"Setting 1 with {N_KEYS} unique keys", fontsize=20)
line.axes.set_xlabel("step", fontsize=17)
line.axes.set_ylabel("loss", fontsize=18)
line.axes.set(ylim=(0.0005, 100))
line.axes.set_yscale('log', basey=10)
line.axes.legend(prop={'size': 14})
line.tick_params(labelsize=15)

# major and minor ticks
line.axes.xaxis.set_major_locator(MultipleLocator(2000))
line.axes.xaxis.set_major_formatter(FormatStrFormatter('%d'))
line.axes.xaxis.set_minor_locator(MultipleLocator(1000))

# grid 
line.axes.xaxis.grid(True, which='both')
line.axes.yaxis.grid(True, which='both')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16998468606431852, 'fraction_numerical': 0.03445635528330781, 'mean_word_length': 3.504597701149425, 'pattern_counts': {'":': 3, '<': 10, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '596155', 'license': 'MIT', 'n_tokens_mistral': 1634, 'n_tokens_neox': 1489, 'n_words': 236, 'path': 'synthetic/.ipynb_checkpoints/setting2_generate_figure-checkpoint.ipynb', 'repo_name': 'ischlag/fast-weight-transformers', 'size': '3918'}