Skip to content

Commit

Permalink
Merge pull request #19 from certara/pmxrd_175_set_seed
Browse files Browse the repository at this point in the history
PMXRD-175 Set seed
  • Loading branch information
certara-irebai authored Sep 30, 2024
2 parents b3a3fcf + 0666bc9 commit 83bd80c
Show file tree
Hide file tree
Showing 3 changed files with 350 additions and 340 deletions.
6 changes: 2 additions & 4 deletions R/ml_cov_search.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ ml_cov_search <- function(data, pop_param, cov_continuous, cov_factors, seed = 1
# Check that covariates supplied by user exist in the data
data_validation(data, pop_param, cov_continuous, cov_factors)

# Set seed
# Check if seed is numeric.
stopifnot(is.numeric(seed))
set.seed(seed)

stopifnot(requireNamespace("caret", quietly = TRUE))

Expand Down Expand Up @@ -96,9 +95,8 @@ ml_cov_search <- function(data, pop_param, cov_continuous, cov_factors, seed = 1
pb <- progress::progress_bar$new(
format = "[:bar] :percent :elapsed elapsed / :eta remaining", total = length(pop_param) * 6, clear = FALSE, show_after = 0)
for (i in pop_param) {
# Use same seed for each iteration of loop
set.seed(seed)
my_seed_name <- paste0("seed_", i)
assign(my_seed_name, .Random.seed, envir = .GlobalEnv)

pb$message(paste0("Searching covariate effects on ", i))
pb$tick()
Expand Down
Loading

0 comments on commit 83bd80c

Please sign in to comment.