Skip to content

Commit

Permalink
Set global R seed inside setup (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfsnow authored Dec 30, 2024
1 parent ee7808c commit 7344ec9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions R/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ if (knitr::is_html_output() || knitr::is_latex_output()) {
}
assign(params_obj_name, read_yaml(here("params.yaml")))

# Set the random seed for reproducibility. This is currently used in two places:
# 1. Within Tidymodels workflows whenever sampling is used e.g. for KNN impute
# 2. Within the CV loop to make random folds that are consistent across runs
# Note that LightGBM uses its own set of seeds i.e. this seed doesn't affect
# whether the model itself is deterministic
set.seed(get(params_obj_name)$model$seed)

# Get the number of available physical cores to use for multi-threading
# Lightgbm docs recommend using only real cores, not logical
# https://lightgbm.readthedocs.io/en/latest/Parameters.html#num_threads
Expand Down

0 comments on commit 7344ec9

Please sign in to comment.