-
-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
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:
# 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.