-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_local_test.py
112 lines (87 loc) · 2.59 KB
/
main_local_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
"""
Run simulations and save results
"""
import os
import numpy as np
from settings.config_triton import Config
from run.make_data_triton import run
from model.learner.exponential import Exponential
from model.learner.walsh2018 import Walsh2018
from model.psychologist.psychologist_grid import PsyGrid
from model.teacher.leitner import Leitner
from model.teacher.myopic import Myopic
from model.teacher.conservative import Conservative
from model.teacher.robust import Robust
def dic_to_lab_val(dic):
lab = list(dic.keys())
val = [dic[k] for k in dic]
return lab, val
def main():
n_item = 500
omni = True
teacher_md = Myopic
learner_md = Exponential
pr_val = [[2e-05, 0.5]
for _ in range(n_item)]
is_item_specific = len(np.asarray(pr_val).shape) > 1
psy_md = PsyGrid
ss_n_iter = 100
time_between_ss = 24 * 60**2
n_ss = 6
learnt_threshold = 0.9
time_per_iter = 4
leitner_cst = {"delay_factor": 2, "delay_min": 4}
pr_lab = ["alpha", "beta"],
bounds = [[2e-07, 0.025], [0.0001, 0.9999]]
grid_methods = [PsyGrid.GEO, PsyGrid.LIN]
grid_size = 100
cst_time = 1
assert learner_md == Exponential
if teacher_md == Leitner:
teacher_pr = leitner_cst
elif teacher_md in (Myopic, Conservative, Robust):
teacher_pr = {}
else:
raise ValueError
teacher_pr_lab, teacher_pr_val = dic_to_lab_val(teacher_pr)
assert psy_md == PsyGrid
psy_pr_lab = [
"grid_size", "grid_methods"
]
psy_pr_val = [
grid_size, grid_methods
]
config = Config(
data_folder="data/local",
config_file=None,
config_dic={},
seed=0,
agent=0,
bounds=bounds,
md_learner=learner_md.__name__,
md_psy=psy_md.__name__,
md_teacher=teacher_md.__name__,
omni=omni,
n_item=n_item,
is_item_specific=is_item_specific,
ss_n_iter=ss_n_iter,
time_between_ss=time_between_ss,
n_ss=n_ss,
learnt_threshold=learnt_threshold,
time_per_iter=time_per_iter,
cst_time=cst_time,
teacher_pr_lab=teacher_pr_lab,
teacher_pr_val=teacher_pr_val,
psy_pr_lab=psy_pr_lab,
psy_pr_val=psy_pr_val,
pr_lab=pr_lab,
pr_val=pr_val,
)
df = run(config=config, with_tqdm=True)
f_name = f"{learner_md.__name__}-" \
f"{psy_md.__name__}-" \
f"{teacher_md.__name__}.csv"
os.makedirs(config.data_folder, exist_ok=True)
df.to_csv(os.path.join(config.data_folder, f_name))
if __name__ == "__main__":
main()