From a6fae5ccfcc63a801576e4dacb492610267598dc Mon Sep 17 00:00:00 2001
From: certara-mtalley <150705449+certara-mtalley@users.noreply.github.com>
Date: Fri, 27 Sep 2024 11:26:47 -0700
Subject: [PATCH 1/2] control set.seed() behavior
Changing the location of set.seed().
Currently it is set outside of the pop parameter loop. The sampling that happens inside that loop changes the seed slightly, so the order in which parameters are listed will affect the seed they get, altering the outcomes of the search. By setting it inside, each parameter should be starting with the same seed.
---
R/ml_cov_search.R | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/R/ml_cov_search.R b/R/ml_cov_search.R
index 708ffbb..5bdcdc4 100644
--- a/R/ml_cov_search.R
+++ b/R/ml_cov_search.R
@@ -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))
@@ -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()
From 0666bc9d4805a896ba6e821dda6a1919a0756b3a Mon Sep 17 00:00:00 2001
From: certara-mtalley <150705449+certara-mtalley@users.noreply.github.com>
Date: Fri, 27 Sep 2024 11:27:24 -0700
Subject: [PATCH 2/2] update snapshots
change to seed affected the results of the ml_cov_search() that was used to create residuals plots.
---
.../custom-shap-plots.svg | 252 +++++-----
.../default-shap-plots.svg | 432 +++++++++---------
2 files changed, 348 insertions(+), 336 deletions(-)
diff --git a/tests/testthat/_snaps/generate_shap_summary_plot/custom-shap-plots.svg b/tests/testthat/_snaps/generate_shap_summary_plot/custom-shap-plots.svg
index c781129..1c033a8 100644
--- a/tests/testthat/_snaps/generate_shap_summary_plot/custom-shap-plots.svg
+++ b/tests/testthat/_snaps/generate_shap_summary_plot/custom-shap-plots.svg
@@ -21,133 +21,139 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1.3e-01
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1.5e-01
+
-AGE
-
-
-
--0.3
-0.0
-0.3
-Test y-axis
+SEX
+
+
+
+
+
+-0.2
+-0.1
+0.0
+0.1
+0.2
+Test y-axis
Test x-axis
-
-Feature value
-
-
-
-
-
- Low
-High
-Test Title
+
+Feature value
+
+
+
+
+
+ Low
+High
+Test Title
diff --git a/tests/testthat/_snaps/generate_shap_summary_plot/default-shap-plots.svg b/tests/testthat/_snaps/generate_shap_summary_plot/default-shap-plots.svg
index b5597c3..98054a8 100644
--- a/tests/testthat/_snaps/generate_shap_summary_plot/default-shap-plots.svg
+++ b/tests/testthat/_snaps/generate_shap_summary_plot/default-shap-plots.svg
@@ -21,222 +21,228 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-0.129
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+0.147
+
-AGE
-
-
-
--0.3
-0.0
-0.3
-SHAP value (impact on model output)
-
-Feature value
-
-
-
-
-
- Low
-High
-CL
+SEX
+
+
+
+
+
+-0.2
+-0.1
+0.0
+0.1
+0.2
+SHAP value (impact on model output)
+
+Feature value
+
+
+
+
+
+ Low
+High
+V1