2023-01-22 15:26:44 -05:00
|
|
|
rm(list = ls(all.names = TRUE)) # Clear the memory of variables from previous run.
|
|
|
|
cat("\014") # Clear the console
|
|
|
|
|
|
|
|
|
|
|
|
# load packages -----------------------------------------------------------
|
|
|
|
|
|
|
|
box::use(
|
|
|
|
magrittr[`%>%`]
|
|
|
|
,here[here]
|
|
|
|
,readr
|
|
|
|
,gp2 = ggplot2[ggplot, aes]
|
2023-01-22 15:38:44 -05:00
|
|
|
,rsample
|
2023-01-22 15:26:44 -05:00
|
|
|
)
|
|
|
|
|
2023-01-22 15:38:44 -05:00
|
|
|
|
|
|
|
|
|
|
|
# globals -----------------------------------------------------------------
|
|
|
|
|
|
|
|
set.seed(070823) #set seed for reproducible research
|
|
|
|
|
|
|
|
|
|
|
|
# load-data ---------------------------------------------------------------
|
|
|
|
|
|
|
|
model_data <- readr$read_rds(here("ML","data-unshared","model_data.RDS"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# split data --------------------------------------------------------------
|
|
|
|
|
|
|
|
model_data_split <- rsample$initial_split(
|
|
|
|
model_data
|
|
|
|
,prop = 0.80
|
|
|
|
,strata = ft4_dia
|
|
|
|
)
|
|
|
|
|
|
|
|
ds_train <- rsample$training(model_data_split)
|
|
|
|
ds_test <- rsample$testing(model_data_split)
|
|
|
|
|
|
|
|
# verify distribution of data
|
|
|
|
table(ds_train$ft4_dia) %>% prop.table()
|
|
|
|
table(ds_test$ft4_dia) %>% prop.table()
|
|
|
|
|