From 327f7328f47a23912ce4082ef67cbc1b7d508905 Mon Sep 17 00:00:00 2001 From: Gufeng Zhou Date: Thu, 25 Nov 2021 20:46:02 +0100 Subject: [PATCH] update version, minor change in plotting progress bar & typos --- R/DESCRIPTION | 2 +- R/R/imports.R | 2 +- R/R/model.R | 19 +++++++++++++------ R/man/robyn_refresh.Rd | 3 ++- R/man/robyn_run.Rd | 3 ++- demo/demo.R | 4 ++-- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/R/DESCRIPTION b/R/DESCRIPTION index 23c184300..51bf00ff9 100644 --- a/R/DESCRIPTION +++ b/R/DESCRIPTION @@ -1,7 +1,7 @@ Package: Robyn Type: Package Title: Automated Marketing Mix Modeling (MMM) Open Source Beta Project from Facebook Marketing Science -Version: 3.4.7 +Version: 3.4.8 Authors@R: c( person("Gufeng", "Zhou", , "gufeng@fb.com", c("aut")), person("Leonel", "Sentana", , "leonelsentana@fb.com", c("aut")), diff --git a/R/R/imports.R b/R/R/imports.R index 18523e420..c211c2bce 100644 --- a/R/R/imports.R +++ b/R/R/imports.R @@ -54,7 +54,7 @@ dt_vars <- c( "optmResponseUnitTotalLift", "optmSpendUnit", "optmSpendUnitTotalDelta", "param", "perc", "percentage", "pos", "predicted", "refreshStatus", "response", "rn", "robynPareto", "roi", "roi_mean", "roi_total", "rsq_lm", "rsq_nls", "rsq_train", "s0", "scale_shape_halflife", - "season", "shape", "solID", "spend", "spend_share", "spend_share_refresh", + "season", "shape", "solID", "spend", "spend_share", "spend_share_refresh", "sid", "theta", "theta_halflife", "total_spend", "trend", "trial", "type", "value", "variable", "weekday", "x", "xDecompAgg", "xDecompMeanNon0", "xDecompMeanNon0Perc", "xDecompMeanNon0PercRF", "xDecompMeanNon0RF", "xDecompPerc", "xDecompPercRF", "y", "yhat", diff --git a/R/R/model.R b/R/R/model.R index 8666db0e1..6b1ac813a 100644 --- a/R/R/model.R +++ b/R/R/model.R @@ -155,7 +155,7 @@ robyn_run <- function(InputCollect, "hyperparameters & 10-fold ridge x-validation on 1 core (Windows fallback)" )) } - + # ng_collect <- list() model_output_collect <- list() @@ -468,7 +468,7 @@ robyn_run <- function(InputCollect, # ggplot doesn't work with process forking on MacOS # however it works fine on Linux and Windows parallel_plotting <- Sys.info()["sysname"] != "Darwin" - + if (plot_pareto) { if (parallel_plotting) { message(paste(">>> Plotting", num_pareto123, "Pareto optimum models on", InputCollect$cores, "cores...")) @@ -476,7 +476,7 @@ robyn_run <- function(InputCollect, message(paste(">>> Plotting", num_pareto123, "Pareto optimum models on 1 core (MacOS fallback)...")) } } - + if (parallel_plotting) { registerDoParallel(InputCollect$cores) } else { @@ -857,6 +857,11 @@ robyn_run <- function(InputCollect, dt_transformSaturationSpendReverse[, (InputCollect$organic_vars) := NA] } + if (!parallel_plotting) { + cnt <- cnt + 1 + setTxtProgressBar(pbplot, cnt) + } + return(list( mediaVecCollect = rbind( dt_transformPlot[, ":="(type = "rawMedia", solID = sid)], @@ -872,8 +877,10 @@ robyn_run <- function(InputCollect, )) } # end solution loop - cnt <- cnt + length(uniqueSol) - setTxtProgressBar(pbplot, cnt) + if (parallel_plotting) { + cnt <- cnt + length(uniqueSol) + setTxtProgressBar(pbplot, cnt) + } # append parallel run results mediaVecCollect <- append(mediaVecCollect, lapply(parallelResult, function (x) x$mediaVecCollect)) @@ -1118,7 +1125,7 @@ robyn_mmm <- function(hyper_collect, # enable parallelisation of main modelling loop for MacOS and Linux only parallel_processing <- .Platform$OS.type == "unix" - + # create cluster before big for-loop to minimize overhead for parallel backend registering if (parallel_processing) { registerDoParallel(InputCollect$cores) diff --git a/R/man/robyn_refresh.Rd b/R/man/robyn_refresh.Rd index e00757a58..4b97cb3ad 100644 --- a/R/man/robyn_refresh.Rd +++ b/R/man/robyn_refresh.Rd @@ -21,7 +21,8 @@ robyn_refresh( that contains all previous modeling information.} \item{plot_folder_sub}{Character. Customize sub path to save plots. The total -path is created with \code{dir.create(file.path(plot_folder, plot_folder_sub))}.} +path is created with \code{dir.create(file.path(plot_folder, plot_folder_sub))}. +For example, plot_folder_sub = "sub_dir".} \item{dt_input}{A data.frame. Should include all previous data and newly added data for the refresh.} diff --git a/R/man/robyn_run.Rd b/R/man/robyn_run.Rd index 28b701192..5f9a9a077 100644 --- a/R/man/robyn_run.Rd +++ b/R/man/robyn_run.Rd @@ -27,7 +27,8 @@ Required when \code{robyn_object} is not provided.} to \code{robyn_object} and saves plot in the same directory as \code{robyn_object}.} \item{plot_folder_sub}{Character. Customize sub path to save plots. The total -path is created with \code{dir.create(file.path(plot_folder, plot_folder_sub))}.} +path is created with \code{dir.create(file.path(plot_folder, plot_folder_sub))}. +For example, plot_folder_sub = "sub_dir".} \item{pareto_fronts}{Integer. Number of Pareto fronts for the output. \code{pareto_fronts = 1} returns the best models trading off \code{NRMSE} & diff --git a/demo/demo.R b/demo/demo.R index 5c337a272..b86f6ea35 100644 --- a/demo/demo.R +++ b/demo/demo.R @@ -4,7 +4,7 @@ # LICENSE file in the root directory of this source tree. ############################################################################################# -#################### Facebook MMM Open Source - Robyn 3.4.7 ###################### +#################### Facebook MMM Open Source - Robyn 3.4.8 ###################### #################### Quick guide ####################### ############################################################################################# @@ -129,7 +129,7 @@ InputCollect <- robyn_inputs( ,nevergrad_algo = "TwoPointsDE" # recommended algorithm for Nevergrad, the gradient-free # optimisation library https://facebookresearch.github.io/nevergrad/index.html - ,trials = 5 # number of allowed iterations per trial. 5 is recommended without calibration, + ,trials = 5 # number of allowed trials. 5 is recommended without calibration, # 10 with calibration. # Time estimation: with geometric adstock, 2000 iterations * 5 trials