Skip to content

Commit

Permalink
fix(at): unused AB and check on required params (#472)
Browse files Browse the repository at this point in the history
* fixes

* ...
  • Loading branch information
sebffischer authored Nov 26, 2024
1 parent 3e7cbf8 commit 87f4f41
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 18 deletions.
9 changes: 1 addition & 8 deletions R/AutoTuner.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ AutoTuner = R6Class("AutoTuner",
) {
learner = assert_learner(as_learner(learner, clone = TRUE))

if (!is.null(search_space) && length(learner$param_set$get_values(type = "only_token")) > 0) {
if (!is.null(search_space) && length(learner$param_set$get_values(type = "only_token", check_required = FALSE)) > 0) {
stop("If the values of the ParamSet of the Learner contain TuneTokens you cannot supply a search_space.")
}

Expand Down Expand Up @@ -288,13 +288,6 @@ AutoTuner = R6Class("AutoTuner",
),

active = list(
#' @field internal_valid_scores
#' Retrieves the inner validation scores as a named `list()`.
#' Returns `NULL` if learner is not trained yet.
internal_valid_scores = function() {
self$state$internal_valid_scores
},

#' @field archive [ArchiveBatchTuning]\cr
#' Archive of the [TuningInstanceBatchSingleCrit].
archive = function() self$tuning_instance$archive,
Expand Down
2 changes: 1 addition & 1 deletion R/TuningInstanceAsyncMulticrit.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ TuningInstanceAsyncMultiCrit = R6Class("TuningInstanceAsyncMultiCrit",
callbacks = assert_async_tuning_callbacks(as_callbacks(callbacks))

# tune token and search space
if (!is.null(search_space) && length(learner$param_set$get_values(type = "only_token"))) {
if (!is.null(search_space) && length(learner$param_set$get_values(type = "only_token", check_required = FALSE))) {
stop("If the values of the ParamSet of the Learner contain TuneTokens you cannot supply a search_space.")
}

Expand Down
2 changes: 1 addition & 1 deletion R/TuningInstanceAsyncSingleCrit.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ TuningInstanceAsyncSingleCrit = R6Class("TuningInstanceAsyncSingleCrit",
callbacks = assert_async_tuning_callbacks(as_callbacks(callbacks))

# tune token and search space
if (!is.null(search_space) && length(learner$param_set$get_values(type = "only_token"))) {
if (!is.null(search_space) && length(learner$param_set$get_values(type = "only_token", check_required = FALSE))) {
stop("If the values of the ParamSet of the Learner contain TuneTokens you cannot supply a search_space.")
}

Expand Down
4 changes: 2 additions & 2 deletions R/TuningInstanceBatchMulticrit.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ TuningInstanceBatchMultiCrit = R6Class("TuningInstanceBatchMultiCrit",
callbacks = assert_batch_tuning_callbacks(as_callbacks(callbacks))

# tune token and search space
if (!is.null(search_space) && length(learner$param_set$get_values(type = "only_token"))) {
if (!is.null(search_space) && length(learner$param_set$get_values(type = "only_token", check_required = FALSE))) {
stop("If the values of the ParamSet of the Learner contain TuneTokens you cannot supply a search_space.")
}

Expand Down Expand Up @@ -129,7 +129,7 @@ TuningInstanceBatchMultiCrit = R6Class("TuningInstanceBatchMultiCrit",

# set learner parameter values
if (search_space_from_tokens) {
learner$param_set$values = learner$param_set$get_values(type = "without_token")
learner$param_set$values = learner$param_set$get_values(type = "without_token", check_required = TRUE)
}

if (!is.null(self$internal_search_space) && self$internal_search_space$has_trafo) {
Expand Down
2 changes: 1 addition & 1 deletion R/TuningInstanceBatchSingleCrit.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ TuningInstanceBatchSingleCrit = R6Class("TuningInstanceBatchSingleCrit",
callbacks = assert_batch_tuning_callbacks(as_callbacks(callbacks))

# tune token and search space
if (!is.null(search_space) && length(learner$param_set$get_values(type = "only_token"))) {
if (!is.null(search_space) && length(learner$param_set$get_values(type = "only_token", check_required = FALSE))) {
stop("If the values of the ParamSet of the Learner contain TuneTokens you cannot supply a search_space.")
}

Expand Down
3 changes: 0 additions & 3 deletions man/AutoTuner.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/mlr_tuners_cmaes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 87f4f41

Please sign in to comment.