-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrun_MAB_glmucb.py
More file actions
36 lines (30 loc) · 876 Bytes
/
run_MAB_glmucb.py
File metadata and controls
36 lines (30 loc) · 876 Bytes
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
"""
run_MAB_glmucb.py
James Wang
Dec 1, 2014
"""
from environment.rejection_MAB import RejectionMAB
from policy.glmUCB import GLMUCB
from policy.oblivious import Oblivious
import sqlite3
import time
import datetime
db = 'data/final.db'
conn = sqlite3.connect(db)
c = conn.cursor()
c.execute('SELECT articleID FROM article')
arms = [arm[0] for arm in c.fetchall()]
policies = [GLMUCB(arms), Oblivious(arms)]
conn.close()
n = 10000
t0 = time.time()
MAB = RejectionMAB(db, n, range(2, 7), arms, policies)
MAB.run()
MAB.output_decisions('data/results_glmucb2.gz')
print MAB.total_pulls
t1 = time.time()
the_time = str(datetime.timedelta(seconds=t1-t0))
print('Now: {}'.format(time.time()))
print('Took a total of {}'.format(the_time))
print('Number of pulls required to reach {} was {}'.format(n,
MAB.total_pulls))