You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using transformation (trafo) method for my ranger learner. The problem is that I need the number of features (columns) in task to transform my param_set. For example:
# random forest
learner = lrn("classif.ranger", predict_type = "prob", predict_sets = c("train", "test"))
learner_params = ParamSet$new(
params = list(
ParamInt$new("max.depth", lower = 2, upper = 10, tags = "ranger"),
ParamDbl$new("mtry", lower = 0.1, upper = 0.9, default = 0.5)
))
learner_params$trafo = function(x, param_set) { # This is slight modification (simplification) from mlr automl package
if ("mtry" %in% names(x)) {
proposed_mtry = as.integer(length(task$feature_names)^x[["mtry"]]) ### HREE THE PROBLEM ####
x[["mtry"]] = max(1, proposed_mtry)
}
x
}
rf = make_auto_tuner(learner, learner_params)
On the line HERE THE PROBLEM I would like to add number of features. Now I use task$features_name, but this works only if I have one task. Is there any more clever way to set number of columns here.
The text was updated successfully, but these errors were encountered:
Hey,
we have a working solution in mlr-org/paradox#323. So you need to install the expression_params branch with devtools::install_github("mlr-org/paradox@expression_params", force = TRUE). It seems we are not happy with the syntax and therefore did not merge the PR. You can still use it. Your example would look like this:
Hi,
I am using transformation (trafo) method for my ranger learner. The problem is that I need the number of features (columns) in task to transform my param_set. For example:
On the line HERE THE PROBLEM I would like to add number of features. Now I use task$features_name, but this works only if I have one task. Is there any more clever way to set number of columns here.
The text was updated successfully, but these errors were encountered: