post.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:kaggle-review 作者: daxiongshu 项目源码 文件源码
def post(inx,k=3):
    out = inx.replace('.csv','_sub.csv')
    #if os.path.exists(out):
    #    return
    fo = open(out,'w')
    last = ''
    pred = {}
    for c,row in enumerate(csv.DictReader(open(inx))):   
        if last != '' and row['orderid'] != last:
            pred = ','.join(sort_value(pred)[:3])
            fo.write('%s,%s\n'%(last,pred))
            pred = {}
        yp = float(row['prob'])
        pred[row['candidate_loc']] = yp
        last = row['orderid']
        if  c % 10000000 == 0 and c>0:
            print c#, 'log loss', score/(c+1), 'm12 apk', apks/dc
    pred = ','.join(sort_value(pred)[:k])
    fo.write('%s,%s\n'%(row['orderid'],pred))
    fo.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号