Closed mareichhoff closed 6 years ago
That's the reason why I wanted to use the development version because I thought that you might corrected the error there already....
By the way, when I set importance = "FALSE" an error message appears, that FALSE is not a feasible parameter setting, although it should be allowed. "none" works. Perhaps "FALSE" should be deleted according to the rfsrc function parameters from the original package?
importance
is not tunable so you cannot set in in the param set:
getParamSet("regr.randomForestSRC")
Type len Def Constr Req Tunable Trafo
ntree integer - 1000 1 to Inf - TRUE -
bootstrap discrete - by.root by.root,by.node,none - TRUE -
mtry integer - - 1 to Inf - TRUE -
nodesize integer - 5 1 to Inf - TRUE -
nodedepth integer - -1 -Inf to Inf - TRUE -
splitrule discrete - mse mse,mse.unwt,mse.hvwt,random - TRUE -
nsplit integer - 0 0 to Inf Y TRUE -
split.null logical - FALSE - - TRUE -
importance discrete - FALSE FALSE,TRUE,none,permute,random,anti,p... - FALSE -
na.action discrete - na.impute na.omit,na.impute - TRUE -
nimpute integer - 1 1 to Inf - TRUE -
proximity discrete - FALSE inbag,oob,all,TRUE,FALSE - FALSE -
sampsize integer - - 1 to Inf Y TRUE -
samptype discrete - swr swr,swor Y TRUE -
xvar.wt numericvector <NA> - 0 to Inf - TRUE -
forest logical - TRUE - - FALSE -
var.used discrete - FALSE FALSE,all.trees,by.tree - FALSE -
split.depth discrete - FALSE FALSE,all.trees,by.tree - FALSE -
seed integer - - -Inf to 0 - FALSE -
do.trace logical - FALSE - - FALSE -
membership logical - TRUE - - FALSE -
statistics logical - FALSE - - FALSE -
tree.err logical - FALSE - - FALSE -
Instead, you need to declare it in the makeLearner()
call and pass the created object onto makeTuneWrapper()
. See the example below.
Usage questions like this do usually better fit to stackoverflow than Github.
Happy to help :)
library(mlr)
#> Loading required package: ParamHelpers
library(mlbench)
data("BostonHousing")
task <- bh.task
measures <- mse
rdesc.inner <- makeResampleDesc("CV", iters = 2L)
rdesc.outer <- makeResampleDesc("CV", iters = 2L)
train.ids <- sample(500L, 333L)
test.ids <- setdiff(1:500,train.ids)
train <- BostonHousing[train.ids,]
test <- BostonHousing[test.ids,]
regr.task.nested <- makeRegrTask(id="bh.nested", data=train, target="medv")
ps = makeParamSet(makeDiscreteParam(id="ntree", 500L),
makeDiscreteParam(id="mtry", 3L),
makeDiscreteParam(id="nodesize", 3L))
lrn = makeLearner("regr.randomForestSRC", importance = TRUE)
tune.ctrl <- makeTuneControlGrid()
wrap.tune.rf <- makeTuneWrapper(learner = lrn,
resampling = rdesc.inner,
measures = measures,
par.set = ps,
control = tune.ctrl)
bench <- benchmark(learners=list(wrap.tune.rf),
tasks=regr.task.nested,
resamplings=rdesc.outer,
measures=measures,
keep.pred=TRUE,
models=TRUE)
#> Task: bh.nested, Learner: regr.randomForestSRC.tuned
#> Resampling: cross-validation
#> Measures: mse
#> [Tune] Started tuning learner regr.randomForestSRC for parameter set:
#> Type len Def Constr Req Tunable Trafo
#> ntree discrete - - 500 - TRUE -
#> mtry discrete - - 3 - TRUE -
#> nodesize discrete - - 3 - TRUE -
#> With control class: TuneControlGrid
#> Imputation value: Inf
#> [Tune-x] 1: ntree=500; mtry=3; nodesize=3
#> [Tune-y] 1: mse.test.mean=24.3093263; time: 0.0 min
#> [Tune] Result: ntree=500; mtry=3; nodesize=3 : mse.test.mean=24.3093263
#> [Resample] iter 1: 13.9461887
#> [Tune] Started tuning learner regr.randomForestSRC for parameter set:
#> Type len Def Constr Req Tunable Trafo
#> ntree discrete - - 500 - TRUE -
#> mtry discrete - - 3 - TRUE -
#> nodesize discrete - - 3 - TRUE -
#> With control class: TuneControlGrid
#> Imputation value: Inf
#> [Tune-x] 1: ntree=500; mtry=3; nodesize=3
#> [Tune-y] 1: mse.test.mean=17.7706289; time: 0.0 min
#> [Tune] Result: ntree=500; mtry=3; nodesize=3 : mse.test.mean=17.7706289
#> [Resample] iter 2: 19.9521484
#>
#> Aggregated Result: mse.test.mean=16.9491685
#>
Created on 2018-06-29 by the [reprex package](http://reprex.tidyverse.org) (v0.2.0).
Moment Patrick! Thank you very much for your answer, but I think anyway I am right here. It's clear that the parameter is not tunable. But I still can set them fixed in the makeParamSet. If I use the following, then it works:
ps = makeParamSet(makeDiscreteParam(id="ntree", c(500,1000)),
makeDiscreteParam(id="mtry", c(3L,4L)),
makeDiscreteParam(id="nodesize", 3:5),
makeDiscreteParam(id="importance", "none"),
makeLogicalParam(id="do.trace", TRUE),
makeLogicalParam(id="membership", TRUE),
makeLogicalParam(id="statistics", TRUE),
makeLogicalParam(id="tree.err", TRUE))
Then this shouldn't wok as well! But it works fine! So the question stays: Why is importance set to "TRUE" in makeParamSet not possible, but "none" is possible.
What is the difference between "none" and "FALSE"?
O.k., I added in my original data some lines (membership etc.), but that doesn't matter.
Then this shouldn't wok as well! But it works fine! So the question stays: Why is importance set to "TRUE" in makeParamSet not possible, but "none" is possible.
Idk this but I assume its due to the way the arguments are parsed. Maybe this is indeed a bug but I am not sure here. One of the two behaviors should def not happen: Either all argument options should be specifiable or none.
Practical advice: I would only pass tunable arguments to the param set and set fixed ones in the learner.
What is the difference between "none" and "FALSE"?
Idk, isn't this document in the help pages of the package?
Not, it's not documented! I looked there. I just find. There exist "none" and "TRUE" and some others. But "FALSE" is not explained. That's why it's strange...
Strange. I opened a new issue, because this has been closed. Thank you for your help!
Hello Lars, Bernd and all the others,
I have the problem that importance = "TRUE" is not being accepted when I like to tune. By the way... what is the difference between "FALSE" and "none"? FALSE is not explained in the randomForestSRC documentation. Some weeks before it worked with importance="TRUE" (perhaps you changed something when updating the package).
Here is my "quite minimal" example and the session information afterwards:
Output:
Thank you very much for your help!