Skip to content

Commit

Permalink
fix: remove unused hyperparameter of ranger (#316)
Browse files Browse the repository at this point in the history
* fix: remove unused hyperparameter of ranger

* ...
  • Loading branch information
be-marc authored Oct 25, 2024
1 parent 3a93084 commit 3cbc64d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
8 changes: 2 additions & 6 deletions R/LearnerClassifRanger.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,14 @@ LearnerClassifRanger = R6Class("LearnerClassifRanger",
#' Creates a new instance of this [R6][R6::R6Class] class.
initialize = function() {
ps = ps(
# FIXME: only works if predict_type == "se". How to set dependency?
alpha = p_dbl(default = 0.5, tags = "train"),
always.split.variables = p_uty(tags = "train"),
class.weights = p_uty(default = NULL, tags = "train"),
holdout = p_lgl(default = FALSE, tags = "train"),
importance = p_fct(c("none", "impurity", "impurity_corrected", "permutation"), tags = "train"),
keep.inbag = p_lgl(default = FALSE, tags = "train"),
max.depth = p_int(default = NULL, lower = 0L, special_vals = list(NULL), tags = "train"),
max.depth = p_int(default = NULL, lower = 1L, special_vals = list(NULL), tags = "train"),
min.bucket = p_int(1L, default = 1L, tags = "train"),
min.node.size = p_int(1L, default = NULL, special_vals = list(NULL), tags = "train"),
minprop = p_dbl(default = 0.1, tags = "train"),
mtry = p_int(lower = 1L, special_vals = list(NULL), tags = "train"),
mtry.ratio = p_dbl(lower = 0, upper = 1, tags = "train"),
num.random.splits = p_int(1L, default = 1L, tags = "train", depends = quote(splitrule == "extratrees")),
Expand All @@ -57,11 +54,10 @@ LearnerClassifRanger = R6Class("LearnerClassifRanger",
regularization.factor = p_uty(default = 1, tags = "train"),
regularization.usedepth = p_lgl(default = FALSE, tags = "train"),
replace = p_lgl(default = TRUE, tags = "train"),
respect.unordered.factors = p_fct(c("ignore", "order", "partition"), default = "ignore", tags = "train"),
respect.unordered.factors = p_fct(c("ignore", "order", "partition"), tags = "train"),
sample.fraction = p_dbl(0L, 1L, tags = "train"),
save.memory = p_lgl(default = FALSE, tags = "train"),
scale.permutation.importance = p_lgl(default = FALSE, tags = "train", depends = quote(importance == "permutation")),
se.method = p_fct(c("jack", "infjack"), default = "infjack", tags = "predict"),
seed = p_int(default = NULL, special_vals = list(NULL), tags = c("train", "predict")),
split.select.weights = p_uty(default = NULL, tags = "train"),
splitrule = p_fct(c("gini", "extratrees", "hellinger"), default = "gini", tags = "train"),
Expand Down
6 changes: 2 additions & 4 deletions R/LearnerRegrRanger.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ LearnerRegrRanger = R6Class("LearnerRegrRanger",
#' Creates a new instance of this [R6][R6::R6Class] class.
initialize = function() {
ps = ps(
alpha = p_dbl(default = 0.5, tags = "train", depends = quote(splitrule == "maxstat")),
always.split.variables = p_uty(tags = "train"),
holdout = p_lgl(default = FALSE, tags = "train"),
importance = p_fct(c("none", "impurity", "impurity_corrected", "permutation"), tags = "train"),
keep.inbag = p_lgl(default = FALSE, tags = "train"),
max.depth = p_int(default = NULL, lower = 0L, special_vals = list(NULL), tags = "train"),
max.depth = p_int(default = NULL, lower = 1L, special_vals = list(NULL), tags = "train"),
min.bucket = p_int(1L, default = 1L, tags = "train"),
min.node.size = p_int(1L, default = 5L, special_vals = list(NULL), tags = "train"),
minprop = p_dbl(default = 0.1, tags = "train", depends = quote(splitrule == "maxstat")),
mtry = p_int(lower = 1L, special_vals = list(NULL), tags = "train"),
mtry.ratio = p_dbl(lower = 0, upper = 1, tags = "train"),
node.stats = p_lgl(default = FALSE, tags = "train"),
Expand All @@ -46,7 +44,7 @@ LearnerRegrRanger = R6Class("LearnerRegrRanger",
regularization.factor = p_uty(default = 1, tags = "train"),
regularization.usedepth = p_lgl(default = FALSE, tags = "train"),
replace = p_lgl(default = TRUE, tags = "train"),
respect.unordered.factors = p_fct(c("ignore", "order", "partition"), default = "ignore", tags = "train"),
respect.unordered.factors = p_fct(c("ignore", "order", "partition"), tags = "train"),
sample.fraction = p_dbl(0L, 1L, tags = "train"),
save.memory = p_lgl(default = FALSE, tags = "train"),
scale.permutation.importance = p_lgl(default = FALSE, tags = "train", depends = quote(importance == "permutation")),
Expand Down
5 changes: 4 additions & 1 deletion inst/paramtest/test_paramtest_classif.ranger.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ test_that("classif.ranger", {
"status.variable.name", # handled via mlr3
"classification", # handled via mlr3
"mtry.ratio", # custom hyperpar
"time.interest" # survival only
"time.interest", # survival only
"alpha", # survival only
"minprop", # survival only
"se.method" # regression only
)

ParamTest = run_paramtest(learner, fun, exclude, tag = "train")
Expand Down
4 changes: 3 additions & 1 deletion inst/paramtest/test_paramtest_regr.ranger.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ test_that("regr.ranger", {
"classification", # handled via mlr3
"mtry.ratio", # custom hyperpar
"time.interest", # survival only
"quantreg" # handled by predict_type
"quantreg", # handled by predict_type
"alpha", # survival only
"minprop" # survival only
)

ParamTest = run_paramtest(learner, fun, exclude, tag = "train")
Expand Down

0 comments on commit 3cbc64d

Please sign in to comment.