clbk("mlr3tuning.early_stopping")
# \donttest{
if (requireNamespace("mlr3learners") && requireNamespace("xgboost") ) {
library(mlr3learners)
# activate early stopping on the test set and set search space
learner = lrn("classif.xgboost",
eta = to_tune(1e-02, 1e-1, logscale = TRUE),
early_stopping_rounds = 5,
nrounds = 100,
early_stopping_set = "test")
# tune xgboost on the pima data set
instance = tune(
tuner = tnr("random_search"),
task = tsk("pima"),
learner = learner,
resampling = rsmp("cv", folds = 3),
measures = msr("classif.ce"),
term_evals = 10,
callbacks = clbk("mlr3tuning.early_stopping")
)
}
# }
Run the code above in your browser using DataLab