Skip to content
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

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open

feat: add callbacks for resample and benchmark #1255

wants to merge 59 commits into from

Conversation

be-marc
Copy link
Member

@be-marc be-marc commented Feb 4, 2025

No description provided.

#'
#' @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.
Copy link
Member Author

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?

Copy link
Member Author

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing closing bracket

Comment on lines +555 to +556
cns = c("uhash", "task", "learner", "resampling", "iteration", "prediction")
if ("data_extra" %in% names(tab)) cns = c(cns, "data_extra")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead something like

Suggested change
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")
Copy link
Collaborator

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")
Copy link
Member Author

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`)
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants