<jupyter_start><jupyter_text>ACS experiment performance (barchart) Here we plot Figure 4B<jupyter_code>import os
from pathlib import Path
import numpy as np
import matplotlib.pyplot as plt
import sklearn.metrics
from mosaiks import config as c
from mosaiks.plotting import fig_2_functions as f2
%matplotlib inline
save_dir = Path(c.res_dir, "figures", "Fig4")
save_dir.mkdir(exist_ok=True, parents=True)<jupyter_output><empty_output><jupyter_text>Get task names in the specified order<jupyter_code>c.app_order = [
    "B08303",
    "B15003",
    "B19013",
    "B19301",
    "C17002",
    "B22010",
    "B25071",
    "B25001",
    "B25002",
    "B25035",
    "B25017",
    "B25077",
]
# get task names
c_by_app_acs = [getattr(c, i) for i in c.app_order]
tasks = [config["application"] for config in c_by_app_acs]
num_tasks = len(tasks)

task_names_acs = np.array([config["disp_name_short"] for config in c_by_app_acs])<jupyter_output><empty_output><jupyter_text>Grab and aggregate the data files from the primary analysis for plotting<jupyter_code>data_by_task_acs = f2.aggregrate_and_bin_data(agg_scale=0.2, is_ACS=True)
print("dataset sizes are:")
[
    print("{0}: {1}".format(tasks[t], len(data_by_task_acs["truth_by_task"][t])))
    for t in range(num_tasks)
]<jupyter_output>/shares/lab/Datasets/Remote_Sensing/replication/code_JP/code/mosaiks/plotting/fig_2_functions.py:350: RuntimeWarning: invalid value encountered in true_divide
  vals_grid = sums_grid / counts<jupyter_text>Plot  Fig 2<jupyter_code># collect and plot r2s for ACS regs:
r2s_acs = np.zeros(len(tasks))
for i in range(len(tasks)):
    y_pred_this = data_by_task_acs["preds_by_task"][i]
    y_true_this = data_by_task_acs["truth_by_task"][i]
    r2s_acs[i] = sklearn.metrics.r2_score(y_true_this, y_pred_this)

acs_descending_order = np.argsort(r2s_acs)
fig, ax = plt.subplots(figsize=(10, 10))
plt.barh(
    task_names_acs[acs_descending_order], r2s_acs[acs_descending_order], color="grey"
)
fig.savefig(save_dir / "ACS_barchart.pdf")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12015693967631191, 'fraction_numerical': 0.04119666503187837, 'mean_word_length': 6.208480565371024, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '388019', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 869, 'n_tokens_neox': 807, 'n_words': 153, 'path': 'code/analysis/3_figures_and_tables/Fig4_global_ACS_and_SR/ACS/2_make_fig.ipynb', 'repo_name': 'Global-Policy-Lab/mosaiks-paper', 'size': '2039'}