Example #1
0
 @Override
 public void map(GLMModel m) {
   _res = (GLMModel) m.clone();
   _res._output = (GLMOutput) _res._output.clone();
   Submodel sm =
       Double.isNaN(_lambda)
           ? _res._output._submodels[_res._output._best_lambda_idx]
           : _res._output.submodelForLambda(_lambda);
   assert sm != null : "GLM[" + m._key + "]: missing submodel for lambda " + _lambda;
   sm = (Submodel) sm.clone();
   _res._output._submodels = new Submodel[] {sm};
   _res._output.setSubmodelIdx(0);
 }
Example #2
0
 public static void setSubmodel(
     H2O.H2OCountedCompleter cmp,
     Key modelKey,
     final double lambda,
     double[] beta,
     double[] norm_beta,
     final int iteration,
     long runtime,
     boolean sparseCoef,
     final GLMValidation val) {
   final Submodel sm = new Submodel(lambda, beta, norm_beta, runtime, iteration, sparseCoef);
   sm.validation = val;
   cmp.addToPendingCount(1);
   new TAtomic<GLMModel>(cmp) {
     @Override
     public GLMModel atomic(GLMModel old) {
       if (old == null) return old; // job could've been cancelled!
       if (old._output._submodels == null) {
         old._output._submodels = new Submodel[] {sm};
       } else {
         int id = old._output.submodelIdForLambda(lambda);
         if (id < 0) {
           id = -id - 1;
           old._output._submodels =
               Arrays.copyOf(old._output._submodels, old._output._submodels.length + 1);
           for (int i = old._output._submodels.length - 1; i > id; --i)
             old._output._submodels[i] = old._output._submodels[i - 1];
         } else if (old._output._submodels[id].iteration > sm.iteration) return old;
         else old._output._submodels = old._output._submodels.clone();
         old._output._submodels[id] = sm;
         old._run_time = Math.max(old._run_time, sm.run_time);
       }
       old._output.pickBestModel(false);
       return old;
     }
   }.fork(modelKey);
 }