tests/testthat/test_regr_GPfit.R

test_that("regr_GPfit", {
  testFun = function(x) {
    return(4 * x[, 1]^2 - 2 * x[, 2])
  }
  train.inds = 1:20
  s = seq(0, 1, by = 0.2)
  x = expand.grid(s, s)
  y = testFun(x)
  gpfit.test.df = cbind.data.frame(x, y)
  colnames(gpfit.test.df) = c("x1", "x2", "y")
  m = GPfit::GP_fit(x[train.inds, ], y[train.inds])
  p = predict(m, xnew = x[-train.inds, ])
  testSimple("regr.GPfit", gpfit.test.df, "y", train.inds, p$Y_hat)
})

Try the mlr package in your browser

Any scripts or data that you put into this service are public.

mlr documentation built on Sept. 29, 2022, 5:05 p.m.