我正在尝试使用该mlr
软件包运行模型,但该功能存在一些问题predict()
。它给了我以下错误消息:
Error in predict(mod, task = task, subset = test) :
Assertion on 'subset' failed: Must be of type 'integerish', not 'data.frame'
请在下面找到一个可重现的示例:
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)
然后出现错误。难道我做错了什么?谢谢!