-
Notifications
You must be signed in to change notification settings - Fork 1
/
dispather.py
134 lines (111 loc) · 4.82 KB
/
dispather.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import sys
import subprocess
from itertools import product
core = 1
params = [
'default',
'c9r5t1',
#'c9g0.001r0t1',
#'c9g0.001r5t1',
#'c9g0.001r6t1',
#'c2g0.001r5t1',
#'c2g0.001r5t0',
#'c9g0.00035t2',
#'c9g0.000375t2',
#'c2t2', # x
#'c4t2', # x
'c9t2',
'c2g0.001t2',
#'c2g0.01t2', # x
#'c9g0.01t2', # x
#'c9g0.005t2', # x
#'c9g0.001t2',
'c9g0.0005t2',
#'c9g0.0001t2'
]
sids = [
'538c48e6d4388c6121b0a1f2', # pat-TF3xIDF2, min_df 1
'538c49ccd4388c7ee25235ff', # pat-TF3xIDF2, min_df 2
# '538c45d2d4388c6d069f8487', # pat-TF3xIDF2
#'538c3813d4388c65b93e7744', # TF3xIDF2, lemma ,extend
#'538c388ed4388c77fd5c3e5f', # TF3xIDF2, lemma, basic
#'538c32b2d4388c1cafcd0a11', # kw-TF3xIDF2 + kw-emo-s + pat-emo-s
#'538bf593d4388c7618373ab1', # kw-TF3xIDF2-Yang
# '538be395d4388c4c7d533e2e', # pat-bag + kw-TF3xIDF2
#'538bdc4cd4388c3b72ded9e7', # kw-TF3xIDF2 + pat-emo-s
# '538be189d4388c7efe214736', # kw-TF1xIDF2 + pat-emo-s
# '538be0edd4388c67c1d6950d', # kw-bag + kw-TF3xIDF2 + pat-emo-s
# '538bcfaad4388c59136665df', # TF3xIDF2
# '538bcf7ad4388c5190d8057c', # TF1xIDF2
# '538b290cd4388c1eb95c3f7b', # kw-bag + pat-emo-s + kw-emo-s + pat-emo-s-pos
# '538aeb10d4388c12a30803d9', # pat-emo-f-pos
# '538ae979d4388c54633cf587', # pat-emo-b-pos
# '538aec90d4388c49cb5c2705', # pat-emo-s-pos
# "538a9256d4388c7d9203e92c", # pat-emo-s + kw-emo-s (538a9256d4388c7d9203e92c)
# "538a9245d4388c7a1a54c294", # kw-bag + pat-emo-s + kw-emo-s (538a9245d4388c7a1a54c294)
# '538a08a5d4388c142389a032',
# '538a128cd4388c32c05231e8',
# '538a1df3d4388c32be4c2c9b',
# '53876afdd4388c03612805ae', # [b] cut 30, min_count 4, -frequency (53876afdd4388c03612805ae)
# '53876efbd4388c3e013e9272', # [b] cut 50, min_count 4, -frequency (53876efbd4388c3e013e9272)
# '5387fff3d4388c238838629f', # [freq] cut 50, min_count 4, -frequency (5387fff3d4388c238838629f)
# '53875c80d4388c4100cac5b2', # [s] cut 30, min_count 4, -frequency (53875c80d4388c4100cac5b2)
# '53875eead4388c4eac581415', # [s] cut 50, min_count 4, -frequency (53875eead4388c4eac581415)
# '53876645d4388c6f97360eb2', # [s] cut 100, min_count 4, -frequency (53876645d4388c6f97360eb2)
# '538706fad4388c61c5deff2d', # [b] cut 30, min_count 4, -frequency (538706fad4388c61c5deff2d)
# '53872b4ed4388c258c75b8e9', # [b] cut 50, min_count 4, -frequency (53872b4ed4388c258c75b8e9)
# '5387fdbcd4388c5d95b5be52', # [freq] cut 50, min_count 4, -frequency (5387fdbcd4388c5d95b5be52)
# '5387635bd4388c34c92325f7', # [s] cut 30, min_count 4, -frequency (5387635bd4388c34c92325f7)
# '538775cdd4388c2767c7dd92', # [s] cut 50, min_count 4, -frequency (538775cdd4388c2767c7dd92)
# '537451d1d4388c7843516ba4', # extend, lemma (537451d1d4388c7843516ba4)
# '537c6c90d4388c0e27069e7b', # min_count: 10 (537c6c90d4388c0e27069e7b)
# '538302743681df11cd509c77', # kw-bag + pat-bag (538302743681df11cd509c77)
# '53877f0bd4388c6949626954', # pat-emo-s + pat-emo-s-pos (53877f0bd4388c6949626954)
# '53877105d4388c1adc151f73', # Fusion.a + pat-emo-s (53877105d4388c1adc151f73)
# '53877b0bd4388c37f6a22b1a', # Fusion.a + pat-emo-s-pos (53877b0bd4388c37f6a22b1a)
# '53877edfd4388c5ea47db964', # kw-bag + pat-emo-s (53877edfd4388c5ea47db964)
# '53877ef0d4388c62c5619889', # kw-bag + pat-emo-s-pos (53877ef0d4388c62c5619889)
# '53877f27d4388c70c7a72952' # kw-bag + pat-emo-s + pat-emo-s-pos (53877f27d4388c70c7a72952)
]
def dispatcher(sids, params, core):
dispatch = []
sids_params = list(product(sids, params))
step = len(sids_params)/core
for i in range(core):
if i == core - 1: dispatch.append(sids_params[i*step:])
else: dispatch.append(sids_params[i*step:(i+1)*step])
return dispatch
def show(sids, params, grouop_by):
if grouop_by == 'row':
sids_params = list(product(sids, params))
elif grouop_by == 'col':
sids_params = [(sid,param) for (param,sid) in list(product(params, sids))]
else:
return False
for sid, param in sids_params:
print sid, '\t', param
subprocess.Popen(['python','evaluate_binary.py',sid,param], stdout=subprocess.PIPE)
raw_input()
if __name__ == '__main__':
if len(sys.argv) > 1:
if sys.argv[1].strip() in ('row', 'col'):
grouop_by = sys.argv[1].strip()
show(sids, params, grouop_by)
else:
print 'invalid argument, usage: python dispatcher.py [row/col]'
exit(-1)
else:
dispatch = dispatcher(sids, params, core)
used_sid_to_check_binary = set()
for fidx, sids_params in enumerate(dispatch):
fn = str(fidx)+'.sh'
with open(fn, 'w') as fw:
for sid, param in sids_params:
if sid not in used_sid_to_check_binary:
used_sid_to_check_binary.add(sid)
fw.write(' '.join(['python','to_binary.py',sid]) + '\n')
fw.write(' '.join(['python','run_binary_svm.py',sid,param]) + '\n')
for sid, param in sids_params:
fw.write(' '.join(['python','evaluate_binary.py',sid,param]) + '\n')
print 'save',fn
subprocess.call(['chmod','+x',fn])