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

Error in advanced tuning chapter #840

Open
larskotthoff opened this issue Oct 28, 2024 · 6 comments
Open

Error in advanced tuning chapter #840

larskotthoff opened this issue Oct 28, 2024 · 6 comments

Comments

@larskotthoff
Copy link
Member

Running the first chunk of code in chapter 5:

tsk_pen = tsk("penguins")
# remove rows with missing values
tsk_pen$filter(tsk_pen$row_ids[complete.cases(tsk_pen$data())])
# create custom resampling with new factors in test data
rsmp_custom = rsmp("custom")
rsmp_custom$instantiate(tsk_pen,
  list(tsk_pen$row_ids[tsk_pen$data()$island != "Torgersen"]),
  list(tsk_pen$row_ids[tsk_pen$data()$island == "Torgersen"])
)
msr_ce = msr("classif.ce")
tnr_random = tnr("random_search")
learner = lrn("classif.lda", method = "t", nu = to_tune(3, 10))

tune(tnr_random, tsk_pen, learner, rsmp_custom, msr_ce, 10)

I get the error:

Error in lda.default(x, grouping, ...) : 
  variable 6 appears to be constant within groups
@be-marc
Copy link
Member

be-marc commented Nov 4, 2024

This chunk is supposed to throw an error.
The chunk definition looks like this {r, error = TRUE, warning = FALSE, message = FALSE}.
Do you get an error when running quarto render?
If so, the options may no longer be supported and we have to use #| error: true?

@larskotthoff
Copy link
Member Author

Ah, I see. Yes, I'm getting an error when I render this with quarto.

@be-marc
Copy link
Member

be-marc commented Nov 4, 2024

Can you try

{r}
#| error: true
#| warning: false
#| message: false

instead of

{r, error = TRUE, warning = FALSE, message = FALSE}

@larskotthoff
Copy link
Member Author

Ok, ran this again -- sorry, the actual error is coming from the chunk after that:

Error in `learner$encapsulate = c(train = "evaluate", predict = "evaluate")`:
! cannot change value of locked binding for 'encapsulate'
Backtrace:
  1. global .main()
  2. execute(...)
  3. rmarkdown::render(...)
  4. knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
  5. knitr:::process_file(text, output)
     ...
 16. base::withRestarts(...)
 17. base (local) withRestartList(expr, restarts)
 18. base (local) withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]])
 19. base (local) docall(restart$handler, restartArgs)
 21. evaluate (local) fun(base::quote(`<smplErrr>`))



Quitting from lines 58-59 [optimization-035] (advanced_tuning_methods_and_black_box_optimization.qmd)
Execution halted

So the error is "caught" as expected, but the example afterwards to demonstrate how to do this with encapsulation fails.

@be-marc
Copy link
Member

be-marc commented Nov 4, 2024

Ah sorry. It's clear that you also have these errors. This is all fixed in #829. @sebffischer Maybe you want to merge?

@sebffischer
Copy link
Member

I will meet with bernd on thursday to review the chapter again

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

No branches or pull requests

3 participants