Skip to content

Commit

Permalink
h2o.saveAll edited to handle duplicate/xval models
Browse files Browse the repository at this point in the history
  • Loading branch information
Amy Wang committed Dec 4, 2014
1 parent 52777ef commit 74028a4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/h2o-package/R/ParseImport.R
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ h2o.saveModel <- function(object, dir="", name="",save_cv=TRUE, force=FALSE) {
h2o.saveAll <- function(object, dir="", save_cv=TRUE, force=FALSE) {
if(missing(object)) stop('Must specify object')
if(class(object) != 'H2OClient') stop('object must be of class H2OClient')
if(!is.logical(save_cv)) stop('save_cv needs to be a boolean')
if(!is.logical(force)) stop('force needs to be a boolean')

## Grab all the model keys in H2O
res = .h2o.__remoteSend(client = object, page = .h2o.__PAGE_ALLMODELS)
Expand All @@ -473,7 +475,7 @@ h2o.saveAll <- function(object, dir="", save_cv=TRUE, force=FALSE) {
for(key in keys) { dups = grep(pattern = paste(key, "_", sep = ""), x = keys)
duplicates = append(x = duplicates, values = dups)
}
keys = keys[-duplicates]
keys = if(length(duplicates) > 0) keys[-duplicates] else keys

## Create H2OModel objects in R (To grab the cross validation models)
models = lapply(keys, function(model_key) h2o.getModel(h2o = object, key = model_key))
Expand Down

0 comments on commit 74028a4

Please sign in to comment.