-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PUBDEV-7914] grid with failing CV models would hang indefinitely (#5183
- Loading branch information
Honza Sterba
committed
Dec 12, 2020
1 parent
19bfcb9
commit 12f6e81
Showing
3 changed files
with
106 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
h2o-py/tests/testdir_algos/grid/pyunit_grid_parallel_cv_error.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import sys | ||
import os | ||
import random | ||
|
||
sys.path.insert(1, os.path.join("..", "..", "..")) | ||
import h2o | ||
from tests import pyunit_utils | ||
from h2o.grid.grid_search import H2OGridSearch | ||
from h2o.estimators.gbm import H2OGradientBoostingEstimator | ||
|
||
|
||
def grid_parallel(): | ||
train = h2o.import_file(path=pyunit_utils.locate("smalldata/iris/iris_wheader.csv")) | ||
fold_assignments = h2o.H2OFrame([[random.randint(0, 4)] for f in range(train.nrow)]) | ||
fold_assignments.set_names(["fold_assignment"]) | ||
train = train.cbind(fold_assignments) | ||
|
||
hyper_parameters = { | ||
"ntrees": [1, 3, 5], | ||
"min_rows": [1, 10, 100] | ||
} | ||
print("GBM grid with the following hyper_parameters:", hyper_parameters) | ||
|
||
gs = H2OGridSearch( | ||
H2OGradientBoostingEstimator, | ||
hyper_params=hyper_parameters, | ||
parallelism=4 | ||
) | ||
gs.train(x=list(range(4)), y=4, training_frame=train, fold_column="fold_assignment") | ||
assert gs is not None | ||
# only six models are trained, since CV is not possible with min_rows=100 | ||
assert len(gs.model_ids) == 6 | ||
|
||
|
||
if __name__ == "__main__": | ||
pyunit_utils.standalone_test(grid_parallel) | ||
else: | ||
grid_parallel() |