Skip to content

Commit

Permalink
set standarzie = false by default and changes all the tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
wendycwong committed Oct 20, 2024
1 parent 8df305d commit d38bd94
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion h2o-algos/src/main/java/hex/hglm/HGLMModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions h2o-algos/src/test/java/hex/hglm/HGLMBasicTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions h2o-py/h2o/estimators/hglm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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], \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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], \
Expand Down
6 changes: 3 additions & 3 deletions h2o-r/h2o-package/R/hglm.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d38bd94

Please sign in to comment.