<jupyter_start><jupyter_text>1. Classification Complexity Measures 1. Neural Network<jupyter_code>measures = cm.get_measures()

DFS = list()
for preprocessing in measures["neuralnetwork"]:
    sub_result = dict()
    for subset in sorted(measures["neuralnetwork"][preprocessing]):
        dic = measures["neuralnetwork"][preprocessing][subset]
        l = np.array([d["test_accuracy"][-1] for d in dic])
        sub_result[subset] = dict()
        sub_result[subset][preprocessing+"_mean"] = l.mean()
        sub_result[subset][preprocessing+"_std"] = l.std()
    df = pd.DataFrame.from_dict(sub_result, orient="index")
    DFS.append(df)

df = pd.concat(DFS, axis=1)
df["Overall_mean"] = df[[col for col in df.columns if "mean" in col]].mean(axis=1)
df["Overall_std"] = df[[col for col in df.columns if "mean" in col]].std(axis=1)
#std of means 
df.loc['Total Mean',:] = df.mean(axis=0)
df

plt.figure(figsize=(10,7)) 
plt.title("Histogram of std between different preprocessing methods \n $\sigma$={:.3f}  $\mu$={:.3f}".format(df["Overall_std"].std(), df["Overall_std"].mean()))
plt.hist(df["Overall_std"], bins=15)
plt.show()
df.drop(df[df.index == "Total Mean"].index, inplace=True)
df["Overall_mean_round"] = df["Overall_mean"].round(3)
df.sort_values(by="Overall_mean", ascending=False)
df_pca = df[["PCA_mean", "PCA_std"]]
df_pca = df_pca.sort_values(by="PCA_mean", ascending=False)
#add rank to df
df_pca["type"] = "pca"
df_pca["rank"] = [i for i in range(1, len(df_pca)+1)]
df_pca.columns = ["mean", "std", "type", "rank"]

# do same for autoencoder and raw
df_ae = df[["Autoencoder_mean", "Autoencoder_std"]]
df_ae = df_ae.sort_values(by="Autoencoder_mean", ascending=False)
df_ae["type"] = "ae"
df_ae["rank"] = [i for i in range(1,     len(df_ae)+1)]
df_ae.columns = ["mean", "std", "type", "rank"]

df_join = pd.concat([df_pca, df_ae], axis=0)
pd.concat([df_pca, df_ae], axis=1)
66+18
df_join = df_join.sort_index()
df_join
fig, ax = plt.subplots(figsize=(7,15))

i=0
for subset in df_join.index:
    if "6" in subset:
        temp = df_join[df_join.index == subset]
        ax.plot(temp["type"], temp["rank"], label=subset)
        plt.text("ae", temp["rank"][temp["type"] == "ae"]+0.5, "{:.2f}".format(temp["mean"][temp["type"] == "ae"][0]), ha='right')
        plt.text("ae", temp["rank"][temp["type"] == "ae"], subset, ha='right')
        plt.text("pca", temp["rank"][temp["type"] == "pca"]+0.5, "{:.2f}".format(temp["mean"][temp["type"] == "pca"][0]), ha='left')
        plt.text("pca", temp["rank"][temp["type"] == "pca"], subset, ha='left')
    i+=1


ax.set_yticks(np.arange(1, 45+1))
ax.set_ylim(46, 0)

ax2 = ax.twinx()
ax2.set_yticks(np.arange(1, 45+1))
ax2.set_ylim(46,0)

plt.show()

data = ds.get_preprocessed_datasets("Autoencoder","PCA")
h.plot_grid(data["Autoencoder"]["3,6"]["x_test"], data["Autoencoder"]["3,6"]["y_test"],rows=4)
h.plot_grid(data["PCA"]["3,6"]["x_test"], data["PCA"]["3,6"]["y_test"],rows=4)
fig,ax = plt.subplots(figsize=(7,15))
df_plot = df.sort_values(by="Overall_mean", ascending=True)

ax.set_xlim(1.01, 0.59)
ax.scatter(df_plot["Overall_mean_round"], df_plot.index,marker="_", linestyle="None",s=df_plot["Overall_std"]*1000)
plt.show()<jupyter_output><empty_output><jupyter_text>2. Fischer<jupyter_code>measures = cm.get_measures()

DFS = list()
for preprocessing in measures["fischer"]:
    sub_result = dict()
    for subset in sorted(measures["fischer"][preprocessing]):
        dic = measures["fischer"][preprocessing][subset]
        sub_result[subset] = dic
    df = pd.DataFrame.from_dict(sub_result, orient="index")
    DFS.append(df)

df = pd.concat(DFS, axis=1)
df.columns = measures["fischer"].keys()
#std of means 
df.loc['Total Mean',:] = df.mean(axis=0)
df<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.21390516782099095, 'fraction_numerical': 0.02184336707511987, 'mean_word_length': 5.777978339350181, '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': '239598', 'license': 'MIT', 'n_tokens_mistral': 1527, 'n_tokens_neox': 1484, 'n_words': 254, 'path': 'praktikum/auswertung.ipynb', 'repo_name': 'FelixBieswanger/masKIT', 'size': '3754'}