| Callback | R Documentation |
Callbacks allow to customize the behavior of processes in mlr3 packages. The following packages implement callbacks:
CallbackOptimization in bbotk.
CallbackTuning in mlr3tuning.
CallbackTorch in mlr3torch
Callback is an abstract base class.
A subclass inherits from Callback and adds stages as public members.
Names of stages should start with "on_".
For each subclass a function should be implemented to create the callback.
For an example on how to implement such a function see callback_optimization() in bbotk.
Callbacks are executed at stages using the function call_back().
A Context defines which information can be accessed from the callback.
id(character(1))
Identifier of the callback.
label(character(1))
Label for this object.
Can be used in tables, plot and text output instead of the ID.
man(character(1))
String in the format [pkg]::[topic] pointing to a manual page for this object.
Defaults to NA, but can be set by child classes.
state(named list())
A callback can write data into the state.
new()Creates a new instance of this R6 class.
Callback$new(id, label = NA_character_, man = NA_character_)
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().
format()Helper for print outputs.
Callback$format(...)
...(ignored).
print()Printer.
Callback$print(...)
...(ignored).
help()Opens the corresponding help page referenced by field $man.
Callback$help()
call()Call the specific stage for a given context.
Callback$call(stage, context)
stage(character(1))
stage.
context(Context)
Context.
clone()The objects of this class are cloneable with this method.
Callback$clone(deep = FALSE)
deepWhether to make a deep clone.
library(R6)
# implement callback subclass
CallbackExample = R6Class("CallbackExample",
inherit = mlr3misc::Callback,
public = list(
on_stage_a = NULL,
on_stage_b = NULL,
on_stage_c = NULL
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.