Skip to content

Suggestion to improve code in chapter 12 #311

@InfiniteCuriosity

Description

@InfiniteCuriosity

Chapter 12 includes this code, which returns an error for me (I'll explain why in a second)

tidymodels_prefer()
llhood <- function(...) {
  logistic_reg() %>% 
    set_engine("glm", ...) %>% 
    fit(Class ~ ., data = training_set) %>% 
    glance() %>% 
    select(logLik)
}

The error is that training_set is not found:
Error in fit.model_spec(., class ~ ., data = training_set) :
object 'training_set' not found

I searched for quite a while for the training set and found it in the GitHub repo, but I'm not sure everyone will figure this out. You might want to include the code below in the code example in the book before calling on the training_set. The code above runs correctly for me once this is done.

set.seed(91)
split <- initial_split(two_class_dat)
training_set <- training(split)
testing_set <- testing(split)```

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions