From 554865451e2d5f77cfec6f55cbfaa0288caf8fc3 Mon Sep 17 00:00:00 2001 From: Wit Jakuczun Date: Sat, 23 Sep 2017 21:27:57 +0200 Subject: [PATCH] Added params to the master script --- README.md | 6 +++++- .../R/build_telco_churn_model.R | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7174bf9..6a1ebb0 100644 --- a/README.md +++ b/README.md @@ -59,9 +59,13 @@ You should get the following output Run model training and evaluation ```bash -Rscript R\build_telco_churn_model.R +Rscript.exe R\build_telco_churn_model.R --nthreads=4 --max-mem="4g" ``` +Please note that script has two parameters: + +* *nthreads* - number of threads to be used with -1 (all) as default +* *max_mem* - maximum memory size for H2O with 4g as default ### Check results diff --git a/telco-customer-churn-in-r-and-h2o/R/build_telco_churn_model.R b/telco-customer-churn-in-r-and-h2o/R/build_telco_churn_model.R index 8ab0a40..1a97d71 100644 --- a/telco-customer-churn-in-r-and-h2o/R/build_telco_churn_model.R +++ b/telco-customer-churn-in-r-and-h2o/R/build_telco_churn_model.R @@ -36,8 +36,13 @@ all_data[, churn := factor(ifelse(churn == 1, "churn", "nochurn"))] loginfo("--> done") -h2o_local <- h2o.init(nthreads = 4, - max_mem_size = "6g") +nthreads <- as.integer(args$get("nthreads", required = FALSE, default = -1)) +max_mem_size <- args$get("max_mem", required = FALSE, default = "4g") + +logdebug("------> nthreads:%d, max_mem_size:%s", nthreads, max_mem_size) + +h2o_local <- h2o.init(nthreads = nthreads, + max_mem_size = max_mem_size) h2o.removeAll() h2o_train <- as.h2o(x = all_data[ind == "Train"],