繁体   English   中英

H2O预测ArrayIndexOutOfBoundsException

[英]H2O Prediction ArrayIndexOutOfBoundsException

因为我听说过很棒的东西,所以我只是在测试水。 到目前为止,我一直在使用以下代码:

 library(h2o)

h2o.removeAll() # Clean up. Just in case H2O was already running
h2o.init(nthreads = -1, max_mem_size="22G")  # Start an H2O cluster with all threads available

train <- read.csv("TRAIN")
test <- read.csv("TEST")

target <- as.factor(train$target)

feature_names <- names(train)[1:(ncol(train)-1)]

train_h2o <- as.h2o(train)
test_h2o <- as.h2o(test)

prob <- test[, "id", drop = FALSE]

model_glm <- h2o.glm(x = feature_names,  y = "target", training_frame = train_h2o)
h2o.performance(model_glm) 

pred_glm <- predict(model_glm, newdata = test_h2o)

相关的部分实际上是最后一行,出现以下错误:

DistributedException from localhost/127.0.0.1:54321, caused by java.lang.ArrayIndexOutOfBoundsException

DistributedException from localhost/127.0.0.1:54321, caused by java.lang.ArrayIndexOutOfBoundsException
    at water.MRTask.getResult(MRTask.java:478)
    at water.MRTask.getResult(MRTask.java:486)
    at water.MRTask.doAll(MRTask.java:390)
    at water.MRTask.doAll(MRTask.java:396)
    at hex.glm.GLMModel.predictScoreImpl(GLMModel.java:1198)
    at hex.Model.score(Model.java:1030)
    at water.api.ModelMetricsHandler$1.compute2(ModelMetricsHandler.java:345)
    at water.H2O$H2OCountedCompleter.compute(H2O.java:1241)
    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)
Caused by: java.lang.ArrayIndexOutOfBoundsException

有人遇到过吗? 有什么简单的解决方案可能会让我错过吗? 提前致谢。

如评论中所述,“训练”和“测试”数据集中的列名需要完全匹配,否则您将收到错误消息。 很高兴您能够找到问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM