Function to create a CallbackAsyncTuning.
Predefined callbacks are stored in the dictionary mlr_callbacks and can be retrieved with clbk().
Tuning callbacks can be called from different stages of the tuning process.
The stages are prefixed with on_*.
Start Tuning
- on_optimization_begin
Start Worker
- on_worker_begin
Start Optimization on Worker
- on_optimizer_before_eval
Start Evaluation
- on_eval_after_xs
Start Resampling Iteration
- on_resample_begin
- on_resample_before_train
- on_resample_before_predict
- on_resample_end
End Resampling Iteration
- on_eval_after_resample
- on_eval_before_archive
End Evaluation
- on_optimizer_after_eval
End Optimization on Worker
- on_worker_end
End Worker
- on_tuning_result_begin
- on_result_begin
- on_result_end
- on_optimization_end
End TuningSee also the section on parameters for more information on the stages. A tuning callback works with ContextAsyncTuning.
Usage
callback_async_tuning(
id,
label = NA_character_,
man = NA_character_,
on_optimization_begin = NULL,
on_worker_begin = NULL,
on_optimizer_before_eval = NULL,
on_eval_after_xs = NULL,
on_resample_begin = NULL,
on_resample_before_train = NULL,
on_resample_before_predict = NULL,
on_resample_end = NULL,
on_eval_after_resample = NULL,
on_eval_before_archive = NULL,
on_optimizer_after_eval = NULL,
on_worker_end = NULL,
on_tuning_result_begin = NULL,
on_result_begin = NULL,
on_result_end = NULL,
on_result = NULL,
on_optimization_end = NULL
)Arguments
- id
(
character(1))
Identifier for the new instance.- label
(
character(1))
Label for the new instance.- man
(
character(1))
String in the format[pkg]::[topic]pointing to a manual page for this object. The referenced help package can be opened via method$help().- on_optimization_begin
(
function())
Stage called at the beginning of the optimization. Called inOptimizer$optimize(). The functions must have two arguments namedcallbackandcontext.- on_worker_begin
(
function())
Stage called at the beginning of the optimization on the worker. Called in the worker loop. The functions must have two arguments namedcallbackandcontext.- on_optimizer_before_eval
(
function())
Stage called after the optimizer proposes points. Called inOptimInstance$.eval_point(). The functions must have two arguments namedcallbackandcontext. The argument ofinstance$.eval_point(xs)andxs_trafoedandextraare available in thecontext. Orxsandxs_trafoedofinstance$.eval_queue()are available in thecontext.- on_eval_after_xs
(
function())
Stage called after xs is passed to the objective. Called inObjectiveTuningAsync$eval(). The functions must have two arguments namedcallbackandcontext. The argument of$.eval(xs)is available in thecontext.- on_resample_begin
(
function())
Stage called at the beginning of a resampling iteration. Called inworkhorse()(internal). See alsomlr3::callback_resample(). The functions must have two arguments namedcallbackandcontext.- on_resample_before_train
(
function())
Stage called before training the learner. Called inworkhorse()(internal). See alsomlr3::callback_resample(). The functions must have two arguments namedcallbackandcontext.- on_resample_before_predict
(
function())
Stage called before predicting. Called inworkhorse()(internal). See alsomlr3::callback_resample(). The functions must have two arguments namedcallbackandcontext.- on_resample_end
(
function())
Stage called at the end of a resampling iteration. Called inworkhorse()(internal). See alsomlr3::callback_resample(). The functions must have two arguments namedcallbackandcontext.- on_eval_after_resample
(
function())
Stage called after a hyperparameter configuration is evaluated. Called inObjectiveTuningAsync$eval(). The functions must have two arguments namedcallbackandcontext. Theresample_resultis available in the `context- on_eval_before_archive
(
function())
Stage called before performance values are written to the archive. Called inObjectiveTuningAsync$eval(). The functions must have two arguments namedcallbackandcontext. Theaggregated_performanceis available incontext.- on_optimizer_after_eval
(
function())
Stage called after points are evaluated. Called inOptimInstance$.eval_point(). The functions must have two arguments namedcallbackandcontext.- on_worker_end
(
function())
Stage called at the end of the optimization on the worker. Called in the worker loop. The functions must have two arguments namedcallbackandcontext.- on_tuning_result_begin
(
function())
Stage called at the beginning of the result writing. Called inTuningInstance*$assign_result(). The functions must have two arguments namedcallbackandcontext. The arguments of$assign_result(xdt, y, learner_param_vals, extra)are available incontext.- on_result_begin
(
function())
Stage called at the beginning of the result writing. Called inOptimInstance$assign_result(). The functions must have two arguments namedcallbackandcontext. The arguments of$.assign_result(xdt, y, extra)are available in thecontext.- on_result_end
(
function())
Stage called after the result is written. Called inOptimInstance$assign_result(). The functions must have two arguments namedcallbackandcontext. The final resultinstance$resultis available in thecontext.- on_result
(
function())
Deprecated. Useon_result_endinstead. Stage called after the result is written. Called inOptimInstance$assign_result().- on_optimization_end
(
function())
Stage called at the end of the optimization. Called inOptimizer$optimize().
Details
When implementing a callback, each function must have two arguments named callback and context.
A callback can write data to the state ($state), e.g. settings that affect the callback itself.
Tuning callbacks access ContextAsyncTuning and mlr3::ContextResample.
