我尝试使用以下代码训练 h2o 模型并对新数据进行预测,但这会导致错误。我怎样才能避免这个错误?
library(mlr)
a <- data.frame(y=factor(c(1,1,1,1,1,1,1,1,0,0,1,0)),
x1=rep(c("a","b","c"), times=c(6,3,3)))
aTask <- makeClassifTask(data = a, target = "y", positive = "1")
h2oLearner <- makeLearner("classif.h2o.deeplearning",
predict.type = "prob")
model <- train(h2oLearner, aTask)
b <- data.frame(x1=rep(c("a","b", "c"), times=c(3,5,4)))
pred <- predict(model, newdata=b)
导致以下错误:
checkPredictLearnerOutput(.learner, .model, p) 出错:
classif.h2o.deeplearning 的 predictLearner 未将类级别作为列名返回:p0,p1
如果我将 predict.type 更改为“response”,它会起作用。那么如何预测概率呢?