-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproposal4July2019_v4_normal10sLDA.py
More file actions
158 lines (110 loc) · 5.6 KB
/
proposal4July2019_v4_normal10sLDA.py
File metadata and controls
158 lines (110 loc) · 5.6 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jul 26 17:19:15 2019
purpose: train only once LDA and evaluate the results
@author: ziwei
"""
############## case1 (10 times) ##########
termsPerfileList_case1 = [goldNPs_set_case1, goldNPs_set_rep_case1, goldNPs_set_keywords_case1, goldNPs_set_keywords_rep_case1]
filter_no_below = 0
filter_no_above = 1
tp = 50
# to nest tuples (u= t, (1,2,3,4))
res_avg_case1 = []
res_stas_case1 = []
for termsPerfileList in termsPerfileList_case1:
res_avg, res_stas = train_eval_10_v2(termsPerfileList,filter_no_below, filter_no_above, tp,threshold0_freq = 3000, threshold1_termProb = 1e-8, threshold2_termSign = 0.001)
res_avg_case1.append(res_avg)
res_stas_case1.append(res_stas)
############## case2 (10 times) ##########
termsPerfileList_case2 = [goldNPs_set_case2, goldNPs_set_rep_case2, goldNPs_set_keywords_case2, goldNPs_set_keywords_rep_case2]
filter_no_below = 0
filter_no_above = 1
tp = 50
# to nest tuples (u= t, (1,2,3,4))
res_avg_case2 = []
res_stas_case2 = []
for termsPerfileList in termsPerfileList_case2:
res_avg, res_stas = train_eval_10_v2(termsPerfileList,filter_no_below, filter_no_above, tp,threshold0_freq = 3000, threshold1_termProb = 1e-8, threshold2_termSign = 0.001)
res_avg_case2.append(res_avg)
res_stas_case2.append(res_stas)
############## case3 (10 times) ##########
termsPerfileList_case3 = [goldNPs_set_case3, goldNPs_set_rep_case3, goldNPs_set_keywords_case3, goldNPs_set_keywords_rep_case3]
filter_no_below = 5
filter_no_above = 0.5
tp = 50
# to nest tuples (u= t, (1,2,3,4))
res_avg_case3 = []
res_stas_case3 = []
for termsPerfileList in termsPerfileList_case3:
res_avg, res_stas = train_eval_10_v2(termsPerfileList,filter_no_below, filter_no_above, tp,threshold0_freq = 3000, threshold1_termProb = 1e-8, threshold2_termSign = 0.001)
res_avg_case3.append(res_avg)
res_stas_case3.append(res_stas)
############## case4 (10 times) ##########
termsPerfileList_case4 = [goldNPs_set_case4, goldNPs_set_rep_case4, goldNPs_set_keywords_case4, goldNPs_set_keywords_rep_case4]
filter_no_below = 5
filter_no_above = 0.5
tp = 50
# to nest tuples (u= t, (1,2,3,4))
res_avg_case4 = []
res_stas_case4 = []
for termsPerfileList in termsPerfileList_case4:
res_avg, res_stas = train_eval_10_v2(termsPerfileList,filter_no_below, filter_no_above, tp,threshold0_freq = 3000, threshold1_termProb = 1e-8, threshold2_termSign = 0.001)
res_avg_case4.append(res_avg)
res_stas_case4.append(res_stas)
############## case5 (10 times) ##########
termsPerfileList_case5 = [goldNPs_set_case5, goldNPs_set_rep_case5, goldNPs_set_keywords_case5, goldNPs_set_keywords_rep_case5]
filter_no_below = 5
filter_no_above = 0.5
tp = 50
# to nest tuples (u= t, (1,2,3,4))
res_avg_case5 = []
res_stas_case5 = []
for termsPerfileList in termsPerfileList_case5:
res_avg, res_stas = train_eval_10_v2(termsPerfileList,filter_no_below, filter_no_above, tp,threshold0_freq = 3000, threshold1_termProb = 1e-8, threshold2_termSign = 0.001)
res_avg_case5.append(res_avg)
res_stas_case5.append(res_stas)
############## case6 (10 times) ##########
termsPerfileList_case6 = [goldNPs_set_case6, goldNPs_set_rep_case6, goldNPs_set_keywords_case6, goldNPs_set_keywords_rep_case6]
filter_no_below = 5
filter_no_above = 0.5
tp = 50
# to nest tuples (u= t, (1,2,3,4))
res_avg_case6 = []
res_stas_case6 = []
for termsPerfileList in termsPerfileList_case6:
res_avg, res_stas = train_eval_10_v2(termsPerfileList,filter_no_below, filter_no_above, tp,threshold0_freq = 3000, threshold1_termProb = 1e-8, threshold2_termSign = 0.001)
res_avg_case6.append(res_avg)
res_stas_case6.append(res_stas)
np.save(os.getcwd()+'/LDAtrain_res/normal10sLDA_5_50p/res_avg_case1',res_avg_case1)
np.save(os.getcwd()+'/LDAtrain_res/normal10sLDA_5_50p/res_stas_case1',res_stas_case1)
np.save(os.getcwd()+'/LDAtrain_res/normal10sLDA_5_50p/res_avg_case2',res_avg_case2)
np.save(os.getcwd()+'/LDAtrain_res/normal10sLDA_5_50p/res_stas_case2',res_stas_case2)
np.save(os.getcwd()+'/LDAtrain_res/normal10sLDA_5_50p/res_avg_case3',res_avg_case3)
np.save(os.getcwd()+'/LDAtrain_res/normal10sLDA_5_50p/res_stas_case3',res_stas_case3)
np.save(os.getcwd()+'/LDAtrain_res/normal10sLDA_5_50p/res_avg_case4',res_avg_case4)
np.save(os.getcwd()+'/LDAtrain_res/normal10sLDA_5_50p/res_stas_case4',res_stas_case4)
np.save(os.getcwd()+'/LDAtrain_res/normal10sLDA_5_50p/res_avg_case5',res_avg_case5)
np.save(os.getcwd()+'/LDAtrain_res/normal10sLDA_5_50p/res_stas_case5',res_stas_case5)
np.save(os.getcwd()+'/LDAtrain_res/normal10sLDA_5_50p/res_avg_case6',res_avg_case6)
np.save(os.getcwd()+'/LDAtrain_res/normal10sLDA_5_50p/res_stas_case6',res_stas_case6)
#np.load(os.getcwd()+'/LDAtrain_res/normal10sLDA_5_50p/res_avg_case1.npy')
### the base method to put these variables into latex (in case that we input with wrong parameters)
import scipy
from tabulate import tabulate
a = scipy.random.rand(3,3)
print(tabulate(a,tablefmt = "latex", floatfmt = ".2f"))
#test
############## case6 (10 times) ##########
termsPerfileList_case6 = [goldNPs_set_case6, goldNPs_set_rep_case6, goldNPs_set_keywords_case6, goldNPs_set_keywords_rep_case6]
filter_no_below = 5
filter_no_above = 0.5
tp = 100
# to nest tuples (u= t, (1,2,3,4))
res_avg_case6 = []
res_stas_case6 = []
for termsPerfileList in termsPerfileList_case6:
res_avg, res_stas = train_eval_10_v2(termsPerfileList,filter_no_below, filter_no_above, tp,threshold0_freq = 3000, threshold1_termProb = 1e-8, threshold2_termSign = 0.001)
res_avg_case6.append(res_avg)
res_stas_case6.append(res_stas)