Skip to content

Commit 30b0f8f

Browse files
committed
fix: as_data_table() functions do not unnest the x_domain colum anymore by default
1 parent 96a79d7 commit 30b0f8f

5 files changed

+22
-20
lines changed

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# mlr3tuning (development version)
22

3+
fix: The `as_data_table()` functions do not unnest the `x_domain` colum anymore by default.
4+
35
# mlr3tuning 1.0.2
46

57
* refactor: Extract internal tuned values in instance.

R/ArchiveAsyncTuning.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ ArchiveAsyncTuning = R6Class("ArchiveAsyncTuning",
184184
)
185185

186186
#' @export
187-
as.data.table.ArchiveAsyncTuning = function(x, ..., unnest = c("x_domain", "internal_tuned_values"), exclude_columns = NULL, measures = NULL) {
187+
as.data.table.ArchiveAsyncTuning = function(x, ..., unnest = "internal_tuned_values", exclude_columns = NULL, measures = NULL) {
188188
data = x$data_with_state()
189189
if (!nrow(data)) return(data.table())
190190

R/ArchiveBatchTuning.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ ArchiveBatchTuning = R6Class("ArchiveBatchTuning",
180180
)
181181

182182
#' @export
183-
as.data.table.ArchiveBatchTuning = function(x, ..., unnest = c("x_domain", "internal_tuned_values"), exclude_columns = "uhash", measures = NULL) {
183+
as.data.table.ArchiveBatchTuning = function(x, ..., unnest = "internal_tuned_values", exclude_columns = "uhash", measures = NULL) {
184184
if (!nrow(x$data)) return(data.table())
185185
data = copy(x$data)
186186

tests/testthat/test_ArchiveAsyncTuning.R

+9-9
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,32 @@ test_that("ArchiveAsyncTuning as.data.table function works", {
7171
# default
7272
tab = as.data.table(instance$archive)
7373
expect_data_table(tab, min.rows = 20)
74-
expect_names(names(tab), permutation.of = c("state", "cp", "classif.ce", "x_domain_cp", "runtime_learners", "worker_id", "resample_result", "timestamp_xs", "timestamp_ys", "pid", "keys", "warnings", "errors"))
74+
expect_names(names(tab), permutation.of = c("state", "cp", "classif.ce", "x_domain", "runtime_learners", "worker_id", "resample_result", "timestamp_xs", "timestamp_ys", "pid", "keys", "warnings", "errors"))
7575

7676
# extra measure
7777
tab = as.data.table(instance$archive, measures = msr("classif.acc"))
7878
expect_data_table(tab, min.rows = 20)
79-
expect_names(names(tab), permutation.of = c("state", "cp", "classif.ce", "x_domain_cp", "runtime_learners", "worker_id", "resample_result", "timestamp_xs", "timestamp_ys", "pid", "keys", "warnings", "errors", "classif.acc"))
79+
expect_names(names(tab), permutation.of = c("state", "cp", "classif.ce", "x_domain", "runtime_learners", "worker_id", "resample_result", "timestamp_xs", "timestamp_ys", "pid", "keys", "warnings", "errors", "classif.acc"))
8080

8181
# extra measures
8282
tab = as.data.table(instance$archive, measures = msrs(c("classif.acc", "classif.mcc")))
8383
expect_data_table(tab, min.rows = 20)
84-
expect_names(names(tab), permutation.of = c("state", "cp", "classif.ce", "x_domain_cp", "runtime_learners", "worker_id", "resample_result", "timestamp_xs", "timestamp_ys", "pid", "keys", "warnings", "errors", "classif.acc", "classif.mcc"))
84+
expect_names(names(tab), permutation.of = c("state", "cp", "classif.ce", "x_domain", "runtime_learners", "worker_id", "resample_result", "timestamp_xs", "timestamp_ys", "pid", "keys", "warnings", "errors", "classif.acc", "classif.mcc"))
8585

8686
# exclude column
8787
tab = as.data.table(instance$archive, exclude_columns = "timestamp_xs")
8888
expect_data_table(tab, min.rows = 20)
89-
expect_names(names(tab), permutation.of = c("state", "cp", "classif.ce", "x_domain_cp", "runtime_learners", "worker_id", "resample_result", "timestamp_ys", "pid", "keys", "warnings", "errors"))
89+
expect_names(names(tab), permutation.of = c("state", "cp", "classif.ce", "x_domain", "runtime_learners", "worker_id", "resample_result", "timestamp_ys", "pid", "keys", "warnings", "errors"))
9090

9191
# exclude columns
9292
tab = as.data.table(instance$archive, exclude_columns = c("timestamp_xs", "resample_result"))
9393
expect_data_table(tab, min.rows = 20)
94-
expect_names(names(tab), permutation.of = c("state", "cp", "classif.ce", "x_domain_cp", "runtime_learners", "worker_id", "timestamp_ys", "pid", "keys", "warnings", "errors"))
94+
expect_names(names(tab), permutation.of = c("state", "cp", "classif.ce", "x_domain", "runtime_learners", "worker_id", "timestamp_ys", "pid", "keys", "warnings", "errors"))
9595

9696
# no exclude
9797
tab = as.data.table(instance$archive, exclude_columns = NULL)
9898
expect_data_table(tab, min.rows = 20)
99-
expect_names(names(tab), permutation.of = c("state", "cp", "classif.ce", "x_domain_cp", "runtime_learners", "worker_id", "resample_result", "timestamp_xs", "timestamp_ys", "pid", "keys", "warnings", "errors"))
99+
expect_names(names(tab), permutation.of = c("state", "cp", "classif.ce", "x_domain", "runtime_learners", "worker_id", "resample_result", "timestamp_xs", "timestamp_ys", "pid", "keys", "warnings", "errors"))
100100

101101
# no unnest
102102
tab = as.data.table(instance$archive, unnest = NULL)
@@ -125,7 +125,7 @@ test_that("ArchiveAsyncTuning as.data.table function works without resample resu
125125

126126
tab = as.data.table(instance$archive)
127127
expect_data_table(tab, min.rows = 20)
128-
expect_names(names(tab), permutation.of = c("state", "cp", "classif.ce", "x_domain_cp", "runtime_learners", "worker_id", "timestamp_xs", "timestamp_ys", "pid", "keys", "warnings", "errors"))
128+
expect_names(names(tab), permutation.of = c("state", "cp", "classif.ce", "x_domain", "runtime_learners", "worker_id", "timestamp_xs", "timestamp_ys", "pid", "keys", "warnings", "errors"))
129129

130130
expect_rush_reset(instance$rush)
131131
})
@@ -182,7 +182,7 @@ test_that("ArchiveAsyncTuning as.data.table function works with new ids in x_dom
182182

183183
tab = as.data.table(instance$archive)
184184
expect_data_table(tab, min.rows = 20)
185-
expect_names(names(tab), permutation.of = c("state", "x1", "x2", "classif.ce", "x_domain_cp", "x_domain_minsplit", "runtime_learners", "worker_id", "resample_result", "timestamp_xs", "timestamp_ys", "pid", "keys", "warnings", "errors"))
185+
expect_names(names(tab), permutation.of = c("state", "x1", "x2", "classif.ce", "x_domain", "runtime_learners", "worker_id", "resample_result", "timestamp_xs", "timestamp_ys", "pid", "keys", "warnings", "errors"))
186186

187187
expect_rush_reset(instance$rush)
188188
})
@@ -221,7 +221,7 @@ test_that("ArchiveAsyncTuning as.data.table function works with switched new ids
221221

222222
tab = as.data.table(instance$archive)
223223
expect_data_table(tab, min.rows = 20)
224-
expect_names(names(tab), permutation.of = c("state", "x1", "x2", "classif.ce", "x_domain_cp", "x_domain_minsplit", "runtime_learners", "worker_id", "resample_result", "timestamp_xs", "timestamp_ys", "pid", "keys", "warnings", "errors"))
224+
expect_names(names(tab), permutation.of = c("state", "x1", "x2", "classif.ce", "x_domain", "runtime_learners", "worker_id", "resample_result", "timestamp_xs", "timestamp_ys", "pid", "keys", "warnings", "errors"))
225225

226226
expect_rush_reset(instance$rush)
227227
})

tests/testthat/test_ArchiveBatchTuning.R

+9-9
Original file line numberDiff line numberDiff line change
@@ -128,32 +128,32 @@ test_that("ArchiveTuning as.data.table function works", {
128128
# default
129129
tab = as.data.table(instance$archive)
130130
expect_data_table(tab, nrows = 4)
131-
expect_names(names(tab), permutation.of = c("cp", "classif.ce", "x_domain_cp", "runtime_learners", "timestamp", "batch_nr", "resample_result", "errors", "warnings"))
131+
expect_names(names(tab), permutation.of = c("cp", "classif.ce", "x_domain", "runtime_learners", "timestamp", "batch_nr", "resample_result", "errors", "warnings"))
132132

133133
# extra measure
134134
tab = as.data.table(instance$archive, measures = msr("classif.acc"))
135135
expect_data_table(tab, nrows = 4)
136-
expect_names(names(tab), permutation.of = c("cp", "classif.ce", "classif.acc", "x_domain_cp", "runtime_learners", "timestamp", "batch_nr", "resample_result", "errors", "warnings"))
136+
expect_names(names(tab), permutation.of = c("cp", "classif.ce", "classif.acc", "x_domain", "runtime_learners", "timestamp", "batch_nr", "resample_result", "errors", "warnings"))
137137

138138
# extra measures
139139
tab = as.data.table(instance$archive, measures = msrs(c("classif.acc", "classif.mcc")))
140140
expect_data_table(tab, nrows = 4)
141-
expect_names(names(tab), permutation.of = c("cp", "classif.ce", "classif.acc", "classif.mcc", "x_domain_cp", "runtime_learners", "timestamp", "batch_nr", "resample_result", "errors", "warnings"))
141+
expect_names(names(tab), permutation.of = c("cp", "classif.ce", "classif.acc", "classif.mcc", "x_domain", "runtime_learners", "timestamp", "batch_nr", "resample_result", "errors", "warnings"))
142142

143143
# exclude column
144144
tab = as.data.table(instance$archive, exclude_columns = "timestamp")
145145
expect_data_table(tab, nrows = 4)
146-
expect_names(names(tab), permutation.of = c("cp", "classif.ce", "x_domain_cp", "runtime_learners", "batch_nr", "uhash", "resample_result", "errors", "warnings"))
146+
expect_names(names(tab), permutation.of = c("cp", "classif.ce", "x_domain", "runtime_learners", "batch_nr", "uhash", "resample_result", "errors", "warnings"))
147147

148148
# exclude columns
149149
tab = as.data.table(instance$archive, exclude_columns = c("timestamp", "uhash"))
150150
expect_data_table(tab, nrows = 4)
151-
expect_names(names(tab), permutation.of = c("cp", "classif.ce", "x_domain_cp", "runtime_learners", "batch_nr", "resample_result", "errors", "warnings"))
151+
expect_names(names(tab), permutation.of = c("cp", "classif.ce", "x_domain", "runtime_learners", "batch_nr", "resample_result", "errors", "warnings"))
152152

153153
# no exclude
154154
tab = as.data.table(instance$archive, exclude_columns = NULL)
155155
expect_data_table(tab, nrows = 4)
156-
expect_names(names(tab), permutation.of = c("cp", "classif.ce", "x_domain_cp", "runtime_learners", "timestamp", "batch_nr", "uhash", "resample_result", "errors", "warnings"))
156+
expect_names(names(tab), permutation.of = c("cp", "classif.ce", "x_domain", "runtime_learners", "timestamp", "batch_nr", "uhash", "resample_result", "errors", "warnings"))
157157

158158
# no unnest
159159
tab = as.data.table(instance$archive, unnest = NULL)
@@ -175,7 +175,7 @@ test_that("ArchiveTuning as.data.table function works", {
175175

176176
tab = as.data.table(instance$archive)
177177
expect_data_table(tab, nrows = 4, ncols = 8)
178-
expect_names(names(tab), permutation.of = c("cp", "classif.ce", "x_domain_cp", "runtime_learners", "timestamp", "batch_nr", "errors", "warnings"))
178+
expect_names(names(tab), permutation.of = c("cp", "classif.ce", "x_domain", "runtime_learners", "timestamp", "batch_nr", "errors", "warnings"))
179179

180180
# empty archive
181181
instance = ti(
@@ -214,7 +214,7 @@ test_that("ArchiveTuning as.data.table function works", {
214214

215215
tab = as.data.table(instance$archive)
216216
expect_data_table(tab, nrows = 4)
217-
expect_names(names(tab), permutation.of = c("x1", "x2", "classif.ce", "x_domain_minsplit", "x_domain_cp", "runtime_learners", "timestamp", "batch_nr", "resample_result", "errors", "warnings"))
217+
expect_names(names(tab), permutation.of = c("x1", "x2", "classif.ce", "x_domain", "runtime_learners", "timestamp", "batch_nr", "resample_result", "errors", "warnings"))
218218

219219
# new ids in x_domain switch
220220
search_space = ps(
@@ -243,7 +243,7 @@ test_that("ArchiveTuning as.data.table function works", {
243243

244244
tab = as.data.table(instance$archive)
245245
expect_data_table(tab, nrows = 100)
246-
expect_names(names(tab), permutation.of = c("x1", "x2", "classif.ce", "x_domain_minsplit", "x_domain_cp", "runtime_learners", "timestamp", "batch_nr", "resample_result", "errors", "warnings"))
246+
expect_names(names(tab), permutation.of = c("x1", "x2", "classif.ce", "x_domain", "runtime_learners", "timestamp", "batch_nr", "resample_result", "errors", "warnings"))
247247

248248
# row order
249249
instance = ti(

0 commit comments

Comments
 (0)