I'm trying to run a model with the mlr
package but I'm having some problems with the predict()
function. It gives me the following error message:
Error in predict(mod, task = task, subset = test) :
Assertion on 'subset' failed: Must be of type 'integerish', not 'data.frame'
Please find a reproducible example below:
require(mlr) # models
require(caTools) # sampling
require(Zelig) # data
data("voteincome")
voteincome$vote <- as.factor(voteincome$vote)
set.seed(0)
sample <- sample.split(voteincome, SplitRatio = .75)
train <- subset(voteincome, sample == TRUE)
test <- subset(voteincome, sample == FALSE)
train <- na.omit(train)
test <- na.omit(test)
task <- makeClassifTask(data = train, target = "vote")
lrnr <- makeLearner("classif.randomForest")
mod <- train(lrnr, task)
pred <- predict(mod, task = task, subset = test)
And then the error appears. Am I doing something wrong? Thanks!