-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_synthetic_data.py
58 lines (50 loc) · 2.38 KB
/
run_synthetic_data.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
"""
==============================================
=== ===
=== _____ ______ ________ ===
=== |_ _| |_ _ `. |_ __ | ===
=== | | | | `. \ | |_ \_| ===
=== | | _ | | | | | _| _ ===
=== _| |__/ | _| |_.' / _| |__/ | ===
=== |________| |______.' |________| ===
=== ===
=== ===
==============================================
Limited Data Estimator -- LDE
This module reproduces the results of the synthetic data example from our NeurIPS 2021 submission.
"""
from synthetic_data.SyntheticBanditEnv import SyntheticBanditEnv
import argparse
def setup():
'''setup the experiment'''
parser = argparse.ArgumentParser(description='argument parser for example 1')
parser.add_argument('-d', '--example',
default='1',
help='number of the reeard function: 1 or 2')
parser.add_argument('-s', '--seed',
default=2021,
help='value of random seed')
parser.add_argument('-save', '--save', action='store_true')
parser.add_argument('-load', '--load', action='store_true')
# parse the arguments
args = parser.parse_args()
print(f'Will {"load" if args.load else "perform"} '
+ f'the experiment for Example 1.{args.example}')
return int(args.example), int(args.seed), args.save, args.load
if __name__ == '__main__':
example, random_seed, save, load = setup()
params = {'num_s': 100, 'num_a': 100, 'dom_s': [0,1], 'dom_a': [-1,1], 'example': example}
env = SyntheticBanditEnv(params)
if load:
env.reproduce_pictures(f'Synthetic_{example}.pkl')
else:
test_params = {
'a': {'a_min': .01, 'a_max': .25, 'num_a_tests': 49, 'num_m': 1, 'num_sims': 1000},
'm': {'alpha': .01, 'm_min': 1, 'm_max': 500, 'num_m_tests': 50, 'num_sims': 1000},
'3d': {'a_min': .01, 'a_max': .10, 'num_a_tests': 10, 'm_min': 1, 'm_max': 10,
'num_m_tests': 10, 'num_sims': 1000},
'grid': {'a_min': .05, 'a_max': .15, 'num_a_tests': 3, 'm_min': 1, 'm_max': 1000,
'num_m_tests': 5, 'num_sims': 1000}}
env.produce_pictures(test_params, seed=random_seed)
if save:
env.save_variables()