Example #1
0
  private void xvalidate(final GLMModel model, int lambdaIxd, final H2OCountedCompleter cmp) {
    final Key[] keys = new Key[n_folds];
    H2OCallback callback =
        new H2OCallback() {
          @Override
          public void callback(H2OCountedCompleter t) {
            try {
              GLMModel[] models = new GLMModel[keys.length];
              // we got the xval models, now compute their validations...
              for (int i = 0; i < models.length; ++i) models[i] = DKV.get(keys[i]).get();
              new GLMXValidationTask(model, _lambdaIdx, models, cmp)
                  .asyncExec(_dinfo._adaptedFrame);
            } catch (Throwable ex) {
              cmp.completeExceptionally(ex);
            }
          }

          @Override
          public boolean onExceptionalCompletion(Throwable ex, CountedCompleter caller) {
            cmp.completeExceptionally(ex);
            return true;
          }
        };
    callback.addToPendingCount(n_folds - 1);
    double proximal_penalty = 0;
    for (int i = 0; i < n_folds; ++i)
      new GLM2(
              this.description + "xval " + i,
              self(),
              keys[i] = Key.make(destination_key + "_" + _lambdaIdx + "_xval" + i),
              _dinfo.getFold(i, n_folds),
              _glm,
              new double[] {lambda[_lambdaIdx]},
              model.alpha,
              0,
              model.beta_eps,
              self(),
              model.norm_beta(lambdaIxd),
              proximal_penalty)
          .run(callback);
  }
Example #2
0
 private void xvalidate(final GLMModel model, int lambdaIxd, final H2OCountedCompleter cmp) {
   final Key[] keys = new Key[n_folds];
   GLM2[] glms = new GLM2[n_folds];
   for (int i = 0; i < n_folds; ++i)
     glms[i] =
         new GLM2(
             this.description + "xval " + i,
             self(),
             keys[i] = Key.make(destination_key + "_" + _lambdaIdx + "_xval" + i),
             _dinfo.getFold(i, n_folds),
             _glm,
             new double[] {lambda[_lambdaIdx]},
             model.alpha,
             0,
             model.beta_eps,
             self(),
             model.norm_beta(lambdaIxd),
             higher_accuracy,
             prior,
             0);
   H2O.submitTask(
       new ParallelGLMs(
           GLM2.this,
           glms,
           H2O.CLOUD.size(),
           new H2OCallback(GLM2.this) {
             @Override
             public void callback(H2OCountedCompleter t) {
               GLMModel[] models = new GLMModel[keys.length];
               // we got the xval models, now compute their validations...
               for (int i = 0; i < models.length; ++i) models[i] = DKV.get(keys[i]).get();
               new GLMXValidationTask(model, _lambdaIdx, models, cmp)
                   .asyncExec(_dinfo._adaptedFrame);
             }
           }));
 }