dlab-berkeley / R-Machine-Learning-Legacy

D-Lab's 6 hour introduction to machine learning in R. Learn the fundamentals of machine learning, regression, and classification, using tidymodels in R.
Other
47 stars 25 forks source link

Solutions for 04_regularization #67

Open leahhrlee opened 11 months ago

leahhrlee commented 11 months ago

Solutions for 04_regularization should include:

Import data

penguins <- palmerpenguins::penguins %>% filter(!is.na(bill_length_mm))

Set seed

set.seed(23)

Perform split

penguin_split <- penguins %>% initial_split(prop = 0.80) penguins_train <- training(penguin_split) penguins_test <- testing(penguin_split)

Participants will run into error if null values in bill_length_mm are not dropped

leahhrlee commented 11 months ago

If not filtered, this error will occur: "Error in if (nulldev == 0) stop("y is constant; gaussian glmnet fails at standardization step") : missing value where TRUE/FALSE needed"