-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.Rmd
More file actions
82 lines (60 loc) · 1.61 KB
/
main.Rmd
File metadata and controls
82 lines (60 loc) · 1.61 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
---
title: "R Notebook"
output: html_notebook
---
```{r}
sample_test_train <- function(test=0.0, train=0.0, n=NULL, X=NULL) {
stopifnot(!is.null(n) || !is.null(X))
stopifnot(test + train <= 1.0)
if (is.null(n)) {
n <- nrow(X)
}
n_test <- floor(test*n)
n_train <- floor(train*n)
all_indices <- sample.int(n, size=n_test+n_train)
list(
test = all_indices[1:n_test],
n_test = n_test,
train = all_indices[(n_test+1):(n_test+n_train)],
n_train = n_train
)
}
```
```{r}
raw <- readr::read_csv("data/L1IO-L2IO-L3O All Rands SMU UA159 Processed-Aerobic.csv")
Xall <- as.matrix(raw[ ,1:20])
yall <- raw$growth
spl <- sample_test_train(test=0.1, train=0.1, X=Xall)
X <- Xall[spl$train, ]
y <- yall[spl$train]
Xt <- Xall[spl$test, ]
yt <- yall[spl$test]
```
```{r}
raw <- readr::read_csv("data/L1IO-L2IO-L3O All Rands SMU UA159 Processed-Aerobic.csv")
Xall <- as.matrix(raw[ ,1:20])
yall <- raw$growth
spl <- sample_test_train(test=0.1, train=0.1, X=Xall)
X <- Xall[spl$train, ]
y <- yall[spl$train]
Xt <- Xall[spl$test, ]
yt <- yall[spl$test]
```
```{r}
eps <- sqrt(.Machine$double.eps)
gpi <- laGP::newGPsep(X, y, d=0.1, g=0.1*var(y), dK=TRUE)
ndim <- dim(X)[[2]]
tmin <- rep(eps, ndim+1)
tmax <- c(rep(100, ndim), var(y))
mle <- laGP::mleGPsep(gpi, para="both", tmin=tmin, tmax=tmax, verb=2)
```
```{r}
order_plot <- function(ytrue, ypred) {
so <- order(ytrue)
cex <- 0.5
plot(1:length(ypred), ypred[so], col="orange", xlab="sorted index", ylab="", cex=cex)
points(1:length(ytrue), ytrue[so], col="blue", cex=cex)
}
yp <- laGP::predGPsep(gpi, Xt, lite=TRUE)
order_plot(yt, yp$mean)
```