-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathprofiler.py
More file actions
36 lines (31 loc) · 988 Bytes
/
profiler.py
File metadata and controls
36 lines (31 loc) · 988 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
"""
profiler.py
James Wang
Nov 27, 2014
"""
import cProfile
import os
from process_to_sqlite import ProcessWebscope
import sqlite3
from environment.rejection_MAB import RejectionMAB
from policy.UCB import UCB, IndexedUCB, KLUCB
from policy.thompson import Thompson
from policy.oblivious import Oblivious
from policy.glmUCB import GLMUCB
# testdb = 'profile.db'
# if os.path.isfile(testdb):
# os.remove(testdb)
# proc = ProcessWebscope(testdb, log=False)
# cProfile.run('proc.process_file("tests/data/fivepercent.gz")',
# 'profiler_results')
db = 'full.db'
conn = sqlite3.connect(db)
c = conn.cursor()
c.execute('SELECT articleID FROM article')
arms = [arm[0] for arm in c.fetchall()]
# policies = [UCB(arms), IndexedUCB(arms, range(2, 7)),
# Thompson(arms), Oblivious(arms)]
policies = [GLMUCB(arms)]
cProfile.run('''MAB = RejectionMAB("{}", 1000,
range(2, 7), arms, policies); MAB.run()'''.format(db),
'MAB_profiler_results')