Beispiel #1
0
 protected void nextLambda(final GLMIterationTask glmt, GLMValidation val) {
   currentLambdaIter = 0;
   boolean improved = _model.setAndTestValidation(_lambdaIdx, val);
   _model.clone().update(self());
   boolean done = false; // _iter < max_iter && (improved || _runAllLambdas) && _lambdaIdx <
   // (lambda.length-1);
   if (_iter == max_iter) {
     Log.info("GLM2 reached max #iterations.");
     done = true;
   } else if (!improved && !_runAllLambdas) {
     Log.info("GLM2 converged as solution stopped improving with decreasing lambda.");
     done = true;
   } else if (_lambdaIdx == lambda.length - 1) {
     Log.info("GLM2 done with all given lambdas.");
     done = true;
   } else if (_activeCols != null && _activeCols.length + 1 >= MAX_PREDICTORS) {
     Log.info(
         "GLM2 reached maximum allowed number of predictors at lambda = " + lambda[_lambdaIdx]);
     done = true;
   }
   if (!done) { // continue with next lambda value?
     ++_lambdaIdx;
     glmt._val = null;
     if (glmt._gram == null) { // assume we had lambda search with strong rules
       // we use strong rules so we can't really used this gram for the next lambda computation
       // (different sets of coefficients)
       // I expect that:
       //  1) beta has been expanded to match current set of active cols
       //  2) it is new GLMIteration ready to be launched
       // caller (nextLambda(glmt,beta)) is expected to ensure this...
       assert _activeCols == null || (glmt._beta.length == _activeCols.length + 1);
       assert !glmt.isDone();
       glmt.asyncExec(_activeData._adaptedFrame);
     } else // we have the right gram, just solve with with next lambda
     new Iteration().callback(glmt);
   } else // nope, we're done
   GLM2.this.complete(); // signal we're done to anyone waiting for the job
 }