-
Notifications
You must be signed in to change notification settings - Fork 2
/
no.intermediates.selected.R
52 lines (50 loc) · 1.32 KB
/
no.intermediates.selected.R
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
51
52
library(data.table)
library(penaltyLearning)
N <- 5
t <- 1:N
## L_t = N-t + I[1 < t < N]/2
dt <- data.table(loss=N-t+(1 < t & t < N)/2, complexity=t)
modelSelection(dt)
## requires while-iteration branch.
result <- .C(
"modelSelectionFwd_interface",
loss=as.double(dt$loss),
complexity=as.double(dt$complexity),
N=as.integer(nrow(dt)),
models=integer(nrow(dt)),
breaks=double(nrow(dt)),
evals=integer(nrow(dt)),
PACKAGE="penaltyLearning")
print(result)# 0 1 2 2 2
sum(result$evals)
qresult <- .C(
"modelSelectionQuadratic_interface",
loss=as.double(dt$loss),
complexity=as.double(dt$complexity),
N=as.integer(nrow(dt)),
models=integer(nrow(dt)),
breaks=double(nrow(dt)),
PACKAGE="penaltyLearning")
print(qresult)
dt <- data.table(loss=N-t+N*(t!=N), complexity=t)
modelSelection(dt)
result <- .C(
"modelSelectionFwd_interface",
loss=as.double(dt$loss),
complexity=as.double(dt$complexity),
N=as.integer(nrow(dt)),
models=integer(nrow(dt)),
breaks=double(nrow(dt)),
evals=integer(nrow(dt)),
PACKAGE="penaltyLearning")
print(result) # 0 1 1 1 4
sum(result$evals)
qresult <- .C(
"modelSelectionQuadratic_interface",
loss=as.double(dt$loss),
complexity=as.double(dt$complexity),
N=as.integer(nrow(dt)),
models=integer(nrow(dt)),
breaks=double(nrow(dt)),
PACKAGE="penaltyLearning")
print(qresult)