From dae9241190d658f44af6e3f8d7de107f03771797 Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Thu, 4 Jun 2015 00:39:54 +0800 Subject: rename --- ensemble.py | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 ensemble.py (limited to 'ensemble.py') diff --git a/ensemble.py b/ensemble.py new file mode 100644 index 0000000..34b4024 --- /dev/null +++ b/ensemble.py @@ -0,0 +1,127 @@ +from misc import * +import math + +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] + +#folds=4 +#tot=316 + step = tot // folds +#inm="0.m" + + 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) + + entries=['0','0'] + + 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 t