Skip to content

Commit

Permalink
Merge pull request #331 from m-muecke/set-values
Browse files Browse the repository at this point in the history
refactor: use more `set_values()`
  • Loading branch information
sebffischer authored Jan 2, 2025
2 parents de0032f + fe2baf9 commit 4f8d0d1
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion R/LearnerClassifKKNN.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ LearnerClassifKKNN = R6Class("LearnerClassifKKNN",
ykernel = p_uty(default = NULL, tags = "train"),
store_model = p_lgl(default = FALSE, tags = "train")
)
ps$values = list(k = 7L)
ps$set_values(k = 7L)

super$initialize(
id = "classif.kknn",
Expand Down
2 changes: 1 addition & 1 deletion R/LearnerClassifNnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ LearnerClassifNnet = R6Class("LearnerClassifNnet",
trace = p_lgl(default = TRUE, tags = "train"),
formula = p_uty(tags = "train")
)
ps$values = list(size = 3L)
ps$set_values(size = 3L)

super$initialize(
id = "classif.nnet",
Expand Down
2 changes: 1 addition & 1 deletion R/LearnerClassifRanger.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ LearnerClassifRanger = R6Class("LearnerClassifRanger",
write.forest = p_lgl(default = TRUE, tags = "train")
)

ps$values = list(num.threads = 1L)
ps$set_values(num.threads = 1L)

super$initialize(
id = "classif.ranger",
Expand Down
2 changes: 1 addition & 1 deletion R/LearnerClassifXgboost.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ LearnerClassifXgboost = R6Class("LearnerClassifXgboost",
)

# custom defaults
ps$values = list(nrounds = 1000L, nthread = 1L, verbose = 0L)
ps$set_values(nrounds = 1000L, nthread = 1L, verbose = 0L)

super$initialize(
id = "classif.xgboost",
Expand Down
2 changes: 1 addition & 1 deletion R/LearnerRegrCVGlmnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ LearnerRegrCVGlmnet = R6Class("LearnerRegrCVGlmnet",
upper.limits = p_uty(tags = "train")
)

ps$values = list(family = "gaussian")
ps$set_values(family = "gaussian")

super$initialize(
id = "regr.cv_glmnet",
Expand Down
2 changes: 1 addition & 1 deletion R/LearnerRegrGlmnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ LearnerRegrGlmnet = R6Class("LearnerRegrGlmnet",
upper.limits = p_uty(tags = "train")
)

ps$values = list(family = "gaussian")
ps$set_values(family = "gaussian")

super$initialize(
id = "regr.glmnet",
Expand Down
2 changes: 1 addition & 1 deletion R/LearnerRegrKKNN.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ LearnerRegrKKNN = R6Class("LearnerRegrKKNN",
store_model = p_lgl(default = FALSE, tags = "train")
)

ps$values = list(k = 7L)
ps$set_values(k = 7L)

super$initialize(
id = "regr.kknn",
Expand Down
2 changes: 1 addition & 1 deletion R/LearnerRegrNnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ LearnerRegrNnet = R6Class("LearnerRegrNnet",
trace = p_lgl(default = TRUE, tags = "train"),
formula = p_uty(tags = "train")
)
ps$values = list(size = 3L)
ps$set_values(size = 3L)

super$initialize(
id = "regr.nnet",
Expand Down
2 changes: 1 addition & 1 deletion R/LearnerRegrRanger.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ LearnerRegrRanger = R6Class("LearnerRegrRanger",
write.forest = p_lgl(default = TRUE, tags = "train")
)

ps$values = list(num.threads = 1L)
ps$set_values(num.threads = 1L)

super$initialize(
id = "regr.ranger",
Expand Down
2 changes: 1 addition & 1 deletion R/LearnerRegrXgboost.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ LearnerRegrXgboost = R6Class("LearnerRegrXgboost",
# param deps

# custom defaults
ps$values = list(nrounds = 1000L, nthread = 1L, verbose = 0L)
ps$set_values(nrounds = 1000L, nthread = 1L, verbose = 0L)

super$initialize(
id = "regr.xgboost",
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_classif_kknn.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test_that("custom model", {
expect_data_table(mod$data)
expect_list(mod$pv, names = "unique")

learner$param_set$values = list(k = 3, store_model = FALSE)
learner$param_set$set_values(k = 3, store_model = FALSE)
learner$train(task)$predict(task)
expect_null(learner$model$kknn)
})
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_classif_ranger.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ skip_if_not_installed("ranger")
test_that("autotest", {
learner = mlr3::lrn("classif.ranger")
expect_learner(learner)
learner$param_set$values = list(num.trees = 30L, importance = "impurity")
learner$param_set$set_values(num.trees = 30L, importance = "impurity")
result = run_autotest(learner)
expect_true(result, info = result$error)
})
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_regr_kknn.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test_that("custom model", {
expect_data_table(mod$data)
expect_list(mod$pv, names = "unique")

learner$param_set$values = list(k = 3, store_model = FALSE)
learner$param_set$set_values(k = 3, store_model = FALSE)
learner$train(task)$predict(task)
expect_null(learner$model$kknn)
})
Expand Down

0 comments on commit 4f8d0d1

Please sign in to comment.