<jupyter_start><jupyter_text>Simulation 1 - Plotting<NAME> | July 8, 2019Visualize the simulation results using high-quality `Seaborn` relplots.<jupyter_code>import glob
import re

import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns<jupyter_output><empty_output><jupyter_text>Sample size vs Power<jupyter_code>dfs = []

for file in glob.glob("results/power/m*.csv"):
    
    # Get the sample size
    sample_size = re.split("[//m.]", file)[3]
    
    # Read csv and add sample_size as column
    df = pd.read_csv(file)
    df["m"] = int(sample_size)
    dfs.append(df)

# Combine dfs in to a single DataFrame
df = pd.concat(dfs)

# Organize the dataframe
df = df.sort_values(by=["m", "$p_{ij}$",])
df = df.drop("Unnamed: 0", axis=1)
df = df.reset_index(drop="True")

# Look at the final result
print(df.shape)
df.head()
sns.set()

g = sns.relplot(
    x=r"$p_{ij}$",
    y="power",
    hue="test",
    col="m",
    col_wrap=5,
    data=df,
    legend="full",
    kind="line",
)

for ax in g.axes.flatten():
    ax.set_xlim(-0.05, 1.05)
    ax.set_ylim(-0.05, 1.05)

plt.savefig("power.png", dpi=300)
plt.show()<jupyter_output><empty_output><jupyter_text>Sample size vs Type 1 Error<jupyter_code>dfs = []

for file in glob.glob("results/type1/m*.csv"):
    
    # Get the sample size
    sample_size = re.split("[//m.]", file)[3]
    
    # Read csv and add sample_size as column
    df = pd.read_csv(file)
    df["m"] = int(sample_size)
    dfs.append(df)

# Combine dfs in to a single DataFrame
df = pd.concat(dfs)

# Organize the dataframe
df = df.sort_values(by=["m", "$p_{ij}$",])
df = df.drop("Unnamed: 0", axis=1)
df = df.reset_index(drop="True")

# Look at the final result
print(df.shape)
df.head()
sns.set()

g = sns.relplot(
    x=r"$p_{ij}$",
    y="type1",
    hue="test",
    col="m",
    col_wrap=5,
    data=df,
    legend="full",
    kind="line",
)

for ax in g.axes.flatten():
    ax.axhline(0.05, color="k", label=r"$\alpha=0.05$")
    ax.set_xlim(-0.05, 1.05)
    ax.set_ylim(-0.01, 0.16)

plt.savefig("type1.png", dpi=300)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17513051732320836, 'fraction_numerical': 0.025628856193640248, 'mean_word_length': 3.6228070175438596, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '368004', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 904, 'n_tokens_neox': 869, 'n_words': 185, 'path': 'experiments/experiment_1/VG/VG-experiment1-plotting.ipynb', 'repo_name': 'neurodata/dos_and_donts', 'size': '2121'}