1

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.

panda
  • 821
  • 1
  • 9
  • 20
  • I think `method="vh"` is redundant it is already implied with `"randomForestSRC_var.select"` hence you get `formal argument "method" matched by multiple actual arguments`. – missuse Sep 26 '19 at 11:16
  • In the package randomForestSRC,function var.select, the default value for method is "md" - minimal depth. Therefore I am able to run the minimal depth filter, by omitting the method parameter, but not the variable hunting filter - method = "vh" or method = "vh.vimp". – panda Sep 27 '19 at 00:38
  • I see. As can be seen from the `mlr` implementation: https://github.com/mlr-org/mlr/blob/master/R/Filter.R only `method = "md"` is supported. Allowing other options would be a fairly easy fix. I think you best bet is to add the functionality yourself and offer a pull request since the mlr team is almost exclusively working on mlr3. – missuse Sep 27 '19 at 05:25

1 Answers1

1

Fixed upstream in this Pull Request.

pat-s
  • 5,992
  • 1
  • 32
  • 60