Skip to content

Commit

Permalink
fixed merging error.
Browse files Browse the repository at this point in the history
  • Loading branch information
wendycwong committed Oct 24, 2024
2 parents 085347c + ef3bae3 commit 6f84597
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 5 deletions.
10 changes: 5 additions & 5 deletions h2o-algos/src/main/java/hex/schemas/HGLMModelV3.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ public static final class HGLMModelOutputV3 extends ModelOutputSchemaV3<HGLMMode

@API(help="Covariance Matrix for Random Effects (= Tj in section II.I of the doc")
public double[][] tmat;

@API(help="ratio of each random effect variance and (sum of all random effect variances plus the residual noise" +
@API(help="Ratio of each random effect variance and (sum of all random effect variances plus the residual noise" +
" variance).")
double[] icc;

@API(help="residual noise variance")
@API(help="Residual noise variance")
double residual_variance;

@API(help="mean residual error with fixed effect coefficients only")
@API(help="Mean residual error with fixed effect coefficients only")
double mean_residual_fixed;

@API(help="mean residual error with fixed effect coefficients only")
@API(help="Mean residual error with fixed effect coefficients only")
double mean_residual_fixed_valid;

@Override
Expand Down
99 changes: 99 additions & 0 deletions h2o-algos/src/test/java/hex/hglm/HGLMBasicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ public void testLevel2enum1() {
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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -415,37 +471,65 @@ 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;

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
formMatrix(arjTArj, unit2Level, randomRowValues, randomRowValues); // calculate arjTArj
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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -683,6 +771,7 @@ public static Frame makeUBetaFrame(double[][] initUBeta) {

@Test
public void testRandomInterceptOnly() {
<<<<<<< HEAD
Scope.enter();
try {
HGLMModel.HGLMParameters params = new HGLMModel.HGLMParameters();
Expand All @@ -701,6 +790,9 @@ public void testRandomInterceptOnly() {
} finally {
Scope.exit();
}
=======
;
>>>>>>> ef3bae3d71df761ab365c4a13f439adfc7987f1e
}

@Test
Expand All @@ -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();
}
Expand Down

0 comments on commit 6f84597

Please sign in to comment.