用 mlr 预测错误:
Error predict with mlr:
我尝试使用以下代码训练 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)
导致以下错误:
Error in checkPredictLearnerOutput(.learner, .model, p) :
predictLearner for classif.h2o.deeplearning has returned not the class
levels as column names: p0,p1
如果我将 predict.type 更改为 "response",它就会起作用。那么如何预测概率呢?
此错误已在 this commit 中修复,将在下一个版本中修复。在那之前,您可以安装 Github 版本:
devtools::install_github("mlr-org/mlr")
我尝试使用以下代码训练 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)
导致以下错误:
Error in checkPredictLearnerOutput(.learner, .model, p) :
predictLearner for classif.h2o.deeplearning has returned not the class levels as column names: p0,p1
如果我将 predict.type 更改为 "response",它就会起作用。那么如何预测概率呢?
此错误已在 this commit 中修复,将在下一个版本中修复。在那之前,您可以安装 Github 版本:
devtools::install_github("mlr-org/mlr")