forked from BIDData/BIDMach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestlr2.ssc
executable file
·46 lines (34 loc) · 1016 Bytes
/
testlr2.ssc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
:silent
val dir="../data/rcv1/"
val a = loadSMat(dir + "docs.smat.lz4")
val c = loadFMat(dir + "cats.fmat.lz4")
val ta = loadSMat(dir + "testdocs.smat.lz4")
val tc = loadFMat(dir + "testcats.fmat.lz4")
//val a=a0(?,0->100000);
//val c=c0(?,0->100000);
val pc = zeros(tc.nrows, tc.ncols)
class Lopts extends Learner.Options with GLM.Opts with ADAGrad.Opts with L1Regularizer.Opts with MatDS.Opts
val opts = new Lopts;
val nn = new Learner(
new MatDS(Array(a,c), opts),
new GLM(opts),
null,
null,
opts);
opts.batchSize=1000
opts.GLM_ADAGrad =true
opts.lrate =0.1f;
opts.reg1weight = 0.01
opts.npasses=1
opts.links = iones(103,1)
opts.addConstFeat=true;
nn.train
val (mm, mopts) = GLM.predictor(nn.model, ta, pc);
mopts.addConstFeat=true;
mm.predict
val rc = roc2(pc, tc, 1-tc, 1000)
val mr = mean(rc)(0, 0->100)
val nt = sum(c,2)(0->100, 0)
val wt = nt / sum(nt);
println("ROC AUC: cat6 %5.4f, mean %5.4f" format (mr(6), (mr*wt).dv))
:silent