Skip to content

Commit 7ed719f

Browse files
committed
Added new version of tag selection in parameter generation.
1 parent 3d41e0c commit 7ed719f

File tree

5 files changed

+42
-4
lines changed

5 files changed

+42
-4
lines changed

paramgenerator/discoverparams.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,26 @@ def generate(factors, portion=SHARE):
160160
result.extend([factors[w.start+i][0] for i in range(amount)])
161161
return result
162162

163+
def divideFactors(factors, splitPortion):
164+
sortedFactors = sorted(factors, key=lambda (k,v): v, reverse=True)
165+
oSum= 0
166+
for l in sortedFactors:
167+
oSum+=l[1]
168+
splitPoint = splitPortion*oSum
169+
leftFactors = []
170+
rightFactors = []
171+
currentSum = 0
172+
for l in sortedFactors:
173+
currentSum+=l[1]
174+
if currentSum <= splitPoint:
175+
leftFactors.append(l)
176+
else:
177+
rightFactors.append(l)
178+
return(leftFactors,rightFactors)
179+
180+
181+
182+
183+
184+
185+

paramgenerator/discoverparams.pyc

6.27 KB
Binary file not shown.

paramgenerator/generateparams.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,27 @@ def main(argv=None):
185185
break
186186
secondCountry.append(selectedCountryParams[3][i])
187187

188-
# find tag parameters for Query 6
189-
print "find parameter bindings for Tags"
188+
#find tag parameters for Query 6
189+
#print "find parameter bindings for Tags"
190+
# old tag selection
191+
#selectedTagParams = {}
192+
#for i in [6]:
193+
# selectedTagParams[i] = discoverparams.generate(tagFactors, portion=0.1)
194+
# # make sure there are as many tag paramters as person parameters
195+
# oldlen = len(selectedTagParams[i])
196+
# newlen = len(selectedPersonParams[i])
197+
# selectedTagParams[i].extend([selectedTagParams[i][random.randint(0, oldlen-1)] for j in range(newlen-oldlen)])
198+
199+
#print "find parameter bindings for Tags"
200+
(leftTagFactors, rightTagFactors) = discoverparams.divideFactors(tagFactors, 0.7)
201+
leftSize = len(leftTagFactors)
202+
rightSize = len(rightTagFactors)
203+
leftPortion = 0.1*(leftSize+rightSize) / (2.0*leftSize)
204+
rightPortion = 0.1*(leftSize+rightSize) / (2.0*rightSize)
190205
selectedTagParams = {}
191206
for i in [6]:
192-
selectedTagParams[i] = discoverparams.generate(tagFactors, portion=0.1)
193-
# make sure there are as many tag paramters as person parameters
207+
selectedTagParams[i] = discoverparams.generate(leftTagFactors, portion=leftPortion)
208+
selectedTagParams[i].extend(discoverparams.generate(rightTagFactors, portion=rightPortion))
194209
oldlen = len(selectedTagParams[i])
195210
newlen = len(selectedPersonParams[i])
196211
selectedTagParams[i].extend([selectedTagParams[i][random.randint(0, oldlen-1)] for j in range(newlen-oldlen)])

paramgenerator/readfactors.pyc

8.76 KB
Binary file not shown.

paramgenerator/timeparameters.pyc

10 KB
Binary file not shown.

0 commit comments

Comments
 (0)