From 8408faf11f6459646d2487dc48e6a5495ca1f270 Mon Sep 17 00:00:00 2001 From: sipp11 Date: Thu, 31 Jul 2014 00:14:53 +0700 Subject: [PATCH] [july] s2/s4 support 24 model's weight --- s2.py | 9 +++++---- s4.py | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/s2.py b/s2.py index 3d2c5ec..a7c56b8 100755 --- a/s2.py +++ b/s2.py @@ -112,7 +112,8 @@ def produce_part3(sum_result, lo_weight): lo_xmodels = lo_xmodels.union(set(sum_result[i])) lo_xmodels = sorted(list(lo_xmodels)) for l in lo_xmodels: - lo_sum = [0, 0, 0, 0, 0, 0] + ## build container to store sum of all weight + lo_sum = [0 for k in xrange(0, 25)] if l not in lo_weight: continue for i in ii: @@ -120,7 +121,7 @@ def produce_part3(sum_result, lo_weight): continue lo_sum = [ float(x) + float(y) for x, y - in zip(lo_weight[l][i], lo_sum)] + in zip(lo_weight[l][i][9:], lo_sum)] rows.append([l] + lo_sum) _f = '%s-3.csv' % ii @@ -131,8 +132,8 @@ def main(*argv): _r = process_s2_data() _lw = process_lo_weight() produce_s2_part1(_r['sum']) - # produce_s2_part2(_r['rank']) - # produce_part3(_r['sum'], _lw) + produce_s2_part2(_r['rank']) + produce_part3(_r['sum'], _lw) if __name__ == '__main__': diff --git a/s4.py b/s4.py index 96bc6c4..06f69ed 100755 --- a/s4.py +++ b/s4.py @@ -36,7 +36,8 @@ def get_weight(xmodel): with open(fpath, 'rb') as f: rows = csv.reader(f) for r in rows: - result[r[0]] = [r[1], r[2], r[3], r[4], r[5], r[6]] + # result[r[0]] = [r[1], r[2], r[3], r[4], r[5], r[6]] + result[r[0]] = [r[k] for k in xrange(1, 26)] return result