Skip to content

Commit 6de64a6

Browse files
committed
implement copilot review, fix failling tests
1 parent d7d7f62 commit 6de64a6

6 files changed

Lines changed: 9 additions & 8 deletions

File tree

h2o-algos/src/main/java/hex/glm/GLM.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3416,7 +3416,6 @@ private void scoreAndUpdateModel() {
34163416
_model._useRemoveOffsetEffects = false;
34173417
}
34183418
}
3419-
_model.generateSummary(_parms._train, _state._iter);
34203419
_lastScore = System.currentTimeMillis();
34213420
long scoringTime = System.currentTimeMillis() - t1;
34223421
_scoringInterval = Math.max(_scoringInterval, 20 * scoringTime); // at most 5% overhead for scoring
@@ -3572,14 +3571,16 @@ private void scorePostProcessing(Frame train, long t1) {
35723571
Log.info(LogMsg("Training metrics computed in " + (t2 - t1) + "ms"));
35733572
if (_valid != null) {
35743573
Frame valid = DKV.<Frame>getGet(_parms._valid);
3574+
ScoreKeeper validScore = new ScoreKeeper(Double.NaN);
35753575
_model.score(_parms.valid(), null, CFuncRef.from(_parms._custom_metric_func)).delete();
35763576
if(_model._parms._control_variables != null || _model._parms._remove_offset_effects){
35773577
_model._output._validation_metrics_unrestricted_model = ModelMetrics.getFromDKV(_model, valid);
3578+
validScore.fillFrom(_model._output._validation_metrics_unrestricted_model);
35783579
} else {
35793580
_model._output._validation_metrics = ModelMetrics.getFromDKV(_model, valid); //updated by model.scoreAndUpdateModel
3581+
validScore.fillFrom(_model._output._validation_metrics);
35803582
}
3581-
ScoreKeeper validScore = new ScoreKeeper(Double.NaN);
3582-
validScore.fillFrom(_model._output._validation_metrics);
3583+
35833584
}
35843585
if(_model._parms._control_variables != null || _model._parms._remove_offset_effects) {
35853586
_model.addUnrestrictedModelScoringInfo(_parms, nclasses(), t2, _state._iter);

h2o-algos/src/test/java/hex/glm/GLMControlVariablesTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,11 @@ public void testControlVariableMultinomial() {
416416
GLMModel glm = null;
417417
try {
418418
Scope.enter();
419-
420419
Vec cat1 = Vec.makeVec(new long[]{1,1,1,0,0},new String[]{"black","red"},Vec.newKey());
421420
Vec cat2 = Vec.makeVec(new long[]{1,1,1,0,0},new String[]{"a","b"},Vec.newKey());
422421
Vec res = Vec.makeVec(new double[]{1,1,2,0,0},cat1.group().addVec());
423422
train = new Frame(Key.<Frame>make("train"),new String[]{"x1", "x2", "y"},new Vec[]{cat1, cat2,res});
423+
DKV.put(train);
424424

425425
GLMModel.GLMParameters params = new GLMModel.GLMParameters();
426426
params._train = train._key;

h2o-bindings/bin/custom/R/gen_glm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def update_param(name, param):
8282
h2o.make_unrestricted_glm_model <- function(model, destination_key = NULL, control_variables_enabled = FALSE, remove_offset_effects_enabled = FALSE) {
8383
stopifnot("GLM wasn't trained with control variables or with remove offset effects." =
8484
!is.null(model@params$actual[["control_variables"]]) || isTRUE(model@params$actual[["remove_offset_effects"]]))
85-
if ((is.null(model@params$actual[["control_variables"]]) || isTRUE(model@params$actual[["remove_offset_effects"]]))
85+
if ((is.null(model@params$actual[["control_variables"]]) || isFALSE(model@params$actual[["remove_offset_effects"]]))
8686
&& (isTRUE(control_variables_enabled) || isTRUE(remove_offset_effects_enabled))) {
8787
stop("GLM wasn't trained with both control variables and with remove offset effects feature set, the control_variables_enabled and remove_offset_effects_enabled features cannot be used.")
8888
}

h2o-py/tests/testdir_algos/glm/pyunit_remove_offset_effects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def glm_remove_offset_effects():
1111
cars = cars[cars["economy_20mpg"].isna() == 0]
1212
cars["name"] = cars["name"].asfactor()
1313
cars["economy_20mpg"] = cars["economy_20mpg"].asfactor()
14-
offset = h2o.H2OFrame([[.5]]*cars.nrow)
14+
offset = h2o.H2OFrame([[.5]] * cars.nrows)
1515
offset.set_names(["offset"])
1616
cars = cars.cbind(offset)
1717

h2o-r/h2o-package/R/glm.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ h2o.makeGLMModel <- function(model,beta) {
845845
h2o.make_unrestricted_glm_model <- function(model, destination_key = NULL, control_variables_enabled = FALSE, remove_offset_effects_enabled = FALSE) {
846846
stopifnot("GLM wasn't trained with control variables or with remove offset effects." =
847847
!is.null(model@params$actual[["control_variables"]]) || isTRUE(model@params$actual[["remove_offset_effects"]]))
848-
if ((is.null(model@params$actual[["control_variables"]]) || isTRUE(model@params$actual[["remove_offset_effects"]]))
848+
if ((is.null(model@params$actual[["control_variables"]]) || isFALSE(model@params$actual[["remove_offset_effects"]]))
849849
&& (isTRUE(control_variables_enabled) || isTRUE(remove_offset_effects_enabled))) {
850850
stop("GLM wasn't trained with both control variables and with remove offset effects feature set, the control_variables_enabled and remove_offset_effects_enabled features cannot be used.")
851851
}

h2o-r/tests/testdir_algos/glm/runit_GLM_make_unrestricted_model.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ glm_make_unrestricted_model_test <- function() {
6363
assertError(h2o.make_unrestricted_glm_model(prostate_glm_2, control_variables_enabled=TRUE))
6464
}
6565

66-
doTest("GLM: Remove offset effects works with explain", glm_make_unrestricted_model_test)
66+
doTest("GLM: Test make unrestricted model", glm_make_unrestricted_model_test)

0 commit comments

Comments
 (0)