Function to create a CallbackBatchFSelect.
Predefined callbacks are stored in the dictionary mlr_callbacks and can be retrieved with clbk()
.
Feature selection callbacks can be called from different stages of feature selection.
The stages are prefixed with on_*
.
The on_auto_fselector_*
stages are only available when the callback is used in an AutoFSelector.
Start Automatic Feature Selection
Start Feature Selection
- on_optimization_begin
Start FSelect Batch
- on_optimizer_before_eval
Start Evaluation
- on_eval_after_design
- on_eval_after_benchmark
- on_eval_before_archive
End Evaluation
- on_optimizer_after_eval
End FSelect Batch
- on_result
- on_optimization_end
End Feature Selection
- on_auto_fselector_before_final_model
- on_auto_fselector_after_final_model
End Automatic Feature Selection
See also the section on parameters for more information on the stages. A feature selection callback works with bbotk::ContextBatch and ContextBatchFSelect.
callback_batch_fselect(
id,
label = NA_character_,
man = NA_character_,
on_optimization_begin = NULL,
on_optimizer_before_eval = NULL,
on_eval_after_design = NULL,
on_eval_after_benchmark = NULL,
on_eval_before_archive = NULL,
on_optimizer_after_eval = NULL,
on_result = NULL,
on_optimization_end = NULL,
on_auto_fselector_before_final_model = NULL,
on_auto_fselector_after_final_model = NULL
)
(character(1)
)
Identifier for the new instance.
(character(1)
)
Label for the new instance.
(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()
.
(function()
)
Stage called at the beginning of the optimization.
Called in Optimizer$optimize()
.
(function()
)
Stage called after the optimizer proposes points.
Called in OptimInstance$eval_batch()
.
(function()
)
Stage called after design is created.
Called in ObjectiveFSelectBatch$eval_many()
.
(function()
)
Stage called after feature sets are evaluated.
Called in ObjectiveFSelectBatch$eval_many()
.
(function()
)
Stage called before performance values are written to the archive.
Called in ObjectiveFSelectBatch$eval_many()
.
(function()
)
Stage called after points are evaluated.
Called in OptimInstance$eval_batch()
.
(function()
)
Stage called after result are written.
Called in OptimInstance$assign_result()
.
(function()
)
Stage called at the end of the optimization.
Called in Optimizer$optimize()
.
(function()
)
Stage called before the final model is trained.
Called in AutoFSelector$train()
.
(function()
)
Stage called after the final model is trained.
Called in AutoFSelector$train()
.
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.
Avoid writing large data the state.
# Write archive to disk
callback_batch_fselect("mlr3fselect.backup",
on_optimization_end = function(callback, context) {
saveRDS(context$instance$archive, "archive.rds")
}
)
Run the code above in your browser using DataLab