-
Notifications
You must be signed in to change notification settings - Fork 52
/
linear.q
50 lines (43 loc) · 1.21 KB
/
linear.q
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
47
48
49
50
.linear.dll:`liblinear^.linear.dll^:`; / optional override
.linear,:(.linear.dll 2: (`lib;1))`
.linear,:`L2R_LR`L2R_L2LOSS_SVC_DUAL`L2R_L2LOSS_SVC!"i"$til 3
.linear,:`L2R_L1LOSS_SVC_DUAL`MCSVM_CS`L1R_L2LOSS_SVC!3i+"i"$til 3
.linear,:`L1R_LR`L2R_LR_DUAL!6i+"i"$til 2
.linear,:`L2R_L2LOSS_SVR`L2R_L2LOSS_SVR_DUAL`L2R_L1LOSS_SVR_DUAL!11i+"i"$til 3
\d .linear
param:(!) . flip (
(`solver_type;L2R_L2LOSS_SVC_DUAL);
(`eps;0f); / uses defaults
(`C;1f);
(`weight_label;::);
(`weight;::);
(`p;.1);
(`init_sol;::));
defeps:(!) . flip (
(L2R_LR;0.01);
(L2R_L2LOSS_SVC;0.01);
(L2R_L2LOSS_SVR;0.001);
(L2R_L2LOSS_SVC_DUAL;0.1);
(L2R_L1LOSS_SVC_DUAL;0.1);
(MCSVM_CS;0.1);
(L2R_LR_DUAL;0.1);
(L1R_L2LOSS_SVC;0.01);
(L1R_LR;0.01);
(L2R_L1LOSS_SVR_DUAL;0.1);
(L2R_L2LOSS_SVR_DUAL;0.1))
defparam:{[prob;param]
if[0f>=param`eps;param[`eps]:defeps param`solver_type];
param}
sparse:{{("i"$1+i)!x i:where not 0f=x} each flip x}
prob:{`x`y!(sparse x;y)}
read_problem:{[s]
i:s?\:" ";
y:i#'s;
x:{(!/)"I: "0:x _y}'[1+i;s];
if[3.5>.z.K;x:("i"$key x)!value x];
`bias`x`y!-1f,"F"$(x;y)}
write_problem:{
s:(("+";"")0>x`y),'string x`y;
s:s,'" ",/:{" " sv ":" sv' string flip(key x;value x)} each x`x;
s:s,\:" ";
s}