From 8f7f308396e6eadda41c4e2497d921ef72882827 Mon Sep 17 00:00:00 2001 From: be-marc Date: Tue, 3 Dec 2024 17:20:17 +0100 Subject: [PATCH] add iteration to context --- R/ContextEvaluation.R | 7 ++++++- R/worker.R | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/R/ContextEvaluation.R b/R/ContextEvaluation.R index 9c366aa5f..d12a1e76f 100644 --- a/R/ContextEvaluation.R +++ b/R/ContextEvaluation.R @@ -30,6 +30,10 @@ ContextEvaluation = R6Class("ContextEvaluation", #' Is usually only set while tuning. param_values = NULL, + #' @field iteration (`integer()`)\cr + #' The current iteration. + iteration = NULL, + #' @field sets (`list()`)\cr #' The train and test set. #' The sets are available on stage `on_evaluation_before_train``. @@ -66,11 +70,12 @@ ContextEvaluation = R6Class("ContextEvaluation", #' The resampling strategy to be used. #' @param param_values (`list()`)\cr #' The parameter values to be used. - initialize = function(task, learner, resampling, param_values) { + initialize = function(task, learner, resampling, param_values, iteration) { # no assertions to avoid overhead self$task = task self$learner = learner self$resampling = resampling + self$iteration = iteration super$initialize(id = "evaluate", label = "Evaluation") } diff --git a/R/worker.R b/R/worker.R index bf3ecb51e..957e223e2 100644 --- a/R/worker.R +++ b/R/worker.R @@ -265,7 +265,7 @@ workhorse = function( unmarshal = TRUE, callbacks = NULL ) { - ctx = ContextEvaluation$new(task, learner, resampling, param_values) + ctx = ContextEvaluation$new(task, learner, resampling, param_values, iteration) call_back("on_evaluation_begin", callbacks, ctx)