java.lang.ArrayIndexOutOfBoundsException: 2

JIRA | Johannes | 6 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    The following assignment of my variable rnd_data... {code} rnd_data = [[1], [2], [3], [1], [4], [2], [1], [4], [5], [10], [3]] rnd_f = h2o.H2OFrame.from_python(rnd_data, destination_frame = "rnd") rnd_f075, rnd_f025 = rnd_f.split_frame(ratios = [0.75], destination_frames = ["rnd075", "rnd025"]) kmeans6 = h2o.estimators.kmeans.H2OKMeansEstimator(model_id = "rnd_kmeans_6", training_frame = rnd_f075.frame_id, validation_frame = rnd_f025.frame_id, nfolds = 2, fold_assignment = "Random", score_each_iteration = True, k = 6) kmeans6.train(training_frame = rnd_f075, validation_frame = rnd_f025) {code} results in an ArrayIndexOutOfBoundsException: {code:none} kmeans Model Build progress: | (failed) --------------------------------------------------------------------------- OSError Traceback (most recent call last) <ipython-input-27-4067a2add74e> in <module>() ----> 1 kmeans6.train(training_frame = rnd_f075, validation_frame = rnd_f025) /opt/conda/lib/python3.5/site-packages/h2o/estimators/estimator_base.py in train(self, x, y, training_frame, offset_column, fold_column, weights_column, validation_frame, max_runtime_secs, **params) 161 parms["weights_column"] = weights_column 162 parms["max_runtime_secs"] = max_runtime_secs --> 163 self.build_model(parms) 164 165 def build_model(self, algo_params): /opt/conda/lib/python3.5/site-packages/h2o/estimators/estimator_base.py in build_model(self, algo_params) 174 if is_auto_encoder and y is not None: raise ValueError("y should not be specified for autoencoder.") 175 if not is_unsupervised and y is None: raise ValueError("Missing response") --> 176 self._model_build(x, y, training_frame, validation_frame, algo_params) 177 178 def _model_build(self, x, y, tframe, vframe, kwargs): /opt/conda/lib/python3.5/site-packages/h2o/estimators/estimator_base.py in _model_build(self, x, y, tframe, vframe, kwargs) 201 return 202 --> 203 model.poll() 204 model_json = h2o.api("GET /%d/Models/%s" % (rest_ver, model.dest_key))["models"][0] 205 self._resolve_model(model.dest_key, model_json) /opt/conda/lib/python3.5/site-packages/h2o/job.py in poll(self) 75 if (isinstance(self.job, dict)) and ("stacktrace" in list(self.job)): 76 raise EnvironmentError("Job with key {} failed with an exception: {}\nstacktrace: " ---> 77 "\n{}".format(self.job_key, self.exception, self.job["stacktrace"])) 78 else: 79 raise EnvironmentError("Job with key %s failed with an exception: %s" % (self.job_key, self.exception)) OSError: Job with key $0301ac11000332d4ffffffff$_a3c95020f0efb0e769cf63bf75024abf failed with an exception: java.lang.ArrayIndexOutOfBoundsException: 2 stacktrace: java.lang.ArrayIndexOutOfBoundsException: 2 at hex.kmeans.KMeans$KMeansDriver.createScoringHistoryTable(KMeans.java:364) at hex.kmeans.KMeans$KMeansDriver.computeStatsFillModel(KMeans.java:208) at hex.kmeans.KMeans$KMeansDriver.computeImpl(KMeans.java:281) at hex.ModelBuilder$Driver.compute2(ModelBuilder.java:169) at water.H2O$H2OCountedCompleter.compute(H2O.java:1198) 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) {code} Same error, if I cast the python list into a numpy array, i.e.: {code:python} rnd_data = np.array(rnd_data) {code} If I do this... {code:python} rnd_data = np.random.rand(30) {code} ...then the error is: {code:none} --------------------------------------------------------------------------- H2OResponseError Traceback (most recent call last) <ipython-input-37-4067a2add74e> in <module>() ----> 1 kmeans6.train(training_frame = rnd_f075, validation_frame = rnd_f025) /opt/conda/lib/python3.5/site-packages/h2o/estimators/estimator_base.py in train(self, x, y, training_frame, offset_column, fold_column, weights_column, validation_frame, max_runtime_secs, **params) 161 parms["weights_column"] = weights_column 162 parms["max_runtime_secs"] = max_runtime_secs --> 163 self.build_model(parms) 164 165 def build_model(self, algo_params): /opt/conda/lib/python3.5/site-packages/h2o/estimators/estimator_base.py in build_model(self, algo_params) 174 if is_auto_encoder and y is not None: raise ValueError("y should not be specified for autoencoder.") 175 if not is_unsupervised and y is None: raise ValueError("Missing response") --> 176 self._model_build(x, y, training_frame, validation_frame, algo_params) 177 178 def _model_build(self, x, y, tframe, vframe, kwargs): /opt/conda/lib/python3.5/site-packages/h2o/estimators/estimator_base.py in _model_build(self, x, y, tframe, vframe, kwargs) 194 rest_ver = kwargs.pop("_rest_version") if "_rest_version" in kwargs else 3 195 --> 196 model = H2OJob(h2o.api("POST /%d/ModelBuilders/%s" % (rest_ver, self.algo), data=kwargs), 197 job_type=(self.algo + " Model Build")) 198 /opt/conda/lib/python3.5/site-packages/h2o/h2o.py in api(endpoint, data, json, filename, save_to) 76 # type checks are performed in H2OConnection class 77 _check_connection() ---> 78 return h2oconn.request(endpoint, data=data, json=json, filename=filename, save_to=save_to) 79 80 /opt/conda/lib/python3.5/site-packages/h2o/backend/connection.py in request(self, endpoint, data, json, filename, save_to) 249 auth=self._auth, verify=self._verify_ssl_cert, proxies=self._proxies) 250 self._log_end_transaction(start_time, resp) --> 251 return self._process_response(resp, save_to) 252 253 except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError) as e: /opt/conda/lib/python3.5/site-packages/h2o/backend/connection.py in _process_response(response, save_to) 574 # Client errors (400 = "Bad Request", 404 = "Not Found", 412 = "Precondition Failed") 575 if status_code in {400, 404, 412} and isinstance(data, (H2OErrorV3, H2OModelBuilderErrorV3)): --> 576 raise H2OResponseError(data) 577 578 # Server errors (notably 500 = "Server Error") H2OResponseError: <h2o.schemas.error.H2OModelBuilderErrorV3 object at 0x7fd12bdc46a0> {code} But if I do as follows, then kmeans is successful: {code:python} rnd_data = np.random.rand(30,1) {code} I however think, that any one of the above assignments to rnd_data should work.

    JIRA | 6 months ago | Johannes
    java.lang.ArrayIndexOutOfBoundsException: 2

    Root Cause Analysis

    1. java.lang.ArrayIndexOutOfBoundsException

      2

      at hex.kmeans.KMeans$KMeansDriver.createScoringHistoryTable()
    2. hex.kmeans
      KMeans$KMeansDriver.computeImpl
      1. hex.kmeans.KMeans$KMeansDriver.createScoringHistoryTable(KMeans.java:364)
      2. hex.kmeans.KMeans$KMeansDriver.computeStatsFillModel(KMeans.java:208)
      3. hex.kmeans.KMeans$KMeansDriver.computeImpl(KMeans.java:281)
      3 frames
    3. hex
      ModelBuilder$Driver.compute2
      1. hex.ModelBuilder$Driver.compute2(ModelBuilder.java:169)
      1 frame
    4. water
      H2O$H2OCountedCompleter.compute
      1. water.H2O$H2OCountedCompleter.compute(H2O.java:1198)
      1 frame
    5. jsr166y
      ForkJoinWorkerThread.run
      1. jsr166y.CountedCompleter.exec(CountedCompleter.java:468)
      2. jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:263)
      3. jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:974)
      4. jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1477)
      5. jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)
      5 frames