-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
10,596 additions
and
0 deletions.
There are no files selected for viewing
1,228 changes: 1,228 additions & 0 deletions
1,228
notebooks/daaf_analyses/control/exp-policycontrol-v1-s0-regret.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
2,012 changes: 2,012 additions & 0 deletions
2,012
notebooks/daaf_analyses/control/exp-policycontrol-v1-s1-stattest-results.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
3,569 changes: 3,569 additions & 0 deletions
3,569
notebooks/daaf_analyses/control/exp-policycontrol-v1-s2-sigma-returntest.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
871 changes: 871 additions & 0 deletions
871
notebooks/daaf_analyses/control/exp-policycontrol-v1-s3-bestmethod.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
2,794 changes: 2,794 additions & 0 deletions
2,794
notebooks/daaf_analyses/control/exp-policycontrol-v1-s4-returnplots.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+11.3 KB
...analyses/control/figures/bestmethod/.ipynb_checkpoints/bestmethod_one-step-checkpoint.pdf
Binary file not shown.
Binary file added
BIN
+41.9 KB
notebooks/daaf_analyses/control/figures/bestmethod/bestmethod_n-step.pdf
Binary file not shown.
Binary file added
BIN
+46.6 KB
notebooks/daaf_analyses/control/figures/bestmethod/bestmethod_one-step.pdf
Binary file not shown.
Binary file added
BIN
+43.2 KB
.../daaf_analyses/control/figures/regret/.ipynb_checkpoints/regret_n-step_all-checkpoint.pdf
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+30.2 KB
notebooks/daaf_analyses/control/figures/regret/regret_one-step_all.pdf
Binary file not shown.
Binary file added
BIN
+28.6 KB
notebooks/daaf_analyses/control/figures/regret/regret_one-step_nooptions.pdf
Binary file not shown.
Binary file added
BIN
+19.2 KB
...gures/returnplots/.ipynb_checkpoints/rc_q-learning_ABCSeq_n=7_1.0_one-step-checkpoint.pdf
Binary file not shown.
Binary file added
BIN
+63.6 KB
...ooks/daaf_analyses/control/figures/returnplots/rc_nstep-sarsa_ABCSeq_n=10_0.99_n-step.pdf
Binary file not shown.
Binary file added
BIN
+63.5 KB
...books/daaf_analyses/control/figures/returnplots/rc_nstep-sarsa_ABCSeq_n=10_1.0_n-step.pdf
Binary file not shown.
Binary file added
BIN
+63.3 KB
...books/daaf_analyses/control/figures/returnplots/rc_nstep-sarsa_ABCSeq_n=7_0.99_n-step.pdf
Binary file not shown.
Binary file added
BIN
+63.2 KB
notebooks/daaf_analyses/control/figures/returnplots/rc_nstep-sarsa_ABCSeq_n=7_1.0_n-step.pdf
Binary file not shown.
Binary file added
BIN
+69.3 KB
...aaf_analyses/control/figures/returnplots/rc_nstep-sarsa_FrozenLake-v1_4x4_0.99_n-step.pdf
Binary file not shown.
Binary file added
BIN
+69.8 KB
...s/daaf_analyses/control/figures/returnplots/rc_nstep-sarsa_FrozenLake-v1_4x4_1_n-step.pdf
Binary file not shown.
Binary file added
BIN
+59.2 KB
...s/daaf_analyses/control/figures/returnplots/rc_nstep-sarsa_GridWorld_4x12_0.99_n-step.pdf
Binary file not shown.
Binary file added
BIN
+55 KB
...ooks/daaf_analyses/control/figures/returnplots/rc_nstep-sarsa_GridWorld_4x12_1_n-step.pdf
Binary file not shown.
Binary file added
BIN
+65.3 KB
...oks/daaf_analyses/control/figures/returnplots/rc_nstep-sarsa_IceWorld_4x4_0.99_n-step.pdf
Binary file not shown.
Binary file added
BIN
+65.3 KB
notebooks/daaf_analyses/control/figures/returnplots/rc_nstep-sarsa_IceWorld_4x4_1_n-step.pdf
Binary file not shown.
Binary file added
BIN
+67 KB
...oks/daaf_analyses/control/figures/returnplots/rc_nstep-sarsa_IceWorld_8x8_0.99_n-step.pdf
Binary file not shown.
Binary file added
BIN
+66 KB
notebooks/daaf_analyses/control/figures/returnplots/rc_nstep-sarsa_IceWorld_8x8_1_n-step.pdf
Binary file not shown.
Binary file added
BIN
+63.6 KB
.../daaf_analyses/control/figures/returnplots/rc_nstep-sarsa_RedGreenSeq_n=9_0.99_n-step.pdf
Binary file not shown.
Binary file added
BIN
+63.8 KB
...oks/daaf_analyses/control/figures/returnplots/rc_nstep-sarsa_RedGreenSeq_n=9_1_n-step.pdf
Binary file not shown.
Binary file added
BIN
+60.1 KB
..._analyses/control/figures/returnplots/rc_nstep-sarsa_TowerOfHanoi_disks=4_0.99_n-step.pdf
Binary file not shown.
Binary file added
BIN
+60.1 KB
...aaf_analyses/control/figures/returnplots/rc_nstep-sarsa_TowerOfHanoi_disks=4_1_n-step.pdf
Binary file not shown.
Binary file added
BIN
+19.7 KB
...oks/daaf_analyses/control/figures/returnplots/rc_q-learning_ABCSeq_n=10_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+19.7 KB
...ooks/daaf_analyses/control/figures/returnplots/rc_q-learning_ABCSeq_n=10_1.0_one-step.pdf
Binary file not shown.
Binary file added
BIN
+19.3 KB
...ooks/daaf_analyses/control/figures/returnplots/rc_q-learning_ABCSeq_n=7_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+19.2 KB
...books/daaf_analyses/control/figures/returnplots/rc_q-learning_ABCSeq_n=7_1.0_one-step.pdf
Binary file not shown.
Binary file added
BIN
+21.8 KB
...af_analyses/control/figures/returnplots/rc_q-learning_FrozenLake-v1_4x4_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+21.3 KB
.../daaf_analyses/control/figures/returnplots/rc_q-learning_FrozenLake-v1_4x4_1_one-step.pdf
Binary file not shown.
Binary file added
BIN
+16.7 KB
.../daaf_analyses/control/figures/returnplots/rc_q-learning_GridWorld_4x12_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+16.7 KB
...oks/daaf_analyses/control/figures/returnplots/rc_q-learning_GridWorld_4x12_1_one-step.pdf
Binary file not shown.
Binary file added
BIN
+20 KB
...ks/daaf_analyses/control/figures/returnplots/rc_q-learning_IceWorld_4x4_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+20.8 KB
...books/daaf_analyses/control/figures/returnplots/rc_q-learning_IceWorld_4x4_1_one-step.pdf
Binary file not shown.
Binary file added
BIN
+21.3 KB
...ks/daaf_analyses/control/figures/returnplots/rc_q-learning_IceWorld_8x8_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+21.3 KB
...books/daaf_analyses/control/figures/returnplots/rc_q-learning_IceWorld_8x8_1_one-step.pdf
Binary file not shown.
Binary file added
BIN
+19.4 KB
...daaf_analyses/control/figures/returnplots/rc_q-learning_RedGreenSeq_n=9_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+19.1 KB
...ks/daaf_analyses/control/figures/returnplots/rc_q-learning_RedGreenSeq_n=9_1_one-step.pdf
Binary file not shown.
Binary file added
BIN
+18.4 KB
...analyses/control/figures/returnplots/rc_q-learning_TowerOfHanoi_disks=4_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+18.2 KB
...af_analyses/control/figures/returnplots/rc_q-learning_TowerOfHanoi_disks=4_1_one-step.pdf
Binary file not shown.
Binary file added
BIN
+19.6 KB
notebooks/daaf_analyses/control/figures/returnplots/rc_sarsa_ABCSeq_n=10_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+19.6 KB
notebooks/daaf_analyses/control/figures/returnplots/rc_sarsa_ABCSeq_n=10_1.0_one-step.pdf
Binary file not shown.
Binary file added
BIN
+19.3 KB
notebooks/daaf_analyses/control/figures/returnplots/rc_sarsa_ABCSeq_n=7_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+19.2 KB
notebooks/daaf_analyses/control/figures/returnplots/rc_sarsa_ABCSeq_n=7_1.0_one-step.pdf
Binary file not shown.
Binary file added
BIN
+22 KB
...ks/daaf_analyses/control/figures/returnplots/rc_sarsa_FrozenLake-v1_4x4_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+22.4 KB
...books/daaf_analyses/control/figures/returnplots/rc_sarsa_FrozenLake-v1_4x4_1_one-step.pdf
Binary file not shown.
Binary file added
BIN
+16.6 KB
...books/daaf_analyses/control/figures/returnplots/rc_sarsa_GridWorld_4x12_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+16.7 KB
notebooks/daaf_analyses/control/figures/returnplots/rc_sarsa_GridWorld_4x12_1_one-step.pdf
Binary file not shown.
Binary file added
BIN
+20.8 KB
notebooks/daaf_analyses/control/figures/returnplots/rc_sarsa_IceWorld_4x4_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+20.7 KB
notebooks/daaf_analyses/control/figures/returnplots/rc_sarsa_IceWorld_4x4_1_one-step.pdf
Binary file not shown.
Binary file added
BIN
+23.3 KB
notebooks/daaf_analyses/control/figures/returnplots/rc_sarsa_IceWorld_8x8_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+22.9 KB
notebooks/daaf_analyses/control/figures/returnplots/rc_sarsa_IceWorld_8x8_1_one-step.pdf
Binary file not shown.
Binary file added
BIN
+18.9 KB
...ooks/daaf_analyses/control/figures/returnplots/rc_sarsa_RedGreenSeq_n=9_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+18.8 KB
notebooks/daaf_analyses/control/figures/returnplots/rc_sarsa_RedGreenSeq_n=9_1_one-step.pdf
Binary file not shown.
Binary file added
BIN
+18.3 KB
...daaf_analyses/control/figures/returnplots/rc_sarsa_TowerOfHanoi_disks=4_0.99_one-step.pdf
Binary file not shown.
Binary file added
BIN
+18.1 KB
...ks/daaf_analyses/control/figures/returnplots/rc_sarsa_TowerOfHanoi_disks=4_1_one-step.pdf
Binary file not shown.
Binary file added
BIN
+21.8 KB
notebooks/daaf_analyses/control/figures/returnsigmatest/returnsigma_n-step.pdf
Binary file not shown.
Binary file added
BIN
+20.9 KB
notebooks/daaf_analyses/control/figures/returnsigmatest/returnsigma_one-step.pdf
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import collections | ||
import copy | ||
import importlib | ||
import os | ||
import pathlib | ||
import uuid | ||
from typing import Any, Mapping, Sequence | ||
|
||
import matplotlib as mpl | ||
import numpy as np | ||
import pandas as pd | ||
import ray | ||
import scipy | ||
import seaborn as sns | ||
import tensorflow as tf | ||
from daaf import estimator_metrics | ||
from matplotlib import pyplot as plt | ||
from scipy import stats | ||
from statsmodels.stats import proportion | ||
|
||
ENVS_MAPPING = { | ||
( | ||
"IceWorld", | ||
"4KE3ASUFQGGUPERSDDRQAZAMA46CI2CMCJHGWJ7MRNI64JMEBETNDXFFPYWTQJF46S5BJ4NXXCHNMJSLII3ROYXI76DFOC3VAABGNVA=", | ||
): {"args": '{"map_name": "4x4"}', "name": "4x4"}, | ||
("ABCSeq", "10"): { | ||
"args": '{"length": 10, "distance_penalty": false}', | ||
"name": "n=10", | ||
}, | ||
( | ||
"RedGreenSeq", | ||
"NNLHYJFTC5ENMMDZWRNQ37B6VVDXQ7WHB5EJOPXYZFLMJEZOYLTSLB4ID4WHQG57XQPNUHGZCFDCWHYGXWSBW7FBWYRZGAGBW4J7MEQ=", | ||
): { | ||
"args": '{"cure": ["red", "green", "wait", "green", "red", "red", "green", "wait"]}', | ||
"name": "n=9", | ||
}, | ||
( | ||
"FrozenLake-v1", | ||
"U75ZLQLLXYRFQE5KOJJGNVQZGQ65U5RVVN3ZV5F4UNYQVK6NGTAAU62O2DKMOEGACNNUQOSWGYYOV7LQHK7GAWG2CL3U3RZJFIEIB5I=", | ||
): {"args": '{"is_slippery": false, "map_name": "4x4"}', "name": "4x4"}, | ||
("TowerOfHanoi", "4"): {"args": '{"num_disks": 4}', "name": "disks=4"}, | ||
("ABCSeq", "7"): { | ||
"args": '{"length": 7, "distance_penalty": false}', | ||
"name": "n=7", | ||
}, | ||
( | ||
"IceWorld", | ||
"JKNDNWGM45FELU53ZLLVJEPY2SFZBCX54PSACOQOFMTDUAK5VNQ4KE45QZINGYFU5GR6D7F3GJMW7EC4TAY5PHCYRN5GPGP7YNACHEI=", | ||
): {"args": '{"map_name": "8x8"}', "name": "8x8"}, | ||
( | ||
"GridWorld", | ||
"P3VJZBIJ7PNUOFG2SCF532NH5AQ6NOBZEZ6UZNZ7D3AU3GQZSLKURMS2SRPEUF6O65F3ETJXEFNTR3UYS73TUCIIU3YIONXHAR6WE5A=", | ||
): { | ||
"args": '{"grid": "oooooooooooo\\noooooooooooo\\noooooooooooo\\nsxxxxxxxxxxg"}', | ||
"name": "4x12", | ||
}, | ||
} | ||
|
||
|
||
# single-step', 'option | ||
MAPPERS_NAMES = { | ||
"identity-mapper": "FR", | ||
"daaf-impute-missing-reward-mapper": "IMR", | ||
"daaf-lsq-reward-attribution-mapper": "LEAST", | ||
"daaf-nstep-td-update-mark-mapper": "nTD-SU", | ||
"daaf-mdp-with-options-mapper": "OT", | ||
} | ||
|
||
POLICY_NAMES = {"options": "OP", "single-step": "PP"} | ||
|
||
|
||
def process_data(df_raw, envs_mapping): | ||
def get_method(meta: Mapping[str, Any]): | ||
return "/".join([meta["policy_type"], meta["traj_mapping_method"]]) | ||
|
||
def simplify_meta(meta): | ||
new_meta = copy.deepcopy(meta) | ||
name = new_meta["env"]["name"] | ||
level = new_meta["env"]["level"] | ||
spec = envs_mapping.get((name, level), {"name": level}) | ||
new_meta["env"]["_level"] = level | ||
new_meta["env"]["level"] = spec["name"] | ||
new_meta["traj_mapping_method"] = MAPPERS_NAMES[new_meta["traj_mapping_method"]] | ||
new_meta["policy_type"] = POLICY_NAMES[new_meta["policy_type"]] | ||
return new_meta | ||
|
||
df_proc = copy.deepcopy(df_raw) | ||
df_proc["meta"] = df_proc["meta"].apply(simplify_meta) | ||
df_proc["method"] = df_proc["meta"].apply(get_method) | ||
return df_proc | ||
|
||
|
||
def read_data(files): | ||
ds_metrics = ray.data.read_parquet(files) | ||
df_metrics = ds_metrics.to_pandas() | ||
return process_data(df_metrics, envs_mapping=ENVS_MAPPING) | ||
|
||
|
||
def wide_metrics(df_metrics): | ||
df_raw = df_metrics.drop(["metrics"], axis=1, inplace=False) | ||
return df_raw.explode("returns") | ||
|
||
|
||
def get_distinct_envs(df_data: pd.DataFrame): | ||
envs = {} | ||
for row in pd.DataFrame(df_data["meta"]).to_dict("records"): | ||
env = row["meta"]["env"] | ||
key = (env["name"], env["level"]) | ||
envs[key] = env["args"] | ||
return envs | ||
|
||
|
||
def drop_duplicate_sets(df_data: pd.DataFrame, keys): | ||
col = str(uuid.uuid4()) | ||
rows = [] | ||
for row in df_data.to_dict("records"): | ||
col_set = sorted([row[key] for key in keys]) | ||
new_row = copy.deepcopy(row) | ||
new_row[col] = col_set | ||
rows.append(new_row) | ||
df_raw = pd.DataFrame(rows) | ||
return df_raw.drop_duplicates(col).drop([col], axis=1) |