When I use the randomForestSRC_var.select filter and pass a method parameter to it (e.g. method="vh" for variable hunting) I get a name clash because an internal function also uses a parameter called method. This was raised as an issue on Github, but was said to have been resolved: https://github.com/mlr-org/mlr/issues/1066. I have also opened an issue on Github: https://github.com/mlr-org/mlr/issues/2639 but thought this might be a more appropriate forum, in case it is not a bug but a fault on my part.
Here is my code:
library(survival)
#> Warning: package 'survival' was built under R version 3.5.3
library(mlr)
#> Loading required package: ParamHelpers
data(veteran)
set.seed(24601)
task_id = "VET"
vet.task <- makeSurvTask(id = task_id, data = veteran, target = c("time", "status"))
vet.task <- createDummyFeatures(vet.task)
tuning = makeResampleDesc("CV", iters=2, stratify=TRUE)
outer = makeResampleDesc("CV", iters=2, stratify=TRUE)
filt = makeFilterWrapper(
makeLearner(cl="surv.coxph", id = "cox.filt.rfsrc", predict.type="response"),
fw.method="randomForestSRC_var.select",
fw.abs=4,
cache=TRUE,
ntree=500,
method="vh"
)
bmr = benchmark(filt, vet.task, outer, list(cindex), show.info = TRUE, models=TRUE, keep.extract=FALSE)
#> Task: VET, Learner: cox.filt.rfsrc.filtered
#> Resampling: cross-validation
#> Measures: cindex
#> Error in (function (task, method = "randomForestSRC_importance", fval = NULL, : formal argument "method" matched by multiple actual arguments
Created on 2019-09-25 by the reprex package (v0.3.0)
If I change argument method to "metho" to try and avoid the clash I get a different error:
library(survival)
#> Warning: package 'survival' was built under R version 3.5.3
library(mlr)
#> Loading required package: ParamHelpers
data(veteran)
set.seed(24601)
task_id = "VET"
vet.task <- makeSurvTask(id = task_id, data = veteran, target = c("time", "status"))
vet.task <- createDummyFeatures(vet.task)
tuning = makeResampleDesc("CV", iters=2, stratify=TRUE)
outer = makeResampleDesc("CV", iters=2, stratify=TRUE)
filt = makeFilterWrapper(
makeLearner(cl="surv.coxph", id = "cox.filt.rfsrc", predict.type="response"),
fw.method="randomForestSRC_var.select",
fw.abs=4,
cache=TRUE,
ntree=500,
metho="vh"
)
bmr = benchmark(filt, vet.task, outer, list(cindex), show.info = TRUE, models=TRUE, keep.extract=FALSE)
#> Task: VET, Learner: cox.filt.rfsrc.filtered
#> Resampling: cross-validation
#> Measures: cindex
#> Error in -im[, 1L]: invalid argument to unary operator
Created on 2019-09-25 by the reprex package (v0.3.0)
It seems that this error is coming from the line:
setNames(-im[, 1L], rownames(im))
in the RF min depth filter and I assume implies that variable im, the results of the filter, is NULL (although I am not sure why). Is there any way around this problem? Apologies for posting here and on GH.
Fixed upstream in this Pull Request.