Skip to content

Commit

Permalink
use new trafo interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mb706 committed Jan 14, 2024
1 parent 070d9c8 commit 9f63efc
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions tests/testthat/test_trafos.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
test_that("simple exp trafo works", {
ll = lrn("classif.rpart")
ps = ps(
cp = p_dbl(lower = -8, upper = -2)
cp = p_dbl(lower = -8, upper = -2, trafo = function(x) 2^x)
)
ps$trafo = function(x, param_set) {
x$cp = 2^x$cp
return(x)
}
te = trm("evals", n_evals = 3)
d = data.table(cp = c(-7, -3))
tuner = tnr("design_points", design = d)
Expand All @@ -22,16 +18,16 @@ test_that("simple exp trafo works", {
test_that("trafo where param names change", {
ll = lrn("classif.rpart")
ps = ps(
foo = p_fct(levels = c("a", "b"))
foo = p_fct(levels = c("a", "b")),
.extra_trafo = function(x, param_set) {
if (x$foo == "a")
x$cp = 0.11
else
x$cp = 0.22
x$foo = NULL
return(x)
}
)
ps$trafo = function(x, param_set) {
if (x$foo == "a")
x$cp = 0.11
else
x$cp = 0.22
x$foo = NULL
return(x)
}
te = trm("evals", n_evals = 3)
tuner = tnr("grid_search", resolution = 2)
inst = TuningInstanceSingleCrit$new(tsk("iris"), ll, rsmp("holdout"), msr("dummy.cp.classif", fun = function(pv) pv$cp), te, ps)
Expand Down

0 comments on commit 9f63efc

Please sign in to comment.