diff --git a/h2o-algos/src/main/java/hex/schemas/HGLMModelV3.java b/h2o-algos/src/main/java/hex/schemas/HGLMModelV3.java index e503e12f1f31..469494742a3e 100644 --- a/h2o-algos/src/main/java/hex/schemas/HGLMModelV3.java +++ b/h2o-algos/src/main/java/hex/schemas/HGLMModelV3.java @@ -45,18 +45,18 @@ public static final class HGLMModelOutputV3 extends ModelOutputSchemaV3>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e new String[]{"enum2", "enum3", "enum4", "enum5", "enum6"}, new String[]{"num1", "num2", "num3"}, new String[]{"enum2", "enum4", "enum6"}, new String[]{"num1", "num3"}); } finally { @@ -138,7 +142,11 @@ public void testLevel2enum1NoIntercept() { params._random_intercept = true; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); +<<<<<<< HEAD checkWithManualResults1(model, params._response_column, _simpleFrame1, params._group_column, +======= + checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum1, params._group_column, +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e new String[]{"enum2", "enum3", "enum4", "enum5", "enum6"}, new String[]{"num1", "num2", "num3"}, new String[]{"enum2", "enum4", "enum6"}, new String[]{"num1", "num3"}); } finally { @@ -160,7 +168,11 @@ public void testLevel2enum1V2() { params._max_iterations = 0; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); +<<<<<<< HEAD checkWithManualResults1(model, params._response_column, _simpleFrame1, params._group_column, +======= + checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum1, params._group_column, +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e new String[]{"enum2", "enum3", "enum4", "enum5", "enum6"}, new String[]{"num1", "num2", "num3"}, new String[]{"enum2", "enum4", "enum6"}, new String[]{"num1", "num3"}); } finally { @@ -183,7 +195,11 @@ public void testLevel2enum2() { params._max_iterations = 0; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); +<<<<<<< HEAD checkWithManualResults1(model, params._response_column, _simpleFrame1, params._group_column, +======= + checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum2, params._group_column, +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e new String[]{"enum1", "enum3", "enum4", "enum5", "enum6"}, new String[]{"num1", "num2", "num3"}, new String[]{"enum1", "enum4", "enum6"}, new String[]{"num2", "num3"}); } finally { @@ -205,7 +221,11 @@ public void testLevel2enum2V2() { params._max_iterations = 0; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); +<<<<<<< HEAD checkWithManualResults1(model, params._response_column, _simpleFrame1, params._group_column, +======= + checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum2, params._group_column, +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e new String[]{"enum1", "enum3", "enum4", "enum5", "enum6"}, new String[]{"num1", "num2", "num3"}, new String[]{"enum1", "enum4", "enum6"}, new String[]{"num2", "num3"}); } finally { @@ -228,7 +248,11 @@ public void testLevel2enum2V2NoRandomIntercept() { params._random_intercept = false; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); +<<<<<<< HEAD checkWithManualResults1(model, params._response_column, _simpleFrame1, params._group_column, +======= + checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum2, params._group_column, +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e new String[]{"enum1", "enum3", "enum4", "enum5", "enum6"}, new String[]{"num1", "num2", "num3"}, new String[]{"enum1", "enum4", "enum6"}, new String[]{"num2", "num3"}); } finally { @@ -251,7 +275,11 @@ public void testLevel2enum3() { params._max_iterations = 0; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); +<<<<<<< HEAD checkWithManualResults1(model, params._response_column, _simpleFrame1, params._group_column, +======= + checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum3, params._group_column, +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e new String[]{"enum1", "enum2", "enum4", "enum5", "enum6"}, new String[]{"num1", "num2", "num3"}, new String[]{"enum1", "enum4"}, new String[]{"num1", "num2"}); } finally { @@ -273,7 +301,11 @@ public void testLevel2enum3V2() { params._max_iterations = 0; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); +<<<<<<< HEAD checkWithManualResults1(model, params._response_column, _simpleFrame1, params._group_column, +======= + checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum3, params._group_column, +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e new String[]{"enum1", "enum2", "enum4", "enum5", "enum6"}, new String[]{"num1", "num2", "num3"}, new String[]{"enum1", "enum4"}, new String[]{"num1", "num2"}); } finally { @@ -296,7 +328,11 @@ public void testLevel2enum4() { params._max_iterations = 0; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); +<<<<<<< HEAD checkWithManualResults1(model, params._response_column, _simpleFrame1, params._group_column, +======= + checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum4, params._group_column, +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e new String[]{"enum1", "enum2", "enum3", "enum5", "enum6"}, new String[]{"num1", "num2", "num3"}, new String[]{"enum1", "enum2", "enum3", "enum6"}, new String[]{"num1", "num2"}); } finally { @@ -318,7 +354,11 @@ public void testLevel2enum4V2() { params._max_iterations = 0; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); +<<<<<<< HEAD checkWithManualResults1(model, params._response_column, _simpleFrame1, params._group_column, +======= + checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum4, params._group_column, +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e new String[]{"enum1", "enum2", "enum3", "enum5", "enum6"}, new String[]{"num1", "num2", "num3"}, new String[]{"enum1", "enum2", "enum3", "enum6"}, new String[]{"num1", "num2"}); } finally { @@ -340,7 +380,11 @@ public void testLevel2enum5() { params._max_iterations = 0; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); +<<<<<<< HEAD checkWithManualResults1(model, params._response_column, _simpleFrame1, params._group_column, +======= + checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum5, params._group_column, +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e new String[]{"enum1", "enum2", "enum3", "enum4", "enum6"}, new String[]{"num1", "num2", "num3"}, new String[]{"enum1", "enum2", "enum3", "enum6"}, new String[]{"num1", "num3"}); } finally { @@ -362,7 +406,11 @@ public void testLevel2enum5V2() { params._max_iterations = 0; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); +<<<<<<< HEAD checkWithManualResults1(model, params._response_column, _simpleFrame1, params._group_column, +======= + checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum5, params._group_column, +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e new String[]{"enum1", "enum2", "enum3", "enum4", "enum6"}, new String[]{"num1", "num2", "num3"}, new String[]{"enum1", "enum2", "enum3", "enum6"}, new String[]{"num1", "num3"}); } finally { @@ -384,7 +432,11 @@ public void testLevel2enum6() { params._max_iterations = 0; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); +<<<<<<< HEAD checkWithManualResults1(model, params._response_column, _simpleFrame1, params._group_column, +======= + checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum6, params._group_column, +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e new String[]{"enum1", "enum2", "enum3", "enum4", "enum5"}, new String[]{"num1", "num2", "num3"}, new String[]{"enum1", "enum2", "enum3", "enum5"}, new String[]{"num1", "num3"}); } finally { @@ -406,7 +458,11 @@ public void testLevel2enum6V2() { params._showFixedMatVecs = true; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); +<<<<<<< HEAD checkWithManualResults1(model, params._response_column, _simpleFrame1, params._group_column, +======= + checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum6, params._group_column, +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e new String[]{"enum1", "enum2", "enum3", "enum4", "enum5"}, new String[]{"num1", "num2", "num3"}, new String[]{"enum1", "enum2", "enum3", "enum5"}, new String[]{"num1", "num3"}); } finally { @@ -415,22 +471,40 @@ public void testLevel2enum6V2() { } // todo: add check _yMinusXTimesZ and _yMinusfixPredSquare +<<<<<<< HEAD public void checkWithManualResults1(HGLMModel model, String response, Frame fr, String level2Name, String[] enumFixed, String[] numFixed, String[] enumRandom, String[] numRandom) { double[] fixedRowValues; double[] randomRowValues; +======= + public void checkWithManualResults1(HGLMModel model, String response, Frame fr, Frame frSorted, String level2Name, + String[] enumFixed, String[] numFixed, String[] enumRandom, String[] numRandom) { + double[] fixedRowValues; + double[] randomRowValues; + double[] randomRowValuesS; +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e int numLevel2Vals = fr.vec(level2Name).domain().length; double[][][] afjTAfj = new double[numLevel2Vals][][]; double[][][] arjTArj = new double[numLevel2Vals][][]; double[][][] afjTArj = new double[numLevel2Vals][][]; double[][] afjTYj = new double[numLevel2Vals][]; double[][] arjTYj = new double[numLevel2Vals][]; +<<<<<<< HEAD +======= + //double[][] zTTimesZ = new double[model._output._zttimesz.length][model._output._zttimesz.length]; + double[][] tempZTTZ = new double[model._output._arjtarj[0].length][model._output._arjtarj[0].length]; +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e double yMinusfixPredSquare = 0; double[][] yMinusXTimesZ = new double[numLevel2Vals][model._output._yMinusXTimesZ[0].length]; double[] beta = model._output._beta; int numRow = (int) fr.numRows(); +<<<<<<< HEAD double responseVal; +======= + double responseVal; + int unit2LevelS; +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e int unit2Level; double fixEffect; double respMinusFix; @@ -438,7 +512,13 @@ public void checkWithManualResults1(HGLMModel model, String response, Frame fr, for (int rowInd = 0; rowInd < numRow; rowInd++) { fixedRowValues = grabRow2Arrays(enumFixed, numFixed, true, rowInd, fr, model._parms._use_all_factor_levels); randomRowValues = grabRow2Arrays(enumRandom, numRandom, model._parms._random_intercept, rowInd, fr, model._parms._use_all_factor_levels); +<<<<<<< HEAD + responseVal = fr.vec(response).at(rowInd); +======= + randomRowValuesS = grabRow2Arrays(enumRandom, numRandom, model._parms._random_intercept, rowInd, frSorted, model._parms._use_all_factor_levels); responseVal = fr.vec(response).at(rowInd); + unit2LevelS = (int) frSorted.vec(level2Name).at(rowInd); +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e unit2Level = (int) fr.vec(level2Name).at(rowInd); // calculate the various matrices and vectors formMatrix(afjTAfj, unit2Level, fixedRowValues, fixedRowValues); // calculate afjTAfj @@ -446,6 +526,10 @@ public void checkWithManualResults1(HGLMModel model, String response, Frame fr, formMatrix(afjTArj, unit2Level, fixedRowValues, randomRowValues); // calculate afjTArj formVector(afjTYj, unit2Level, fixedRowValues, responseVal); // calculate afjTYj formVector(arjTYj, unit2Level, randomRowValues, responseVal); // calculate arjTYj +<<<<<<< HEAD +======= + // formZTTimesZ(zTTimesZ, unit2LevelS, randomRowValuesS, tempZTTZ); +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e fixEffect = innerProduct(fixedRowValues, beta); respMinusFix = responseVal - fixEffect; yMinusfixPredSquare += respMinusFix*respMinusFix; @@ -458,6 +542,10 @@ public void checkWithManualResults1(HGLMModel model, String response, Frame fr, check3DArrays(model._output._afjtafj, afjTAfj, TOL); check3DArrays(model._output._afjtarj, afjTArj, TOL); check3DArrays(model._output._arjtarj, arjTArj, TOL); +<<<<<<< HEAD +======= + // checkDoubleArrays(model._output._zttimesz, zTTimesZ, TOL); +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e checkDoubleArrays(model._output._yMinusXTimesZ, yMinusXTimesZ, TOL); assertEquals(model._output._yMinusFixPredSquare, yMinusfixPredSquare, TOL); } @@ -683,6 +771,7 @@ public static Frame makeUBetaFrame(double[][] initUBeta) { @Test public void testRandomInterceptOnly() { +<<<<<<< HEAD Scope.enter(); try { HGLMModel.HGLMParameters params = new HGLMModel.HGLMParameters(); @@ -701,6 +790,9 @@ public void testRandomInterceptOnly() { } finally { Scope.exit(); } +======= + ; +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e } @Test @@ -725,6 +817,13 @@ public void testSemiconductor() { // just make sure it runs HGLMModel model = new HGLM(parms).trainModel().get(); Scope.track_generic(model); +<<<<<<< HEAD +======= + ; + // ModelMetricsHGLMGaussianGaussian mmetrics = (ModelMetricsHGLMGaussianGaussian) model._output._training_metrics; + // Scope.track_generic(mmetrics); + // assertEquals(363.6833, mmetrics._hlik, 1e-4); +>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e } finally { Scope.exit(); }