From 6e9e61e2627c971db2a0a810ceb8260e384bbaf7 Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Wed, 3 Jun 2015 10:58:35 +0800 Subject: separating --- ensemble-train.py | 217 +++++++++++++++++++++++++++--------------------------- 1 file changed, 110 insertions(+), 107 deletions(-) (limited to 'ensemble-train.py') diff --git a/ensemble-train.py b/ensemble-train.py index 1ceb380..34b4024 100644 --- a/ensemble-train.py +++ b/ensemble-train.py @@ -1,124 +1,127 @@ from misc import * import math -inr="a.rid" -resm="res.m" + +def onefold(inr,inm,tot,clist,folds,resm) + +#inr="a.rid" +#resm="res.m" #consts used -clist=[0.0001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 10, 100, 1000] +#clist=[0.0001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 10, 100, 1000] -folds=4 -tot=316 -step = tot // folds -inm="0.m" +#folds=4 +#tot=316 + step = tot // folds +#inm="0.m" -ourb=inr + ourb=inr #splits -print("splitting") -for i in range(folds-1): - inra=ourb - oura="a%d.rid"%i - ourb="b%d.rid"%i - params = "-c %d -i %s -a %s -b %s" %(step,inra,oura,ourb) - split(params) + print("splitting") + for i in range(folds-1): + inra=ourb + oura="a%d.rid"%i + ourb="b%d.rid"%i + params = "-c %d -i %s -a %s -b %s" %(step,inra,oura,ourb) + split(params) -entries=['0','0'] + entries=['0','0'] -tmp=take("b0.rid") -put("c0.rid",tmp) + tmp=take("b0.rid") + put("c0.rid",tmp) -tmp=take("b%d.rid"%(folds-2)) -put("a%d.rid"%(folds-1),tmp) -print("merging") -for a in range(folds-1): - tmp=take("a%d.rid"%a) - entries = merge(tmp,entries) - - if a0: - low=1e20 - k=0 - P=[] - #find best weak ranker - for w in wlist: - t=0 - pr=getpred(w+".p") - for (d,p) in zip(D,pr): - if p<=0: - t+=d - if t0: + low=1e20 + k=0 + P=[] + #find best weak ranker + for w in wlist: + t=0 + pr=getpred(w+".p") + for (d,p) in zip(D,pr): + if p<=0: + t+=d + if t