From dd5e37c6aac46a2ce50d0e98cbb6c0737426b0ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20M=C3=BCcke?= Date: Thu, 2 Jan 2025 14:05:27 +0100 Subject: [PATCH] docs(extending): use `set_values` in example code (#402) * docs(extending): use `set_values` in example code * docs(extending): same pattern for importance example function --- vignettes/extending.Rmd | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/vignettes/extending.Rmd b/vignettes/extending.Rmd index 9e391db09..8b42e3f76 100644 --- a/vignettes/extending.Rmd +++ b/vignettes/extending.Rmd @@ -40,7 +40,7 @@ LearnerRegrRpartSimple = R6Class("LearnerRegrRpartSimple", usesurrogate = p_int(0L, 2L, default = 2L, tags = "train"), xval = p_int(0L, default = 10L, tags = "train") ) - param_set$values$xval = 10 + param_set$set_values(xval = 10L) super$initialize( id = "regr.rpart_simple", feature_types = c("logical", "integer", "numeric", "factor", "ordered"), @@ -58,11 +58,10 @@ LearnerRegrRpartSimple = R6Class("LearnerRegrRpartSimple", } # importance is only present if there is at least on split if (is.null(self$model$variable.importance)) { - importance = set_names(numeric()) + set_names(numeric()) } else { - importance = sort(self$model$variable.importance, decreasing = TRUE) + sort(self$model$variable.importance, decreasing = TRUE) } - return(importance) } ), private = list( @@ -285,11 +284,10 @@ importance = function() { } # importance is only present if there is at least on split if (is.null(self$model$variable.importance)) { - importance = set_names(numeric()) + set_names(numeric()) } else { - importance = sort(self$model$variable.importance, decreasing = TRUE) + sort(self$model$variable.importance, decreasing = TRUE) } - return(importance) } ```