diff --git a/NAMESPACE b/NAMESPACE index 28e7bb64..6e326f11 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -51,6 +51,7 @@ importFrom(bbotk,trms) importFrom(mlr3misc,clbk) importFrom(mlr3misc,clbks) importFrom(mlr3misc,mlr_callbacks) +importFrom(stats,sd) importFrom(utils,bibentry) importFrom(utils,combn) importFrom(utils,head) diff --git a/R/bibentries.R b/R/bibentries.R index fe01592c..b993f233 100644 --- a/R/bibentries.R +++ b/R/bibentries.R @@ -55,5 +55,19 @@ bibentries = c( journal = "Machine Learning", author = "Isabelle Guyon and Jason Weston and Stephen Barnhill and Vladimir Vapnik", year = "2002" + ), + + kuhn2013 = bibentry("Inbook", + author = "Kuhn, Max and Johnson, Kjell", + chapter = "Over-Fitting and Model Tuning", + title = "Applied Predictive Modeling", + year = "2013", + publisher = "Springer New York", + address = "New York, NY", + pages = "61--92", + isbn = "978-1-4614-6849-3", + doi = "10.1007/978-1-4614-6849-3_4", + url = "https://doi.org/10.1007/978-1-4614-6849-3_4" ) ) + diff --git a/R/mlr_callbacks.R b/R/mlr_callbacks.R index 07217bcb..14c6372b 100644 --- a/R/mlr_callbacks.R +++ b/R/mlr_callbacks.R @@ -117,6 +117,9 @@ load_callback_svm_rfe = function() { #' @description #' Selects the smallest feature set within one standard error of the best as the result. #' +#' @source +#' `r format_bib("kuhn2013")` +#' #' @examples #' clbk("mlr3fselect.one_se_rule") #' @@ -142,7 +145,7 @@ load_callback_one_se_rule = function() { on_result = function(callback, context) { archive = context$instance$archive data = as.data.table(archive) - data[, n_features := map(features, length)] + data[, "n_features" := map(get("features"), length)] # standard error y = data[[archive$cols_y]] diff --git a/R/zzz.R b/R/zzz.R index 2efd5740..5724260f 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -6,11 +6,12 @@ #' @import bbotk #' @importFrom R6 R6Class #' @importFrom utils combn head +#' @importFrom stats sd "_PACKAGE" .onLoad = function(libname, pkgname) { # nocov start - utils::globalVariables(c("super", "self")) + utils::globalVariables(c("super", "self", "n_features")) # reflections x = utils::getFromNamespace("bbotk_reflections", ns = "bbotk") diff --git a/man/mlr3fselect.one_se_rule.Rd b/man/mlr3fselect.one_se_rule.Rd index cde3ab3f..3de6d41d 100644 --- a/man/mlr3fselect.one_se_rule.Rd +++ b/man/mlr3fselect.one_se_rule.Rd @@ -3,6 +3,13 @@ \name{mlr3fselect.one_se_rule} \alias{mlr3fselect.one_se_rule} \title{One Standard Error Rule Callback} +\source{ +Kuhn, Max, Johnson, Kjell (2013). +\dQuote{Applied Predictive Modeling.} +In chapter Over-Fitting and Model Tuning, 61--92. +Springer New York, New York, NY. +ISBN 978-1-4614-6849-3, \doi{10.1007/978-1-4614-6849-3_4}, \url{https://doi.org/10.1007/978-1-4614-6849-3_4}. +} \description{ Selects the smallest feature set within one standard error of the best as the result. } diff --git a/tests/testthat/test_FSelectInstanceSingleCrit.R b/tests/testthat/test_FSelectInstanceSingleCrit.R index 548738e5..dab1f0ce 100644 --- a/tests/testthat/test_FSelectInstanceSingleCrit.R +++ b/tests/testthat/test_FSelectInstanceSingleCrit.R @@ -79,7 +79,7 @@ test_that("always include variable works", { task = task, learner = learner, resampling = resampling, - measure = msr("classif.ce"), + measures = msr("classif.ce"), terminator = trm("evals", n_evals = 100), store_models = TRUE ) @@ -105,7 +105,7 @@ test_that("always include variables works", { task = task, learner = learner, resampling = resampling, - measure = msr("classif.ce"), + measures = msr("classif.ce"), terminator = trm("evals", n_evals = 100), store_models = TRUE )