<jupyter_start><jupyter_text>Single-Q results<jupyter_code>filename = "single_quantity_lsa_20210903-044949"
df_single_q = pd.read_csv(os.path.join(folder, filename), index_col=None)
df_single_q = df_single_q[df_single_q["valid_cv"]]
add_count_Qs(df_single_q)
frames = [df_single_q[df_single_q["quantity"]=="(Tr)"], 
          df_single_q[df_single_q["quantity"]=="(Mm)"]]
df_resume = pd.concat(frames)
df_resume = df_resume[["quantity", "win", "wl", "cv_mean"]]
df_resume.head()
all_frames = [df_single_q]
plt.figure(figsize=(16, 4))
b = snb.boxplot(x="quantity", y="cv_mean", data=df_single_q)
plt.ylabel("Cross-Validation accuracy", fontsize=16)
plt.xlabel("Statistical Quantity", fontsize=16)
plt.title("Single-quantity evaluation", fontsize=18)
plt.yticks(fontsize=14)
plt.xticks(fontsize=14)
plt.tight_layout()

plt.savefig("figs/single_q_evaluations.png", dpi=350)<jupyter_output><empty_output><jupyter_text>Comb Single-Q results<jupyter_code>filename = "comb_single_quantity_lsa_20210903-044949"
df_comb_single_q = pd.read_csv(os.path.join(folder, filename), index_col=None)
df_comb_single_q = df_comb_single_q[df_comb_single_q["valid_cv"]]
add_count_Qs(df_comb_single_q)
df_comb_single_q2 = comb_filter_only_bests(df_comb_single_q, 6)
df_comb_single_q2 = concat_single_best(df_single_q, df_comb_single_q2)
df_comb_single_q2.head()
frame = df_comb_single_q2[df_comb_single_q2["quantity"]=="(Tr-Mm)"][["quantity", "win", "wl", "cv_mean"]]
df_resume = pd.concat([df_resume, frame])
df_resume.head()
all_frames.append(df_comb_single_q2)
plt.figure(figsize=(16, 4))
b = snb.boxplot(x="quantity", y="cv_mean", data=df_comb_single_q2)
loc, labels = plt.xticks()
# plt.xticks(loc, labels, rotation = 15, ha="right", fontsize=13)
plt.ylabel("Cross-Validation accuracy", fontsize=16)
plt.xlabel("Statistical Quantity", fontsize=16)
plt.title("Single-quantity combinations evaluation", fontsize=18)
plt.yticks(fontsize=14)
plt.xticks(fontsize=14)
plt.tight_layout()

plt.savefig("figs/single_q_comb_evaluations.png", dpi=350)<jupyter_output><empty_output><jupyter_text>Double-Q results<jupyter_code>filename = "double_quantity_lsa_20210903-044949"
df_double_q = pd.read_csv(os.path.join(folder, filename), index_col=None)
df_double_q = df_double_q[df_double_q["valid_cv"]]
add_count_Qs(df_double_q)
df_double_q = df_double_q[df_double_q["quantity"] != "(MmTr)"]
# df_double_q.head()

frame = df_double_q[df_double_q["quantity"]=="(TrMm)"][["quantity", "win", "wl", "cv_mean"]]
df_resume = pd.concat([df_resume, frame])
all_frames.append(df_double_q)
plt.figure(figsize=(16, 4))
b = snb.boxplot(x="quantity", y="cv_mean", data=df_double_q)
plt.ylabel("Cross-Validation accuracy", fontsize=16)
plt.xlabel("Statistical Quantity", fontsize=16)
plt.title("Double-quantity evaluation", fontsize=18)
plt.yticks(fontsize=14)
plt.xticks(fontsize=14)
plt.tight_layout()

plt.savefig("figs/double_q_evaluations.png", dpi=350)<jupyter_output><empty_output><jupyter_text>Comb Double-Q results<jupyter_code>filename = "comb_double_quantity_lsa_20210904-024910"
df_comb_double_q = pd.read_csv(os.path.join(folder, filename), index_col=None)
df_comb_double_q = df_comb_double_q[df_comb_double_q["valid_cv"]]
add_count_Qs(df_comb_double_q)
df_comb_double_q2 = comb_filter_only_bests(df_comb_double_q, 6)
df_comb_double_q2 = concat_single_best(df_double_q, df_comb_double_q2)
# df_comb_double_q2.head()

frames = [df_resume,
          df_comb_double_q2[df_comb_double_q2["quantity"]=="(MmTr-MmMn)"][["quantity", "win", "wl", "cv_mean"]], 
          df_comb_double_q2[df_comb_double_q2["quantity"]=="(MmTr-MmMn-MmMx)"][["quantity", "win", "wl", "cv_mean"]], 
          df_comb_double_q2[df_comb_double_q2["quantity"]=="(MmTr-MmMn-MmMx-TrMn)"][["quantity", "win", "wl", "cv_mean"]]]
df_resume = pd.concat(frames)
all_frames.append(df_comb_double_q2)
plt.figure(figsize=(16, 4))
b = snb.boxplot(x="quantity", y="cv_mean", data=df_comb_double_q2)
plt.ylabel("Cross-Validation accuracy", fontsize=16)
plt.xlabel("Statistical Quantity", fontsize=16)
plt.title("Double-quantity combinations evaluation", fontsize=18)
plt.yticks(fontsize=13)
plt.xticks(fontsize=13)
plt.tight_layout()

plt.savefig("figs/double_q_comb_evaluations.png", dpi=350)<jupyter_output><empty_output><jupyter_text>Triple-Q results<jupyter_code>filename = "triple_quantity_lsa_20210904-024910"
df_triple_q = pd.read_csv(os.path.join(folder, filename), index_col=None)
df_triple_q = df_triple_q[df_triple_q["valid_cv"]]
add_count_Qs(df_triple_q)
df_triple_q = df_triple_q[df_triple_q["quantity"] != "(MmTr)"]
df_triple_q = df_triple_q.sort_values("cv_mean", ascending=False)
df_triple_q.head()
all_frames.append(df_triple_q)

plt.figure(figsize=(16, 4))
b = snb.boxplot(x="quantity", y="cv_mean", data=df_triple_q)
plt.ylabel("Cross-Validation accuracy", fontsize=16)
plt.xlabel("Statistical Quantity", fontsize=16)
plt.title("Triple-quantity evaluation", fontsize=18)
plt.yticks(fontsize=14)
plt.xticks(fontsize=14)
plt.tight_layout()

# plt.savefig("figs/triple_q_evaluations.png", dpi=350)<jupyter_output><empty_output><jupyter_text>Comb Triple-Q results<jupyter_code>filename = "comb_triple_quantity_lsa_20210904-024910"
df_comb_triple_q = pd.read_csv(os.path.join(folder, filename), index_col=None)
df_comb_triple_q = df_comb_triple_q[df_comb_triple_q["valid_cv"]]
add_count_Qs(df_comb_triple_q)
df_comb_triple_q2 = comb_filter_only_bests(df_comb_triple_q, 5)
df_comb_triple_q2 = concat_single_best(df_triple_q, df_comb_triple_q2)
# df_comb_triple_q2.head()
frames = [df_resume,
          df_comb_double_q2[df_comb_double_q2["quantity"]=="(MmTr-MmMn)"][["quantity", "win", "wl", "cv_mean"]], 
          df_comb_double_q2[df_comb_double_q2["quantity"]=="(MmTr-MmMn-MmMx)"][["quantity", "win", "wl", "cv_mean"]], 
          df_comb_double_q2[df_comb_double_q2["quantity"]=="(MmTr-MmMn-MmMx-TrMn)"][["quantity", "win", "wl", "cv_mean"]]]
df_resume = pd.concat(frames)
all_frames.append(df_comb_triple_q2)
plt.figure(figsize=(16, 4))
b = snb.boxplot(x="quantity", y="cv_mean", data=df_comb_triple_q2)
plt.ylabel("Cross-Validation accuracy", fontsize=16)
plt.xlabel("Statistical Quantity", fontsize=16)
plt.title("Triple-quantity combinations evaluation", fontsize=18)
plt.yticks(fontsize=14)
plt.xticks(fontsize=14)
plt.tight_layout()

plt.savefig("figs/triple_q_comb_evaluations.png", dpi=350)<jupyter_output><empty_output><jupyter_text>RESUME<jupyter_code>def resume_quantity_search(df1, df2, df3):
    df1 = df1.reset_index()
    df2 = df2.reset_index()
    df3 = df3.reset_index()
    
    qs1 = np.unique(df1["quantity"])
    qs2 = np.unique(df2["quantity"])
    qs3 = np.unique(df3["quantity"])
    print(qs1)
    
    idxs = []
    for q in qs1:
        df_tmp = df1[df1["quantity"] == q]
        high_idx = np.argmax(df_tmp["cv_mean"])
        idxs.append(high_idx)
    print(idxs, len(df1))
    df1_bests = df1.iloc[idxs]
    df1_bests["type"] = np.array(["Single-Q"] * len(df1_bests))
    
    idxs = []
    for q in qs2:
        high_idx = np.argmax(df2[df2["quantity"] == q]["cv_mean"])
        idxs.append(high_idx)
    df2_bests = df2.iloc[idxs]
    df2_bests["type"] = np.array(["Double-Q"] * len(df2_bests))
    
    idxs = []
    for q in qs3:
        high_idx = np.argmax(df3[df3["quantity"] == q]["cv_mean"])
        idxs.append(high_idx)
    df3_bests = df3.iloc[idxs]
    df3_bests["type"] = np.array(["Triple-Q"] * len(df3_bests))
    
    res_df = pd.concat([df1_bests, df2_bests, df3_bests])
    return res_df[["quantity", "type", "cv_mean", "cv_std", "win", "wl", "alpha", "dropped", "bopf_shape", "cv_time"]]
df = resume_quantity_search(df_comb_single_q2, df_comb_double_q2, df_comb_triple_q2)
df = df.sort_values("cv_mean", ascending=False)
df
plt.figure(figsize=(16, 4))
b = snb.boxplot(x="cv_mean", y="quantity", data=df_resume)
plt.xlabel("Cross-Validation accuracy", fontsize=16)
plt.ylabel("Statistical Quantity", fontsize=16)
plt.title("Multi-quantity search summary", fontsize=18)
plt.yticks(fontsize=14)
plt.xticks(fontsize=14)
plt.tight_layout()

plt.savefig("figs/multi-quantity-search-result.png", dpi=350)
df_all = pd.concat(all_frames)
df_all = df_all.sort_values("cv_mean", ascending=False)
plt.figure(figsize=(14, 18))
b = snb.boxplot(x="cv_mean", y="quantity", data=df_all)
plt.xlabel("Cross-Validation accuracy", fontsize=16)
plt.ylabel("Statistical Quantity", fontsize=16)
plt.title("Multi-quantity search summary", fontsize=20)
plt.yticks(fontsize=15)
plt.xticks(fontsize=15)
plt.tight_layout()

plt.savefig("figs/multi-quantity-search-all-results.png", dpi=350)<jupyter_output><empty_output><jupyter_text>TIME COMPLEXITY BOPF METHOD<jupyter_code>def time_complexity(dfs):
    dfs_arr = []
    for i, dfs_i in enumerate(dfs):
        dfs_i["n_q"] = [i+1] * len(dfs_i)
        dfs_arr.append(dfs_i)
    
    df = pd.concat(dfs_arr)
    df["features"] = [row.alpha ** (row.wl * row.n_q) for index, row in df.iterrows()]
    df["x"] = [row.wl * row.n_q for index, row in df.iterrows()]
    x = df["x"].to_numpy()
    y = df["bopf_time"].to_numpy()
    return x, y
x, y = time_complexity([df_single_q, df_double_q, df_triple_q])
plt.plot(x, y, ".")
plt.xlabel(r"$log_{\alpha}(N)$")
plt.ylabel("Time (sec.)")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16448010408760708, 'fraction_numerical': 0.03220210343705952, 'mean_word_length': 7.400728597449909, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, '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': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '489285', 'license': 'MIT', 'n_tokens_mistral': 4130, 'n_tokens_neox': 3812, 'n_words': 471, 'path': 'notebooks/quantity_search.ipynb', 'repo_name': 'frmunozz/irregular-bag-of-pattern', 'size': '9223'}