@Override protected Response serve() { init(); link = family.defaultLink; // TODO tweedie_link_power = 1 - tweedie_variance_power; // TODO Frame fr = DataInfo.prepareFrame(source, response, ignored_cols, family == Family.binomial, true); _dinfo = new DataInfo(fr, 1, standardize); _glm = new GLMParams(family, tweedie_variance_power, link, tweedie_link_power); if (alpha.length > 1) { // grid search if (destination_key == null) destination_key = Key.make("GLMGridModel_" + Key.make()); if (job_key == null) job_key = Key.make("GLMGridJob_" + Key.make()); Job j = gridSearch(self(), destination_key, _dinfo, _glm, lambda, alpha, n_folds); return GLMGridView.redirect(this, j.dest()); } else { if (destination_key == null) destination_key = Key.make("GLMModel_" + Key.make()); if (job_key == null) job_key = Key.make("GLM2Job_" + Key.make()); fork(); return GLMProgress.redirect(this, job_key, dest()); } }
@Override public void init() { super.init(); if (lambda_search && lambda.length > 1) throw new IllegalArgumentException( "Can not supply both lambda_search and multiple lambdas. If lambda_search is on, GLM expects only one value of lambda, representing the lambda min (smallest lambda in the lambda search)."); // check the response if (response.isEnum() && family != Family.binomial) throw new IllegalArgumentException( "Invalid response variable, trying to run regression with categorical response!"); switch (family) { case poisson: case tweedie: if (response.min() < 0) throw new IllegalArgumentException( "Illegal response column for family='" + family + "', response must be >= 0."); break; case gamma: if (response.min() <= 0) throw new IllegalArgumentException( "Invalid response for family='Gamma', response must be > 0!"); break; case binomial: if (response.min() < 0 || response.max() > 1) throw new IllegalArgumentException( "Illegal response column for family='Binomial', response must in <0,1> range!"); break; default: // pass } Frame fr = DataInfo.prepareFrame( source, response, ignored_cols, family == Family.binomial, true, true); _dinfo = new DataInfo(fr, 1, use_all_factor_levels || lambda_search, standardize, false); if (higher_accuracy) setHighAccuracy(); }