1
1
test_that(" simple exp trafo works" , {
2
2
ll = lrn(" classif.rpart" )
3
3
ps = ps(
4
- cp = p_dbl(lower = - 8 , upper = - 2 )
4
+ cp = p_dbl(lower = - 8 , upper = - 2 , trafo = function ( x ) 2 ^ x )
5
5
)
6
- ps $ trafo = function (x , param_set ) {
7
- x $ cp = 2 ^ x $ cp
8
- return (x )
9
- }
10
6
te = trm(" evals" , n_evals = 3 )
11
7
d = data.table(cp = c(- 7 , - 3 ))
12
8
tuner = tnr(" design_points" , design = d )
@@ -22,16 +18,16 @@ test_that("simple exp trafo works", {
22
18
test_that(" trafo where param names change" , {
23
19
ll = lrn(" classif.rpart" )
24
20
ps = ps(
25
- foo = p_fct(levels = c(" a" , " b" ))
21
+ foo = p_fct(levels = c(" a" , " b" )),
22
+ .extra_trafo = function (x , param_set ) {
23
+ if (x $ foo == " a" )
24
+ x $ cp = 0.11
25
+ else
26
+ x $ cp = 0.22
27
+ x $ foo = NULL
28
+ return (x )
29
+ }
26
30
)
27
- ps $ trafo = function (x , param_set ) {
28
- if (x $ foo == " a" )
29
- x $ cp = 0.11
30
- else
31
- x $ cp = 0.22
32
- x $ foo = NULL
33
- return (x )
34
- }
35
31
te = trm(" evals" , n_evals = 3 )
36
32
tuner = tnr(" grid_search" , resolution = 2 )
37
33
inst = TuningInstanceSingleCrit $ new(tsk(" iris" ), ll , rsmp(" holdout" ), msr(" dummy.cp.classif" , fun = function (pv ) pv $ cp ), te , ps )
0 commit comments