H2O预测ArrayIndexOutOfBoundsException

时间:2017-05-09 19:04:43

标签: r h2o

我只是测试了h2o,因为我听说过很棒的事情。到目前为止,我一直在使用以下代码:

 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

有没有人遇到过这个?有什么简单的解决方案可能会让我失踪吗?提前谢谢。

1 个答案:

答案 0 :(得分:0)

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