在重采样期间,将测试值为 5 和 9 的 max_depth 参数。但是,在训练时,使用了一个完全不同的值 10。我预计在训练期间将设置返回最小 RMSE 的参数。在这种情况下,选择了完全不同的参数值。
library("mlr3")
library("paradox")
library("mlr3learners")
library("mlr3tuning")
library("data.table")
set.seed(10)
x1 = 1:100
x2 = 2 * x1
y = x1^2 - x2 + rnorm(100)
data = data.table(
x1 = x1,
x2 = x2,
y = y
)
task = TaskRegr$new("task", backend = data, target = "y")
lrn_xgb = mlr_learners$get("regr.xgboost")
ps = ParamSet$new(
params = list(
ParamInt$new(id = "max_depth", lower = 4, upper = 10)
))
at = AutoTuner$new(learner = lrn_xgb,
resampling = rsmp("cv", folds = 2),
measures = msr("regr.rmse"),
tune_ps = ps,
terminator = term("evals", n_evals = 1),
tuner = tnr("random_search"))
resampling_outer = rsmp("cv", folds = 2)
rr = resample(task = task, learner = at, resampling = resampling_outer)
#> max_depth = 5
#> max_depth = 9
at$train(task)
#> max_depth = 10
会话信息:
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8.1 x64 (build 9600)
Matrix products: default
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] mlr3learners_0.1.3 mlr3tuning_0.1.0 data.table_1.12.2
[4] paradox_0.1.0 mlr3_0.1.3
loaded via a namespace (and not attached):
[1] lgr_0.3.3 lattice_0.20-38 mlr3misc_0.1.4
[4] digest_0.6.21 crayon_1.3.4 grid_3.6.1
[7] R6_2.4.0 backports_1.1.4 magrittr_1.5
[10] stringi_1.4.3 uuid_0.1-2 Matrix_1.2-17
[13] checkmate_1.9.4 xgboost_0.90.0.2 tools_3.6.1
[16] compiler_3.6.1 Metrics_0.1.4