From d38bd9498f17d5f71072eba42a408a0e650fcd6b Mon Sep 17 00:00:00 2001 From: wendycwong Date: Sat, 19 Oct 2024 17:36:20 -0700 Subject: [PATCH] set standarzie = false by default and changes all the tests. --- h2o-algos/src/main/java/hex/hglm/HGLMModel.java | 2 +- h2o-algos/src/test/java/hex/hglm/HGLMBasicTest.java | 10 ++++++++++ h2o-py/h2o/estimators/hglm.py | 6 +++--- ...it_GH_8487_1p5_noise_var_scoring_history_summary.py | 2 +- .../hglm/pyunit_GH_8487_coefficients_check.py | 2 +- ...nit_GH_8487_p5_noise_var_scoring_history_summary.py | 2 +- h2o-r/h2o-package/R/hglm.R | 6 +++--- 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/h2o-algos/src/main/java/hex/hglm/HGLMModel.java b/h2o-algos/src/main/java/hex/hglm/HGLMModel.java index dbcc4c7653be..a827caec626a 100644 --- a/h2o-algos/src/main/java/hex/hglm/HGLMModel.java +++ b/h2o-algos/src/main/java/hex/hglm/HGLMModel.java @@ -88,7 +88,7 @@ private HGLMScore makeScoringTask(Frame adaptFrm, boolean makePredictions, Job j public static class HGLMParameters extends Model.Parameters { public long _seed = -1; public GLMModel.GLMParameters.Family _family; - public boolean _standardize = true; + public boolean _standardize = false; public int _max_iterations = -1; public double[] _initial_fixed_effects; // initial values of fixed coefficients public Key _initial_random_effects; // frame key that contains the initial starting values of random coefficient effects diff --git a/h2o-algos/src/test/java/hex/hglm/HGLMBasicTest.java b/h2o-algos/src/test/java/hex/hglm/HGLMBasicTest.java index 75a5c8a8c030..cb95dafaf8be 100644 --- a/h2o-algos/src/test/java/hex/hglm/HGLMBasicTest.java +++ b/h2o-algos/src/test/java/hex/hglm/HGLMBasicTest.java @@ -112,6 +112,7 @@ public void testLevel2enum1() { params._random_columns = new String[]{"enum6", "enum4", "enum2", "num1", "num3"}; params._showFixedMatVecs = true; params._max_iterations = 0; + params._standardize = true; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum1, params._group_column, params._standardize, @@ -135,6 +136,7 @@ public void testLevel2enum1NoIntercept() { params._showFixedMatVecs = true; params._max_iterations = 0; params._random_intercept = true; + params._standardize = true; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum1, params._group_column, params._standardize, @@ -252,6 +254,7 @@ public void testLevel2enum3() { params._random_columns = new String[]{"enum4", "enum1", "num1", "num2"}; params._showFixedMatVecs = true; params._max_iterations = 0; + params._standardize = true; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum3, params._group_column, params._standardize, @@ -274,6 +277,7 @@ public void testLevel2enum3V2() { params._random_columns = new String[]{"enum4", "enum1", "num1", "num2"}; params._showFixedMatVecs = true; params._max_iterations = 0; + params._standardize = true; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum3, params._group_column, params._standardize, @@ -297,6 +301,7 @@ public void testLevel2enum4() { params._random_columns = new String[]{"enum3", "enum1", "enum2", "enum6", "num1", "num2"}; params._showFixedMatVecs = true; params._max_iterations = 0; + params._standardize = true; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum4, params._group_column, params._standardize, @@ -319,6 +324,7 @@ public void testLevel2enum4V2() { params._random_columns = new String[]{"enum3", "enum1", "enum2", "enum6", "num1", "num2"}; params._showFixedMatVecs = true; params._max_iterations = 0; + params._standardize = true; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum4, params._group_column, params._standardize, @@ -341,6 +347,7 @@ public void testLevel2enum5() { params._random_columns = new String[]{"enum3", "enum1", "enum2", "enum6", "num1", "num3"}; params._showFixedMatVecs = true; params._max_iterations = 0; + params._standardize = true; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum5, params._group_column, params._standardize, @@ -363,6 +370,7 @@ public void testLevel2enum5V2() { params._random_columns = new String[]{"enum3", "enum1", "enum2", "enum6", "num1", "num3"}; params._showFixedMatVecs = true; params._max_iterations = 0; + params._standardize = true; HGLMModel model = new HGLM(params).trainModel().get(); Scope.track_generic(model); checkWithManualResults1(model, params._response_column, _simpleFrame1, _simpleFrameSortEnum5, params._group_column, params._standardize, @@ -749,6 +757,7 @@ public void testCoeffDeNNormalizationWithRandomIntercept() { parms._initial_fixed_effects = initBetaStandardize; parms._initial_random_effects = ubetaFrameStandardize._key; parms._random_intercept = true; + parms._standardize = true; // just make sure it runs HGLMModel model1 = new HGLM(parms).trainModel().get(); @@ -906,6 +915,7 @@ public void testSemiconductor() { parms._random_intercept = true; parms._group_column = "Device"; parms._max_iterations = 1; + parms._standardize = true; // just make sure it runs HGLMModel model = new HGLM(parms).trainModel().get(); diff --git a/h2o-py/h2o/estimators/hglm.py b/h2o-py/h2o/estimators/hglm.py index e5d57eaa8d21..cf27a0f7e713 100644 --- a/h2o-py/h2o/estimators/hglm.py +++ b/h2o-py/h2o/estimators/hglm.py @@ -41,7 +41,7 @@ def __init__(self, plug_values=None, # type: Optional[Union[None, str, H2OFrame]] family="gaussian", # type: Literal["gaussian"] rand_family=None, # type: Optional[Literal["gaussian"]] - standardize=True, # type: bool + standardize=False, # type: bool max_iterations=-1, # type: int initial_fixed_effects=None, # type: Optional[List[float]] initial_random_effects=None, # type: Optional[Union[None, str, H2OFrame]] @@ -116,7 +116,7 @@ def __init__(self, Defaults to ``None``. :type rand_family: Literal["gaussian"], optional :param standardize: Standardize numeric columns to have zero mean and unit variance. - Defaults to ``True``. + Defaults to ``False``. :type standardize: bool :param max_iterations: Maximum number of iterations. Value should >=1. A value of 0 is only set when only the model coefficient names and model coefficient dimensions are needed. @@ -432,7 +432,7 @@ def standardize(self): """ Standardize numeric columns to have zero mean and unit variance. - Type: ``bool``, defaults to ``True``. + Type: ``bool``, defaults to ``False``. """ return self._parms.get("standardize") diff --git a/h2o-py/tests/testdir_algos/hglm/pyunit_GH_8487_1p5_noise_var_scoring_history_summary.py b/h2o-py/tests/testdir_algos/hglm/pyunit_GH_8487_1p5_noise_var_scoring_history_summary.py index f346084cd252..02279374e526 100644 --- a/h2o-py/tests/testdir_algos/hglm/pyunit_GH_8487_1p5_noise_var_scoring_history_summary.py +++ b/h2o-py/tests/testdir_algos/hglm/pyunit_GH_8487_1p5_noise_var_scoring_history_summary.py @@ -73,7 +73,7 @@ def test_scoring_history_model_summary(): # check and make sure the llg from training and validation frame should be increasing in values # this is only true when the true residual variance is high. For low true residual variance, it is only # true for the last few iterations when the residual variance estimate is close to the true residual variance - if (residual_var_true >= 2): + if (residual_var_true > 2): for ind in list(range(1, model_iterations)): p_ind = ind-1 assert scoring_history.cell_values[p_ind][3] <= scoring_history.cell_values[ind][3], \ diff --git a/h2o-py/tests/testdir_algos/hglm/pyunit_GH_8487_coefficients_check.py b/h2o-py/tests/testdir_algos/hglm/pyunit_GH_8487_coefficients_check.py index 7097a2beedfb..a6589b29fede 100644 --- a/h2o-py/tests/testdir_algos/hglm/pyunit_GH_8487_coefficients_check.py +++ b/h2o-py/tests/testdir_algos/hglm/pyunit_GH_8487_coefficients_check.py @@ -17,7 +17,7 @@ def test_scoring_history_model_summary(): x.remove("C1") random_columns = ["C2", "C3", "C10", "C20"] hglm_model = hglm(random_columns=random_columns, group_column = "C1", score_each_iteration=True, seed=12345, - max_iterations=10) + max_iterations=10, standardize=True) hglm_model.train(x=x, y=y, training_frame=train, validation_frame=valid) # grab various metrics coef = hglm_model.coef() diff --git a/h2o-py/tests/testdir_algos/hglm/pyunit_GH_8487_p5_noise_var_scoring_history_summary.py b/h2o-py/tests/testdir_algos/hglm/pyunit_GH_8487_p5_noise_var_scoring_history_summary.py index 16e7aeb99d0c..e209b7b452ab 100644 --- a/h2o-py/tests/testdir_algos/hglm/pyunit_GH_8487_p5_noise_var_scoring_history_summary.py +++ b/h2o-py/tests/testdir_algos/hglm/pyunit_GH_8487_p5_noise_var_scoring_history_summary.py @@ -73,7 +73,7 @@ def test_scoring_history_model_summary(): # check and make sure the llg from training and validation frame should be increasing in values # this is only true when the true residual variance is high. For low true residual variance, it is only # true for the last few iterations when the residual variance estimate is close to the true residual variance - if (residual_var_true >= 2): + if (residual_var_true > 2): for ind in list(range(1, model_iterations)): p_ind = ind-1 assert scoring_history.cell_values[p_ind][3] <= scoring_history.cell_values[ind][3], \ diff --git a/h2o-r/h2o-package/R/hglm.R b/h2o-r/h2o-package/R/hglm.R index fbe405066097..a3007ca70b7c 100644 --- a/h2o-r/h2o-package/R/hglm.R +++ b/h2o-r/h2o-package/R/hglm.R @@ -40,7 +40,7 @@ #' @param family Family. Only gaussian is supported now. Must be one of: "gaussian". Defaults to gaussian. #' @param rand_family rand_family. Set distribution of random effects. Only Gaussian is implemented now. Must be one of: #' "gaussian". -#' @param standardize \code{Logical}. Standardize numeric columns to have zero mean and unit variance. Defaults to TRUE. +#' @param standardize \code{Logical}. Standardize numeric columns to have zero mean and unit variance. Defaults to FALSE. #' @param max_iterations Maximum number of iterations. Value should >=1. A value of 0 is only set when only the model coefficient #' names and model coefficient dimensions are needed. Defaults to -1. #' @param initial_fixed_effects An array that contains initial values of the fixed effects coefficient. @@ -94,7 +94,7 @@ h2o.hglm <- function(x, plug_values = NULL, family = c("gaussian"), rand_family = c("gaussian"), - standardize = TRUE, + standardize = FALSE, max_iterations = -1, initial_fixed_effects = NULL, initial_random_effects = NULL, @@ -214,7 +214,7 @@ h2o.hglm <- function(x, plug_values = NULL, family = c("gaussian"), rand_family = c("gaussian"), - standardize = TRUE, + standardize = FALSE, max_iterations = -1, initial_fixed_effects = NULL, initial_random_effects = NULL,