water.Job类的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(177)

本文整理了Java中water.Job类的一些代码示例,展示了Job类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Job类的具体详情如下:
包路径:water.Job
类名称:Job

Job介绍

暂无

代码示例

代码示例来源:origin: h2oai/h2o-3

private void pollAndUpdateProgress(Stage stage, String name, WorkAllocations.Work work, Job parentJob, Job subJob, boolean ignoreTimeout) {
 if (null == subJob) {
  if (null != parentJob) {
   parentJob.update(work.consume(), "SKIPPED: " + name);
   Log.info("AutoML skipping " + name);
 while (subJob.isRunning()) {
  if (null != parentJob) {
   if (parentJob.stop_requested()) {
    userFeedback.info(Stage.ModelTraining, "AutoML job cancelled; skipping " + name);
    subJob.stop();
    subJob.stop();
  long workedSoFar = Math.round(subJob.progress() * work.share);
   parentJob.update(Math.round(workedSoFar - lastWorkedSoFar), name);
  if (subJob.isCrashed()) {
   userFeedback.info(stage, name + " failed: " + subJob.ex().toString());
  } else if (subJob.get() == null) {
   userFeedback.info(stage, name + " cancelled");
  } else {
   Grid grid = (Grid) subJob.get();
   int gridCount = grid.getModelCount();
   if (gridCount > gridLastCount) {
  if (subJob.isCrashed()) {
   userFeedback.info(stage, name + " failed: " + subJob.ex().toString());
  } else if (subJob.get() == null) {

代码示例来源:origin: h2oai/h2o-3

public H2OJob(H2ORunnable runnable, Key key, long max_runtime_msecs) {
 _target = runnable;
 _job = new Job<>(key, _target.getClass().getName(), _target.getClass().getSimpleName() + " build");
 _jobKey = _job._key;
 _job._max_runtime_msecs = max_runtime_msecs;
}

代码示例来源:origin: h2oai/h2o-2

@Override public void invoke() {
 init();
 start(new H2OEmptyCompleter());  // mark job started
 exec(); // execute the implementation
 remove();     // remove the job
}

代码示例来源:origin: h2oai/h2o-3

@Override
public void stop() {
 for (Frame f : tempFrames) f.delete();
 tempFrames = null;
 if (null == jobs) return; // already stopped
 for (Job j : jobs) j.stop();
 for (Job j : jobs) j.get(); // Hold until they all completely stop.
 jobs = null;
 // TODO: add a failsafe, if we haven't marked off as much work as we originally intended?
 // If we don't, we end up with an exceptional completion.
}

代码示例来源:origin: h2oai/h2o-2

@Override protected Response serve() {
 Job jjob = null;
 if( job_key != null )
  jjob = Job.findJob(job_key);
 if( jjob != null && jjob.isCancelledOrCrashed()) // Handle cancelled job
  return Response.error(jjob.isCrashed() ? jjob.exception : "Job was cancelled by user!" );
 if( jjob == null || jjob.isDone() ) // Handle done job
  return jobDone(destination_key);
 return jobInProgress(jjob, destination_key);
}

代码示例来源:origin: h2oai/h2o-3

/**
 * Compute quantile-based threshold (in reconstruction error) to find outliers
 * @param mse Vector containing reconstruction errors
 * @param quantile Quantile for cut-off
 * @return Threshold in MSE value for a point to be above the quantile
 */
public double calcOutlierThreshold(Vec mse, double quantile) {
 Frame mse_frame = new Frame(Key.<Frame>make(), new String[]{"Reconstruction.MSE"}, new Vec[]{mse});
 DKV.put(mse_frame._key, mse_frame);
 QuantileModel.QuantileParameters parms = new QuantileModel.QuantileParameters();
 parms._train = mse_frame._key;
 parms._probs = new double[]{quantile};
 Job<QuantileModel> job = new Quantile(parms).trainModel();
 QuantileModel kmm = job.get();
 job.remove();
 double q = kmm._output._quantiles[0][0];
 kmm.delete();
 DKV.remove(mse_frame._key);
 return q;
}

代码示例来源:origin: h2oai/h2o-3

@Override public void map( Chunk chks[] ) {
  if (isCancelled() || j != null && j.stop_requested()) return;
  double tmp [] = new double[_output._names.length];
  double preds[] = new double[len];
  for(int row = 0; row < chks[0]._len; row++) {
   Arrays.fill(preds,0);
   double p[] = score_indicator(chks, row, tmp, preds);
   for(int c = 0; c < preds.length; c++)
    chks[_output._names.length + c].set(row, p[c]);
  }
  if (j != null) j.update(1);
 }
}.doAll(adaptFrm);

代码示例来源:origin: h2oai/h2o-3

long sinceLastScore = now-_timeLastScoreStart;
boolean updated = false;
_job.update(0,"Built " + _model._output._ntrees + " trees so far (out of " + _parms._ntrees + ").");
 _job.update(0,"Scoring the model.");
 try {
  Scope.enter();
  _job.update(0, "Calibrating probabilities");
  Vec calibWeights = _parms._weights_column != null ? calib().vec(_parms._weights_column) : null;
  Frame calibPredict = Scope.track(_model.score(calib(), null, _job, false));
  Job calibJob = new Job<>(calibModelKey, ModelBuilder.javaName("glm"), "Platt Scaling (GLM)");
  GLM calibBuilder = ModelBuilder.make("GLM", calibJob, calibModelKey);
  calibBuilder._parms._intercept = true;
  _model._output._calib_model = calibBuilder.trainModel().get();
  _model.update(_job);
 } finally {

代码示例来源:origin: h2oai/h2o-3

/**
 * Holds until AutoML's job is completed, if a job exists.
 */
public void get() {
 if (job != null) job.get();
}

代码示例来源:origin: h2oai/h2o-3

private void progressUpdate(Key<Job> job_key, boolean keep_running) {
  updateTiming(job_key);
  Job job = job_key.get();
  double progress = job.progress();
//    Log.info("2nd speed: (samples: " + model_info().get_processed_total() + ", total_run_time: " + total_training_time_ms + ", total_scoring_time: " + total_scoring_time_ms + ", total_setup_time: " + total_setup_time_ms + ")");
  float speed = (float)(model_info().get_processed_total() * 1000. / (total_training_time_ms -total_scoring_time_ms-total_setup_time_ms));
  assert(speed >= 0) : "negative speed computed! (total_run_time: " + total_training_time_ms + ", total_scoring_time: " + total_scoring_time_ms + ", total_setup_time: " + total_setup_time_ms + ")";
  String msg =
      "Iterations: " + String.format("%,d", iterations)
      + ". Epochs: " + String.format("%g", epoch_counter)
      + ". Speed: " + (speed>10 ? String.format("%d", (int)speed) : String.format("%g", speed)) + " samples/sec."
      + (progress == 0 ? "" : " Estimated time left: " + PrettyPrint.msecs((long) (total_training_time_ms * (1. - progress) / progress), true));
  job.update(actual_train_samples_per_iteration,msg); //mark the amount of work done for the progress bar
  long now = System.currentTimeMillis();
  long sinceLastPrint = now -_timeLastPrintStart;
  if (!keep_running || sinceLastPrint > get_params()._score_interval * 1000) { //print this after every score_interval, not considering duty cycle
   _timeLastPrintStart = now;
   if (!get_params()._quiet_mode) {
    Log.info(
        "Training time: " + PrettyPrint.msecs(total_training_time_ms, true) + " (scoring: " + PrettyPrint.msecs(total_scoring_time_ms, true) + "). "
        + "Processed " + String.format("%,d", model_info().get_processed_total()) + " samples" + " (" + String.format("%.3f", epoch_counter) + " epochs).\n");
    Log.info(msg);
   }
  }
 }

代码示例来源:origin: h2oai/h2o-2

/**
 * Returns true if job is not running.
 * The job can be cancelled, crashed, or already done.
 *
 * @param jobkey job identification key
 * @return true if job is done, cancelled, or crashed, else false
 */
public static boolean isEnded(Key jobkey) { return !isRunning(jobkey); }

代码示例来源:origin: h2oai/h2o-3

final GLMModel model = glm.trainModelOnH2ONode().get();
Scope.track_generic(model);
assertNotNull(model);
final Job j = new Job<>(Key.make(), parms.javaName(), parms.algoName());
j.start(new H2O.H2OCountedCompleter() {
  @Override
  public void compute2() {
    tryComplete();
}, 1).get();

代码示例来源:origin: h2oai/h2o-3

dl = job.trainModel().get();
  Assert.fail("Should toss exception instead of reaching here");
 } catch( RuntimeException de ) {
 Assert.assertTrue(dl._output._job.isCrashed());
} finally {
 if (tfr != null) tfr.delete();

代码示例来源:origin: h2oai/h2o-3

@Override public void map( Chunk chk ) {
 _matches = new String[1]; // Result holders; will lazy expand
 _offsets = new long  [1];
 ByteSeq bs = new ByteSeq(chk,chk.nextChunk());
 // We already checked that this is an instance of a ByteVec, which means
 // all the Chunks contain raw text as byte arrays.
 Matcher m = _pattern.matcher(bs);
 while( m.find() && m.start() < bs._bs0.length )
  add(bs.str(m.start(),m.end()),chk.start()+m.start());
 _job.update(chk._len);         // Whole chunk of work, done all at once
}
@Override public void reduce( GrepGrep gg1 ) {

代码示例来源:origin: h2oai/h2o-2

@Override public float progress() {
 double d = 0.1;
 for( Job job : jobs )
  if(job.start_time > 0)
   d += job.progress();
 return Math.min(1f, (float) (d / jobs.length));
}

代码示例来源:origin: h2oai/h2o-3

m = job.trainModel().get();
Assert.assertTrue("Progress not 100%, but " + job._job.progress() *100, job._job.progress() == 1.0);

代码示例来源:origin: h2oai/h2o-3

model1 = dl.trainModel().get();
  checkSums.add(model1.checksum());
  testcount++;
  model1 = DKV.getGet(dl.dest());
  if (model1 != null)
   Assert.assertTrue(model1._output._job.isCrashed());
  throw t;
Assert.assertFalse(model1._output._job.isCrashed());
 DeepLearning dl = new DeepLearning(p2);
 try {
  model2 = dl.trainModel().get();
 } catch (Throwable t) {
  model2 = DKV.getGet(dl.dest());
  if (model2 != null)
   Assert.assertTrue(model2._output._job.isCrashed());
  throw t;
Assert.assertTrue(model1._output._job.isDone());
Assert.assertTrue(model2._output._job.isDone());

代码示例来源:origin: h2oai/h2o-3

void compute() {
 try {
  B builder = createBuilder();
  if (_hasMetalearnerParams) {
   builder._parms = _metalearner_parameters;
  }
  setCommonParams(builder._parms);
  setCrossValidationParams(builder._parms);
  setCustomParams(builder._parms);
  builder.init(false);
  Job<M> j = builder.trainModel();
  while (j.isRunning()) {
   try {
    _job.update(j._work, "training metalearner(" + _model._parms._metalearner_algorithm + ")");
    Thread.sleep(100);
   } catch (InterruptedException ignored) {
   }
  }
  Log.info("Finished training metalearner model(" + _model._parms._metalearner_algorithm + ").");
  _model._output._metalearner = builder.get();
  _model.doScoreOrCopyMetrics(_job);
  if (_parms._keep_levelone_frame) {
   _model._output._levelone_frame_id = _levelOneTrainingFrame; //Keep Level One Training Frame in Stacked Ensemble model object
  }
 } finally {
  cleanup();
  _model.update(_job);
  _model.unlock(_job);
 }
}

代码示例来源:origin: h2oai/h2o-2

JsonObject result = new JsonObject();
JsonArray array = new JsonArray();
Job[] jobs = Job.all();
for( int i = jobs.length - 1; i >= 0; i-- ) {
 JsonObject json = new JsonObject();
 json.addProperty(KEY, jobs[i].self().toString());
 json.addProperty(DESCRIPTION, jobs[i].description);
 json.addProperty(DEST_KEY, jobs[i].dest() != null ? jobs[i].dest().toString() : "");
 json.addProperty(START_TIME, RequestBuilders.ISO8601.get().format(new Date(jobs[i].start_time)));
 long end = jobs[i].end_time;
  jobResult.addProperty("val", "OK");
 json.addProperty(END_TIME, end == 0 ? "" : RequestBuilders.ISO8601.get().format(new Date(end)));
 json.addProperty(PROGRESS, job.state==JobState.RUNNING || job.state==JobState.DONE ? jobs[i].progress() : -1);
 json.addProperty(PROGRESS, end == 0 ? (cancelled ? -2 : jobs[i].progress()) : (cancelled ? -2 : -1));
 json.addProperty(CANCELLED, cancelled);
 json.add("result",jobResult);

代码示例来源:origin: h2oai/h2o-3

public boolean progress(double [] beta, double likelihood) {
 _state._iter++;
 _state.updateState(beta,likelihood);
 if(!_parms._lambda_search)
  updateProgress(true);
 boolean converged = _state.converged();
 if(converged) Log.info(LogMsg(_state.convergenceMsg));
 return !_job.stop_requested() && !converged && _state._iter < _parms._max_iterations ;
}

相关文章