<jupyter_start><jupyter_text>Read the data from GP, XGB, and FFNN<jupyter_code>df = pd.read_csv("comparison.csv")<jupyter_output><empty_output><jupyter_text>Read the ChemProp data<jupyter_code>cp_df = pd.read_csv("cp_comparison.csv")<jupyter_output><empty_output><jupyter_text>Merge the two datasets<jupyter_code>df = df.merge(cp_df,on=["dataset","split"])<jupyter_output><empty_output><jupyter_text>Label the datasets with random and scaffold splits<jupyter_code>df['random'] = [x.startswith("RND") for x in df.split]<jupyter_output><empty_output><jupyter_text>Split the datasets into two dataframes, one for scaffold splits and one for random splits<jupyter_code>df_rnd = df.query("random")
df_scaf = df.query("random == False")
df_rnd
df_scaf<jupyter_output><empty_output><jupyter_text>A simple function to count the number of lines in a file, we'll use this to order the datasets from smallest to largest<jupyter_code>def count_lines(file_name):
    return sum(1 for line in open(file_name))<jupyter_output><empty_output><jupyter_text>Put the datasets in order from smallest to largest<jupyter_code>line_counts = [[x.split("/")[-1].replace(".smi",""),count_lines(x)] for x in glob("data/*.smi")]
df_line_count = pd.DataFrame(line_counts,columns=['dataset','count'])
df_line_count.sort_values("count",inplace=True)
sort_order = df_line_count.dataset.values<jupyter_output><empty_output><jupyter_text>Create the y-axis labels for the boxplots with the number of molecules in the dataset and the dataset name<jupyter_code>target_labels = [f"{a} {b}" for a,b in df_line_count[["dataset","count"]].values]<jupyter_output><empty_output><jupyter_text>A function to draw boxplots showing performance over multiple folds of cross validation<jupyter_code>def draw_boxplots(df,title):
    r2_cols = ["dataset"] + [x for x in df.columns if x.find("r2") > 0]
    rms_cols = ["dataset"] + [x for x in df.columns if x.find("rms") > 0]
    r2_df = df[r2_cols].melt(id_vars="dataset")
    rms_df = df[rms_cols].melt(id_vars="dataset")
    r2_df.columns = ['Dataset',"algorithm","R2"]
    rms_df.columns = ['Dataset',"algorithm","RMSE"]
    r2_df['Method'] = [x.split("_")[0].upper() for x in r2_df.algorithm]
    rms_df['Method'] = [x.split("_")[0].upper() for x in rms_df.algorithm]
    sns.set(rc={'figure.figsize': (15, 18)})
    sns.set_context('talk')
    ax = sns.boxplot(x="R2",y="Dataset",data=r2_df,orient="h",hue="Method",order=sort_order)
    for i in range(0,len(df.dataset.unique())):
        ax.axhline(0.5+i,linestyle="--",color="grey")
    ax.set(xlabel="R${^2}$")
    ax.set(yticklabels=target_labels)
    ax.set(title=title)
    plt.show()
    plt.tight_layout()
    ax.figure.savefig(title.replace(" ","_")+"_r2.png",bbox_inches='tight')
    ax = sns.boxplot(x="RMSE",y="Dataset",data=rms_df,orient="h",hue="Method",order=sort_order)
    for i in range(0,len(df.dataset.unique())):
        ax.axhline(0.5+i,linestyle="--",color="grey")
    ax.set(title=title)
    ax.set(yticklabels=target_labels)
    plt.show()
    ax.figure.savefig(title.replace(" ","_")+"_rmse.png",bbox_inches='tight');
draw_boxplots(df_rnd,"Random Split")
draw_boxplots(df_scaf,"Scaffold Split")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16541822721598, 'fraction_numerical': 0.008739076154806492, 'mean_word_length': 6.685851318944844, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 39, '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': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '323699', 'license': 'MIT', 'n_tokens_mistral': 1232, 'n_tokens_neox': 1204, 'n_words': 207, 'path': 'analysis.ipynb', 'repo_name': 'PatWalters/yamc', 'size': '3204'}