3
votes

I am trying to predict test times in a Kaggle comp using the H2OGeneralizedLinearEstimator function. The model trains normally in line 3 and the metrics are all reasonable. However when I come to the predict step I get an error despite the test data frame matching the train data frame.

Has anyone seen this error before?

 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 Model Build progress: |███████████████████████████████████████████████| 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
This looks like the same error I posted here: stackoverflow.com/questions/44901421/… As a workaround, try adding a fake response column (e.g. add a constant column 'y' to test_data)Richard
This worked straight away - thank you! Hopefully this bug gets fixed in a later update. ThanksGeorge
Can you tell me which version of H2O this is so I can track that in the bug report? Thx.Erin LeDell
It is H2O version 3.12.0.1. I am also having a problem with xgboost in H2o 3.12.0.1 when I try to perform a grid search with a h2o xgboost estimator. Is this a known problem? ThanksGeorge

1 Answers

2
votes

To summarize the comments above, the current solution is to add a response column (with fake data if it doesn't exist) to the test_data frame. However, this is a bug that should be fixed. The JIRA is here.