Skip to content

Commit

Permalink
Fixed the "get old model results" error
Browse files Browse the repository at this point in the history
  • Loading branch information
gufengzhou committed Sep 30, 2021
1 parent 234bffb commit 1c4f351
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions R/R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ robyn_run <- function(InputCollect,

hyper_fixed <- all(sapply(InputCollect$hyperparameters, length) == 1)
if (hyper_fixed & is.null(dt_hyper_fixed)) {
stop("hyperparameters can't be all fixed for hyperparameter optimisation. If you want to get old model result, pleaseprovide only 1 model / 1 row from OutputCollect$resultHypParam or pareto_hyperparameters.csv from previous runs")
stop("hyperparameters can't be all fixed for hyperparameter optimisation. If you want to get old model result, please provide only 1 model / 1 row from OutputCollect$resultHypParam or pareto_hyperparameters.csv from previous runs")
}
hypParamSamName <- hyper_names(adstock = InputCollect$adstock, all_media = InputCollect$all_media)

Expand Down Expand Up @@ -263,6 +263,7 @@ robyn_run <- function(InputCollect,
message(paste0("Exporting all charts into directory: ", plot_folder, "/", plot_folder_sub))

message(">>> Plotting summary charts...")
local_name <- names(InputCollect$hyperparameters)
if (!hyper_fixed) {

## plot prophet
Expand Down Expand Up @@ -306,7 +307,6 @@ robyn_run <- function(InputCollect,
}

## plot hyperparameter sampling distribution
local_name <- names(InputCollect$hyperparameters)
resultHypParam.melted <- melt.data.table(resultHypParam[, c(local_name, "robynPareto"), with = FALSE], id.vars = c("robynPareto"))

pSamp <- ggplot(data = resultHypParam.melted, aes(x = value, y = variable, color = variable, fill = variable)) +
Expand Down
2 changes: 1 addition & 1 deletion demo/demo.R
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ Response2/Spend2 # ROI for search 81k
#### Optional: get old model results

# Get old hyperparameters and select model
dt_hyper_fixed <- fread("~/Desktop/2021-07-29 00.56 init/pareto_hyperparameters.csv")
dt_hyper_fixed <- data.table::fread("~/Desktop/2021-07-29 00.56 init/pareto_hyperparameters.csv")
select_model <- "1_24_5"
dt_hyper_fixed <- dt_hyper_fixed[solID == select_model]

Expand Down

0 comments on commit 1c4f351

Please sign in to comment.