在h2o.predict函数中调用测试文件时出错

时间:2019-03-16 06:40:23

标签: r data-science h2o

prediction_h2o <-h2o.predict(automl_leader,正在测试) 执行此语法时,出现一些奇怪的错误。

prediction_h2o <- h2o.predict(automl_leader, testing)

java.lang.IllegalArgumentException: Actual column must be integer class labels!

    java.lang.IllegalArgumentException: Actual column must be integer class labels!
        at hex.GainsLift.init(GainsLift.java:51)
        at hex.GainsLift.exec(GainsLift.java:124)
        at hex.glm.GLMMetricBuilder.makeModelMetrics(GLMMetricBuilder.java:217)
        at hex.glm.GLMModel.predictScoreImpl(GLMModel.java:1456)
        at hex.Model.score(Model.java:1381)
        at hex.ensemble.StackedEnsembleModel.predictScoreImpl(StackedEnsembleModel.java:150)
        at hex.Model.score(Model.java:1381)
        at water.api.ModelMetricsHandler$1.compute2(ModelMetricsHandler.java:374)
        at water.H2O$H2OCountedCompleter.compute(H2O.java:1386)
        at jsr166y.CountedCompleter.exec(CountedCompleter.java:468)
        at jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:263)
        at jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:974)
        at jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1477)
        at jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)
    Error: java.lang.IllegalArgumentException: Actual column must be integer class labels!

2 个答案:

答案 0 :(得分:0)

我的建议是检查要传递给predict函数的两个对象的类型,并验证包含标签的目标列是否为您想要的类型。该错误消息表明预测函数正在使用整数类型的标签列,但还有其他内容。

此外,我将看一下documentation中的AutoML代码示例,并验证您在使用预测函数之前是否正在复制相同的步骤。

答案 1 :(得分:0)

问题与H2O版本有关。因此,请尝试降级(版本3.22.1.6):

# The following two commands remove any previously installed H2O packages for R.
if ("package:h2o" %in% search()) { detach("package:h2o", unload=TRUE) }
if ("h2o" %in% rownames(installed.packages())) { remove.packages("h2o") }

# Next, we download packages that H2O depends on.
pkgs <- c("RCurl","jsonlite")
for (pkg in pkgs) {
if (! (pkg %in% rownames(installed.packages()))) { install.packages(pkg) }
}

# Now we download, install and initialize the H2O package for R.
install.packages("h2o", type="source", repos="http://h2o-release.s3.amazonaws.com/h2o/rel-xu/6/R")

# Finally, let's load H2O and start up an H2O cluster
library(h2o)
h2o.init()

编辑:https://github.com/h2oai/h2o-tutorials/issues/107