Skip to content

Commit

Permalink
added csv_out to allow all iteratiosns in csv output
Browse files Browse the repository at this point in the history
  • Loading branch information
gufengzhou committed Nov 2, 2021
1 parent 5a46c9d commit 094ea5e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
13 changes: 11 additions & 2 deletions R/R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#' lambda.min and lambda.1se.
#' @param refresh Boolean. Set to \code{TRUE} when used in \code{robyn_refresh()}.
#' @param seed Integer. For reproducible results when running nevergrad.
#' @param csv_out Character. Accepts "pareto" or "all". Default to "pareto". Set
#' to "all" will output all iterations as csv.
#' @param ui Boolean. Save additional outputs for UI usage. List outcome.
#' @examples
#' \dontrun{
Expand All @@ -48,6 +50,7 @@ robyn_run <- function(InputCollect,
refresh = FALSE,
dt_hyper_fixed = NULL,
seed = 123L,
csv_out = "pareto",
ui = FALSE) {

#####################################
Expand Down Expand Up @@ -848,8 +851,14 @@ robyn_run <- function(InputCollect,

allSolutions <- xDecompVecCollect[, unique(solID)]

fwrite(resultHypParam[solID %in% allSolutions], paste0(plot_folder, "/", plot_folder_sub, "/", "pareto_hyperparameters.csv"))
fwrite(xDecompAgg[solID %in% allSolutions], paste0(plot_folder, "/", plot_folder_sub, "/", "pareto_aggregated.csv"))
if (!csv_out %in% c("pareto", "all")) csv_out <- "pareto"
if (csv_out == "pareto") {
fwrite(resultHypParam[solID %in% allSolutions], paste0(plot_folder, "/", plot_folder_sub, "/", "pareto_hyperparameters.csv"))
fwrite(xDecompAgg[solID %in% allSolutions], paste0(plot_folder, "/", plot_folder_sub, "/", "pareto_aggregated.csv"))
} else if (csv_out == "all") {
fwrite(resultHypParam, paste0(plot_folder, "/", plot_folder_sub, "/", "all_hyperparameters.csv"))
fwrite(xDecompAgg, paste0(plot_folder, "/", plot_folder_sub, "/", "all_aggregated.csv"))
}
fwrite(mediaVecCollect, paste0(plot_folder, "/", plot_folder_sub, "/", "pareto_media_transform_matrix.csv"))
fwrite(xDecompVecCollect, paste0(plot_folder, "/", plot_folder_sub, "/", "pareto_alldecomp_matrix.csv"))

Expand Down
4 changes: 4 additions & 0 deletions R/man/robyn_run.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions demo/debug.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ lambda_control = 1
refresh = FALSE
dt_hyper_fixed = NULL
ui = FALSE
csv_out = "pareto"
seed = 123
# go into robyn_run() line by line

Expand Down

0 comments on commit 094ea5e

Please sign in to comment.