Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set global R seed inside setup #307

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading