-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbandit_experiment_confidence.py
52 lines (40 loc) · 1.59 KB
/
bandit_experiment_confidence.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
'''
Script to run tabular experiments in batch mode.
author: [email protected]
'''
import numpy as np
import pandas as pd
import argparse
import sys
import environment
import finite_tabular_agents
from feature_extractor import FeatureTrueState
from bandit_confidence import run_bandit_confidence
if __name__ == '__main__':
'''
Run a tabular experiment according to command line arguments
'''
# Take in command line flags
parser = argparse.ArgumentParser(description='Run tabular RL experiment')
parser.add_argument('epLen', help='length of episode', type=int)
parser.add_argument('gap', help='gap between best arm', type=float)
parser.add_argument('alg', help='Agent constructor', type=str)
parser.add_argument('scaling', help='scaling', type=float)
parser.add_argument('seed', help='random seed', type=int)
parser.add_argument('nEps', help='number of episodes', type=int)
args = parser.parse_args()
# Make a filename to identify flags
fileName = ('bandit'
+ '_len=' + '%02.f' % args.epLen
+ '_gap=' + '%04.3f' % args.gap
+ '_alg=' + str(args.alg)
+ '_scal=' + '%03.2f' % args.scaling
+ '_seed=' + str(args.seed)
+ '.csv')
folderName = './'
targetPath = folderName + fileName
print '******************************************************************'
print fileName
print '******************************************************************'
# Run the experiment
run_bandit_confidence(args.seed, args.alg, args.epLen, targetPath)