Search in sources :

Example 16 with Solver

use of hex.glm.GLMModel.GLMParameters.Solver in project h2o-3 by h2oai.

the class GLMBasicTestBinomial method testCornerCases.

// test various problematic inputs to make sure fron-tend (ignoring/moving cols) works.
@Test
public void testCornerCases() {
    //    new GLM2("GLM testing constant offset on a toy dataset.", Key.make(), modelKey, new GLM2.Source(fr, fr.vec("D"), false, false, fr.vec("E")), Family.gaussian).setRegularization(new double[]{0}, new double[]{0}).doInit().fork().get();
    //    just test it does not blow up and the model is sane
    //    model = DKV.get(modelKey).get();
    //    assertEquals(model.coefficients().get("E"), 1, 0); // should be exactly 1
    GLMParameters parms = new GLMParameters(Family.gaussian);
    parms._response_column = "D";
    parms._offset_column = "E";
    parms._train = _abcd._key;
    parms._intercept = false;
    parms._standardize = false;
    GLMModel m = null;
    for (Solver s : new Solver[] { Solver.IRLSM, Solver.COORDINATE_DESCENT }) {
        parms._solver = s;
        try {
            m = new GLM(parms).trainModel().get();
            GLMTest.testScoring(m, _abcd);
            System.out.println(m.coefficients());
        } finally {
            if (m != null)
                m.delete();
        }
    }
}
Also used : Solver(hex.glm.GLMModel.GLMParameters.Solver) GLMParameters(hex.glm.GLMModel.GLMParameters) ModelMetricsBinomialGLM(hex.ModelMetricsBinomialGLM) Test(org.junit.Test)

Example 17 with Solver

use of hex.glm.GLMModel.GLMParameters.Solver in project h2o-3 by h2oai.

the class GLMBasicTestMultinomial method testCovtypeMinActivePredictors.

@Test
public void testCovtypeMinActivePredictors() {
    GLMParameters params = new GLMParameters(Family.multinomial);
    GLMModel model = null;
    Frame preds = null;
    try {
        params._response_column = "C55";
        params._train = _covtype._key;
        params._valid = _covtype._key;
        params._lambda = new double[] { 4.881e-05 };
        params._alpha = new double[] { 1 };
        params._objective_epsilon = 1e-6;
        params._beta_epsilon = 1e-4;
        params._max_active_predictors = 50;
        params._max_iterations = 10;
        double[] alpha = new double[] { .99 };
        double expected_deviance = 33000;
        double[] lambda = new double[] { 2.544750e-05 };
        Solver s = Solver.COORDINATE_DESCENT;
        System.out.println("solver = " + s);
        params._solver = s;
        model = new GLM(params).trainModel().get();
        System.out.println(model._output._model_summary);
        System.out.println(model._output._training_metrics);
        System.out.println(model._output._validation_metrics);
        System.out.println("rank = " + model._output.rank() + ", max active preds = " + params._max_active_predictors);
        assertTrue(model._output.rank() < params._max_active_predictors + model._output.nclasses());
        assertTrue(model._output._training_metrics.equals(model._output._validation_metrics));
        assertTrue(((ModelMetricsMultinomialGLM) model._output._training_metrics)._resDev <= expected_deviance * 1.1);
        preds = model.score(_covtype);
        ModelMetricsMultinomialGLM mmTrain = (ModelMetricsMultinomialGLM) hex.ModelMetricsMultinomial.getFromDKV(model, _covtype);
        assertTrue(model._output._training_metrics.equals(mmTrain));
        model.delete();
        model = null;
        preds.delete();
        preds = null;
    } finally {
        if (model != null)
            model.delete();
        if (preds != null)
            preds.delete();
    }
}
Also used : Solver(hex.glm.GLMModel.GLMParameters.Solver) GLMParameters(hex.glm.GLMModel.GLMParameters) ModelMetricsMultinomialGLM(hex.ModelMetricsBinomialGLM.ModelMetricsMultinomialGLM) ModelMetricsMultinomialGLM(hex.ModelMetricsBinomialGLM.ModelMetricsMultinomialGLM) ModelMetricsBinomialGLM(hex.ModelMetricsBinomialGLM) Test(org.junit.Test)

Aggregations

Solver (hex.glm.GLMModel.GLMParameters.Solver)17 GLMParameters (hex.glm.GLMModel.GLMParameters)16 Test (org.junit.Test)15 ModelMetricsBinomialGLM (hex.ModelMetricsBinomialGLM)11 ModelMetricsRegressionGLM (hex.ModelMetricsRegressionGLM)4 H2OModelBuilderIllegalArgumentException (water.exceptions.H2OModelBuilderIllegalArgumentException)4 ModelMetricsMultinomialGLM (hex.ModelMetricsBinomialGLM.ModelMetricsMultinomialGLM)3 Frame (water.fvec.Frame)2 L1Solver (hex.optimization.ADMM.L1Solver)1 ProximalSolver (hex.optimization.ADMM.ProximalSolver)1