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

Suggestion to improve code in chapter 12 #311

Open
InfiniteCuriosity opened this issue May 28, 2022 · 1 comment
Open

Suggestion to improve code in chapter 12 #311

InfiniteCuriosity opened this issue May 28, 2022 · 1 comment

Comments

@InfiniteCuriosity
Copy link

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)```
@juliasilge
Copy link
Member

I can see why that might be confusing. It is too late for us to include this in the print version of the initial publication, but we can come back and evaluate if we want to show this code in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants