-
Notifications
You must be signed in to change notification settings - Fork 0
/
exp2_getworkerquality.py
77 lines (52 loc) · 2.57 KB
/
exp2_getworkerquality.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
import ConfigParser
import random
import math
import os
import commands
def run_datasets(python_command, datasets, methods, filetype):
for dataset in datasets:
print "########"+dataset+"########"
for method in methods:
if not os.path.isdir(r'./methods/' + method):
continue
# dataset & method
# truthfile = r"'./datasets/" + dataset + r"/truth.csv'"
datafile = r"'./datasets/" + dataset + r"/answer.csv'"
if filetype in [ 'decision_making', 'single_label' ]:
ftype = '"categorical"'
elif filetype == 'continuous':
ftype = '"continuous"'
output = commands.getoutput(python_command + r'./methods/' + method + r'/method.py '
+ datafile + ' ' + ftype ).split('\n')[-2]
workerquality = eval(output)
assert type(workerquality) == type({})
# dataset & method finished
folder = './workerquality/' + filetype
if not os.path.isdir(folder):
os.mkdir(folder)
folder = folder + '/' + dataset
if not os.path.isdir(folder):
os.mkdir(folder)
f = open(folder + '/' + method, 'w')
f.write(str(workerquality))
f.close()
if __name__=='__main__':
if not os.path.isdir('./workerquality'):
os.mkdir('./workerquality')
cf = ConfigParser.ConfigParser()
cf.read('./config.ini')
# decision_making
datasets_decisionmaking = eval(cf.get("exp-1", "datasets_decisionmaking"))
quality_decisionmaking = eval(cf.get("exp-2", "quality_decisionmaking"))
python_command = eval(cf.get("exp-1", "python_command"))
run_datasets(python_command, datasets_decisionmaking, quality_decisionmaking, 'decision_making')
# single_label
datasets_singlelabel = eval(cf.get("exp-1", "datasets_singlelabel"))
quality_singlelabel = eval(cf.get("exp-2", "quality_singlelabel"))
python_command = eval(cf.get("exp-1", "python_command"))
run_datasets(python_command, datasets_singlelabel, quality_singlelabel, 'single_label')
# continuous
datasets_continuous = eval(cf.get("exp-1", "datasets_continuous"))
quality_continuous = eval(cf.get("exp-2", "quality_continuous"))
python_command = eval(cf.get("exp-1", "python_command"))
run_datasets(python_command, datasets_continuous, quality_continuous, 'continuous')