forked from BIDData/BIDMach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestlr.ssc
executable file
·44 lines (35 loc) · 1.03 KB
/
testlr.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
:silent
val dir="../data/rcv1/"
val a0 = loadSMat(dir + "docs.smat.lz4")
val c0 = loadFMat(dir + "cats.fmat.lz4")(0->100,?)
val rr = rand(c0.ncols,1);
val (ss, ii) = sort2(rr);
val a = a0(?,ii);
val c = c0(?,ii);
val ta = loadSMat(dir + "testdocs.smat.lz4")
val tc = loadFMat(dir + "testcats.fmat.lz4")(0->100,?)
val pc = zeros(tc.nrows, tc.ncols)
val (nn,opts)=GLM.learnerX(a,c,1)
opts.batchSize=5000
opts.lrate = 0.1f
opts.npasses = 3
opts.reg1weight = 0.0
opts.links = iones(103,1)
opts.addConstFeat=true;
opts.aopts = opts;
//val dd = mkdiag(ones(100,1));
//val tmap = dd on dd on dd on dd
//opts.targmap = tmap
//mopts.targmap = opts.targmap
nn.train
val (mm, mopts) = GLM.predictor(nn.model, ta, pc)
mopts.addConstFeat=opts.addConstFeat;
mopts.batchSize=20000
mopts.links = opts.links
mm.predict
//val tc2= tmap * tc
val rc = roc2(pc, tc, 1-tc, 1000)
val nc = sum(tc,2);
val wmean = mean(rc)*nc/sum(nc)
:silent
println("roc6 = %5.4f, roc weighted mean = %5.4f" format (mean(rc)(6), wmean.v))