Skip to content

Commit

Permalink
a few more checks for model show methods
Browse files Browse the repository at this point in the history
  • Loading branch information
spennihana committed Sep 5, 2014
1 parent c8dae58 commit 31821ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 1 addition & 2 deletions R/h2o-package/R/Algorithms.R
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@ h2o.deeplearning <- function(x, y, data, key = "",
# params$mom_ramp = model_params$momentum_ramp
# params$mom_stable = model_params$momentum_stable
# params$epochs = model_params$epochs

# result$params = params
# model_params = res$model_info$parameters
model_params = res$model_info$job
Expand Down Expand Up @@ -1072,7 +1071,7 @@ h2o.SpeeDRF <- function(x, y, data, key="", classification=TRUE, nfolds=0, valid
raw_cms[[length(raw_cms)]] = NULL
raw_cms <- lapply(raw_cms, function(x) { if(length(x) > dom_len) x = x[1:dom_len]; return(x) })


# rrr <- NULL
# if ( res$parameters$n_folds <= 0) {
# f <- function(o) { o[-length(o)] }
Expand Down
10 changes: 6 additions & 4 deletions R/h2o-package/R/Classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ setMethod("show", "H2OGLMModel", function(object) {
cat(" Best Threshold:", round(model$best_threshold,5))
cat("\n\nConfusion Matrix:\n"); print(model$confusion)
if (!is.null(model$auc)) {
trainOrTest <- ifelse(is.na(object@valid@key), "train)", "test)")
if(.hasSlot(object, "valid"))
trainOrTest <- ifelse(is.na(object@valid@key), "train)", "test)")
else trainOrTest <- "train)"
cat("\nAUC = ", model$auc, "(on", trainOrTest ,"\n")
}
}
Expand Down Expand Up @@ -207,7 +209,7 @@ setMethod("show", "H2ODeepLearningModel", function(object) {
if(model$params$nfolds == 0)
cat("Reported on", object@data@key, "\n")
else
if (object@model$params$nfolds >= 2)
if (!is.null(object@model$params$nfolds) && object@model$params$nfolds >= 2)
cat("Reported on", paste(model$params$nfolds, "-fold cross-validated data", sep = ""), "\n")
} else
cat("Reported on", object@valid@key, "\n")
Expand Down Expand Up @@ -251,7 +253,7 @@ setMethod("show", "H2ODRFModel", function(object) {
if(model$params$classification) {
cat("\nConfusion matrix:\n")
if(is.na(object@valid@key))
if (object@model$params$nfolds >= 2)
if (!is.null(object@model$params$nfolds) && object@model$params$nfolds >= 2)
cat("Reported on", paste(object@model$params$nfolds, "-fold cross-validated data", sep = ""), "\n")
else cat("Reported on training data.")
else
Expand Down Expand Up @@ -287,7 +289,7 @@ setMethod("show", "H2OSpeeDRFModel", function(object) {

cat("\nConfusion matrix:\n");
if(is.na(object@valid@key)) {
if (object@model$params$nfolds >= 2)
if (!is.null(object@model$params$nfolds) && object@model$params$nfolds >= 2)
cat("Reported on", paste(object@model$params$nfolds, "-fold cross-validated data", sep = ""), "\n")
else cat("Reported on training data.")
} else cat("Reported on", object@valid@key, "\n")
Expand Down

0 comments on commit 31821ba

Please sign in to comment.