Browse Source

[july] s1 with all 24 weight values

master
sipp11 11 years ago
parent
commit
a89cadac3b
  1. 5
      base.py
  2. 12
      s1.py
  3. 6
      s2.py
  4. 4
      s3.py
  5. 8
      s4.py

5
base.py

@ -2,6 +2,9 @@ from __future__ import print_function
import csv
import os
RAW_DIR = os.path.join(os.getcwd(), 'raw', 'july')
TARGET_DIR = os.path.join(os.getcwd(), 'build')
class Lo:
src_path = None
@ -80,7 +83,7 @@ def create_csv(filename, data, **kwargs):
if not isinstance(data, list):
print('Nope, data are not list')
directory = kwargs.get('directory', '')
path = os.path.join(os.getcwd(), 'build', directory)
path = os.path.join(TARGET_DIR, directory)
try:
os.mkdir(path)
except OSError:

12
s1.py

@ -1,7 +1,7 @@
# -*- coding:utf-8 -*-
#!/usr/bin/env python
from __future__ import print_function
from base import Lo
from base import Lo, RAW_DIR, TARGET_DIR
import os
import csv
import sys
@ -17,10 +17,10 @@ def get_rank_thing(filename, **kwargs):
}
output_filename = kwargs.get('output', '%s-output.csv' % filename)
count = tot = lo_match = 0
with open(os.path.join(os.getcwd(), 'build', output_filename), 'wb') as o:
with open(os.path.join(TARGET_DIR, output_filename), 'wb') as o:
owriter = csv.writer(o, delimiter=',', quotechar='"',
quoting=csv.QUOTE_ALL)
with open(os.path.join(os.getcwd(), 'raw', filename)) as f:
with open(os.path.join(RAW_DIR, filename)) as f:
reader = csv.reader(f)
reader.next()
for r in reader:
@ -28,8 +28,10 @@ def get_rank_thing(filename, **kwargs):
w = [
r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8], # July 1
rank_no, # July 1
r[10], r[11], r[12], r[13], r[14]
]
## add 24 model's weight
for i in xrange(10, 34):
w.append(r[i])
q = (
('A', r[1]), ('B', r[2]), ('C', r[3]), ('D', r[4]),
('E', r[5]), ('F', r[6]), ('G', r[7]), ('H', r[8]),
@ -67,7 +69,7 @@ def main(*argv):
mx = [set(j) for i, j in x.items()]
order = sorted(list(set.union(*mx)))
sum_file = '%s-result.csv' % fs[f]
with open(os.path.join(os.getcwd(), 'build', sum_file), 'wb') as o:
with open(os.path.join(TARGET_DIR, sum_file), 'wb') as o:
result_writer = csv.writer(o, delimiter=',', quotechar='"',
quoting=csv.QUOTE_ALL)
m = {}

6
s2.py

@ -1,7 +1,7 @@
# -*- coding:utf-8 -*-
#!/usr/bin/env python
from __future__ import print_function
from base import Lo, create_csv
from base import Lo, create_csv, TARGET_DIR
import os
import csv
import sys
@ -29,7 +29,7 @@ def process_s2_data():
for i in fs:
f_name = '%s-result.csv' % i
# print(f_name)
with open(os.path.join(os.getcwd(), 'build', f_name), 'rb') as f:
with open(os.path.join(TARGET_DIR, f_name), 'rb') as f:
rows = csv.reader(f)
for r in rows:
if r[0] in ('rank_no', 'All Result'):
@ -87,7 +87,7 @@ def process_lo_weight():
los = {}
for i in fs:
f_name = '%s-output.csv' % i
with open(os.path.join(os.getcwd(), 'build', f_name), 'rb') as f:
with open(os.path.join(TARGET_DIR, f_name), 'rb') as f:
rows = csv.reader(f)
for r in rows:
_los = r[1].split(',')

4
s3.py

@ -4,7 +4,7 @@ WTH
# -*- coding:utf-8 -*-
#!/usr/bin/env python
from __future__ import print_function
from base import Lo, create_csv
from base import Lo, create_csv, TARGET_DIR
import os
import csv
import sys
@ -28,7 +28,7 @@ def process_s2_data():
xm_data = {}
for ii in xmodels.keys():
fname = '%s-2.csv' % ii
fpath = os.path.join(os.getcwd(), 'build', 'part2', fname)
fpath = os.path.join(TARGET_DIR, 'part2', fname)
with open(fpath, 'rb') as f:
rows = csv.reader(f)
rank = 0

8
s4.py

@ -4,7 +4,7 @@ Step 4
# -*- coding:utf-8 -*-
#!/usr/bin/env python
from __future__ import print_function
from base import Lo, create_csv
from base import Lo, create_csv, TARGET_DIR
import os
import csv
import sys
@ -22,7 +22,7 @@ fs = ('Case1_LS.csv', 'Case1_Gender.csv', 'Case1_Level.csv', 'Case1_SciF.csv')
def get_match_all():
result = {}
fpath = os.path.join(os.getcwd(), 'build', 'part3', 'step3_match_all.csv')
fpath = os.path.join(TARGET_DIR, 'part3', 'step3_match_all.csv')
with open(fpath, 'rb') as f:
rows = csv.reader(f)
for r in rows:
@ -32,7 +32,7 @@ def get_match_all():
def get_weight(xmodel):
result = {}
fpath = os.path.join(os.getcwd(), 'build', 'part2', '%s-3.csv' % xmodel)
fpath = os.path.join(TARGET_DIR, 'part2', '%s-3.csv' % xmodel)
with open(fpath, 'rb') as f:
rows = csv.reader(f)
for r in rows:
@ -44,7 +44,7 @@ def get_x_from_step3_all(m):
'''
July 1 requested
'''
fpath = os.path.join(os.getcwd(), 'build', 'part3', '%s-all.csv' % m)
fpath = os.path.join(TARGET_DIR, 'part3', '%s-all.csv' % m)
los = {}
with open(fpath, 'rb') as f:
rows = csv.reader(f)

Loading…
Cancel
Save