1
1
skip_if_not_installed(" irace" )
2
- skip_on_cran()
3
2
4
3
test_that(" TunerIrace" , {
5
- x = capture.output({ z = test_tuner(" irace" , term_evals = 42 , real_evals = 39 )} )
4
+ z = test_tuner(" irace" , term_evals = 42 )
6
5
instance = z $ inst
7
6
archive = instance $ archive $ data
8
7
tuner = z $ tuner
@@ -12,7 +11,7 @@ test_that("TunerIrace", {
12
11
13
12
# check optimization direction
14
13
# first elite of the first race should have the lowest average performance
15
- load (tuner $ param_set $ values $ logFile )
14
+ iraceResults = irace :: read_logfile (tuner $ param_set $ values $ logFile )
16
15
elites = iraceResults $ allElites
17
16
aggr = archive [race == 1 , .(classif.ce = mean(classif.ce )), by = configuration ]
18
17
expect_equal(aggr [which.min(classif.ce ), configuration ], elites [[1 ]][1 ])
@@ -27,8 +26,13 @@ test_that("TunerIrace works with dependencies", {
27
26
cp = p_dbl(lower = 0.001 , upper = 0.1 ),
28
27
minsplit = p_int(lower = 1 , upper = 10 , depends = cp == 0.005 )
29
28
)
30
- instance = TuningInstanceBatchSingleCrit $ new(tsk(" iris" ), lrn(" classif.rpart" ), rsmp(" holdout" ), msr(" classif.ce" ),
31
- trm(" evals" , n_evals = 96 ), search_space )
29
+ instance = ti(
30
+ task = tsk(" mtcars" ),
31
+ learner = lrn(" regr.rpart" ),
32
+ resampling = rsmp(" holdout" ),
33
+ measures = msr(" regr.mse" ),
34
+ terminator = trm(" evals" , n_evals = 96 ),
35
+ search_space = search_space )
32
36
tuner = tnr(" irace" )
33
37
x = capture.output({tuner $ optimize(instance )})
34
38
@@ -38,27 +42,44 @@ test_that("TunerIrace works with dependencies", {
38
42
})
39
43
40
44
test_that(" TunerIrace works with logical parameters" , {
41
- search_space = ps(keep_model = p_lgl())
42
- instance = TuningInstanceBatchSingleCrit $ new(tsk(" mtcars" ), lrn(" regr.rpart" ), rsmp(" holdout" ), msr(" regr.mse" ),
43
- trm(" evals" , n_evals = 42 ), search_space )
45
+ search_space = ps(
46
+ cp = p_dbl(lower = 0.001 , upper = 0.1 ),
47
+ keep_model = p_lgl())
48
+ instance = ti(
49
+ task = tsk(" mtcars" ),
50
+ learner = lrn(" regr.rpart" ),
51
+ resampling = rsmp(" holdout" ),
52
+ measures = msr(" regr.mse" ),
53
+ terminator = trm(" evals" , n_evals = 96 ),
54
+ search_space = search_space )
44
55
tuner = tnr(" irace" )
45
56
x = capture.output({tuner $ optimize(instance )})
46
57
expect_logical(instance $ archive $ best()$ keep_model )
47
58
})
48
59
49
60
test_that(" TunerIrace uses digits" , {
50
61
search_space = ps(cp = p_dbl(lower = pi * 1e-20 , upper = 5.242e12 / 1e13 ))
51
- instance = TuningInstanceBatchSingleCrit $ new(tsk(" iris" ), lrn(" classif.rpart" ), rsmp(" holdout" ), msr(" classif.ce" ),
52
- trm(" evals" , n_evals = 30 ), search_space )
62
+ instance = ti(
63
+ task = tsk(" mtcars" ),
64
+ learner = lrn(" regr.rpart" ),
65
+ resampling = rsmp(" holdout" ),
66
+ measures = msr(" regr.mse" ),
67
+ terminator = trm(" evals" , n_evals = 96 ),
68
+ search_space = search_space )
53
69
tuner = tnr(" irace" , nbIterations = 1L , minNbSurvival = 1 )
54
70
x = capture.output({expect_data_table(tuner $ optimize(instance ))})
55
71
})
56
72
57
73
test_that(" TunerIrace works with unnamed discrete values" , {
58
74
# we had a bug here, see (mlr) issue #627
59
75
search_space = ps(minsplit = p_int(lower = 2L , upper = 7L ))
60
- inst = TuningInstanceBatchSingleCrit $ new(tsk(" iris" ), lrn(" classif.rpart" ), rsmp(" holdout" ), msr(" classif.ce" ),
61
- trm(" evals" , n_evals = 50 ), search_space )
76
+ instance = ti(
77
+ task = tsk(" mtcars" ),
78
+ learner = lrn(" regr.rpart" ),
79
+ resampling = rsmp(" holdout" ),
80
+ measures = msr(" regr.mse" ),
81
+ terminator = trm(" evals" , n_evals = 96 ),
82
+ search_space = search_space )
62
83
tuner = tnr(" irace" )
63
- x = capture.output({expect_data_table(tuner $ optimize(inst ))})
84
+ x = capture.output({expect_data_table(tuner $ optimize(instance ))})
64
85
})
0 commit comments