2017-07-07 86 views
3

我正在尝试使用H2OGeneralizedLinearEstimator函数来预测Kaggle comp中的测试时间。该模型通常在第3行进行训练,并且度量都是合理的。但是,当我进入预测步骤时,尽管测试数据帧与列车数据帧相匹配,但仍然出现错误。H2OGeneralizedLinearEstimator() - 预测错误

有没有人看过这个错误?

h2o_glm = H2OGeneralizedLinearEstimator() 

h2o_glm.train(training_frame=train_h2o,y='y') 

h2o_glm_predictions = h2o_glm.predict(test_data=test_h2o).as_data_frame() 

test_pred = pd.read_csv('test.csv')[['ID']] 
test_pred['y'] = h2o_glm_predictions 
test_pred.to_csv('h2o_glm_predictions.csv',index=False) 

GLM模型构建过程:|█████████████████████████████████████ ██████████| 100%

glm prediction progress: | (failed) 

OSError Traceback (most recent call last) in() 3 h2o_glm.train(training_frame=train_h2o,y='y') 4 ----> 5 h2o_glm_predictions = h2o_glm.predict(test_data=test_h2o).as_data_frame() 6 7 test_pred = pd.read_csv('test.csv')[['ID']] 

/Applications/anaconda/lib/python3.6/site-packages/h2o/model/model_base.py in predict(self, test_data) 130 j = H2OJob(h2o.api("POST /4/Predictions/models/%s/frames/%s" % (self.model_id, test_data.frame_id)), 131 self._model_json["algo"] + " prediction") --> 132 j.poll() 133 return h2o.get_frame(j.dest_key) 134 

/Applications/anaconda/lib/python3.6/site-packages/h2o/job.py in poll(self) 71 if (isinstance(self.job, dict)) and ("stacktrace" in list(self.job)): 72 raise EnvironmentError("Job with key {} failed with an exception: {}\nstacktrace: " ---> 73 "\n{}".format(self.job_key, self.exception, self.job["stacktrace"])) 74 else: 75 raise EnvironmentError("Job with key %s failed with an exception: %s" % (self.job_key, self.exception)) 

OSError: Job with key $03017f00000132d4ffffffff$_868312f4c32f683871930a1145c1476a failed with an exception: DistributedException from /127.0.0.1:54321: 'null', caused by java.lang.ArrayIndexOutOfBoundsException stacktrace: DistributedException from /127.0.0.1:54321: 'null', 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:1215) at hex.Model.score(Model.java:1077) at water.api.ModelMetricsHandler$1.compute2(ModelMetricsHandler.java:351) at water.H2O$H2OCountedCompleter.compute(H2O.java:1349) 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

这看起来像我在这里发布的同样的错误:https://stackoverflow.com/questions/44901421/h2o-predictions-sometimes-fail-when-response-variable-not-present-in-test-set作为一个解决方法,尝试添加一个假响应列(例如添加一个恒定的列'y'test_data) – Richard

+0

这个工作马上 - 谢谢!希望这个错误在稍后的更新中得到解决。谢谢 – George

+0

你能告诉我这是什么版本的H2O,所以我可以在错误报告中跟踪它吗?谢谢。 –

回答

2

为了总结上述评论,当前的解决方案是增加一个响应柱(用假的数据,如果它不存在),以该帧test_data。但是,这是一个应该修复的错误。 JIRA是here

+1

我可以证实这个bug也存在于R中(h2o 3.10.3.3和3.12.0.1),并且它似乎不是GLM特有的,而是与显式的一个热门编码有关 - 请参阅我链接到的问题在评论中。 – Richard