-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add callbacks for resample and benchmark #1255
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Sebastian Fischer <[email protected]>
#' | ||
#' @description | ||
#' Specialized [mlr3misc::Callback] to customize the behavior of [resample()] and [benchmark()] in mlr3. | ||
#' The [callback_resample()] function is used to create instances of this class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What can you do with callbacks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example save file to disk or extract information from models
#' @param null_ok (`logical(1)`)\cr | ||
#' If `TRUE`, `NULL` is allowed. | ||
#' | ||
#' @return [CallbackResample | List of [CallbackResample]s. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing closing bracket
cns = c("uhash", "task", "learner", "resampling", "iteration", "prediction") | ||
if ("data_extra" %in% names(tab)) cns = c(cns, "data_extra") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead something like
cns = c("uhash", "task", "learner", "resampling", "iteration", "prediction") | |
if ("data_extra" %in% names(tab)) cns = c(cns, "data_extra") | |
cns = c("uhash", "task", "learner", "resampling", "iteration", "prediction", | |
if ("data_extra" %in% names(tab)) "data_extra") |
(same story further down)
@@ -373,7 +380,9 @@ ResampleResult = R6Class("ResampleResult", | |||
as.data.table.ResampleResult = function(x, ..., predict_sets = "test") { # nolint | |||
private = get_private(x) | |||
tab = private$.data$as_data_table(view = private$.view, predict_sets = predict_sets) | |||
tab[, c("task", "learner", "resampling", "iteration", "prediction"), with = FALSE] | |||
cns = c("task", "learner", "resampling", "iteration", "prediction") | |||
if ("data_extra" %in% names(tab)) cns = c(cns, "data_extra") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(see above)
#' | ||
#' @export | ||
#' @examples | ||
#' task = tsk("pima") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add more examples also with data_extra
#' ``` | ||
#' Start Resampling Iteration on Worker | ||
#' - on_resample_begin | ||
#' (Split `ctx$task` into training and test set with `ctx$resampling` and `ctx$iteration`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarify that this happens in workhorse() and not in the callback
No description provided.