How can I use rsample for multiple mrl algorithms?

36 Views Asked by At

I have some difficulty using the function resample of mlr package, in my case for example.

library(mlr)

learners = makeLearners(cls = c("C50", "rpart","ada","naiveBayes"), type = "classif", predict.type = "prob")

data_task = makeClassifTask(data = dataset, target = "y_dx")

repCV = makeResampleDesc(method = "RepCV", folds = 5 ,stratify = TRUE)
valCV = resample(
    learners = learners, 
    task = data_task, 
    resampling = repCV, 
    measures = list(mmce, acc, auc))

when running the variable valCV, it generates the following error

Error in checkLearner(learner) : argument "learner" is missing, with no default

The problem is that it doesn't recognize the learners argument, is there any other way to solve this?

1

There are 1 best solutions below

2
Lars Kotthoff On BEST ANSWER

resample() takes only a single learner -- did you mean to use benchmark()?

benchmark(
  learners = learners, 
  task = data_task, 
  resampling = repCV, 
  measures = list(mmce, acc, auc))

And as the comment points out, you should switch to mlr3. See the book chapter on evaluation and benchmark experiments.