tidymodels / dials

Tools for creating tuning parameter values
https://dials.tidymodels.org/
Other
114 stars 27 forks source link

tune_bayes issue #270

Closed amin0511ss closed 1 year ago

amin0511ss commented 1 year ago

I did a tune_grid to find the best parameters setup for a light GBM fit (bonsai package). I then try to improve upon it by using tune_bayes command and set initial to "tune_grid". the code is below and then the error message is shown further down.

code: lgbm_tuned <- tune_grid(object = lgbm_workflow, resamples = IndividualData_cv_folds, grid = lgbm_grid, metrics = metric_set(yardstick::rmse), control_grid(verbose = F) )

set.seed(1432) lgbm_bayes <- tune_bayes(lgbm_workflow, IndividualData_cv_folds, initial = lgbm_tuned, iter = 6)

The error message: Gaussian process model: Error in .f(): ! The parameter object contains unknowns. ℹ This is an internal error that was detected in the dials package. Please report it at https://github.com/tidymodels/dials/issues with a [reprex](https://https:/... Error in check_gp_failure(): ! Gaussian process model was not fit. Run rlang::last_error() to see where the error occurred. ✖ Optimization stopped prematurely; returning current results.

rlang::last_error() <error/rlang_error> Error in check_gp_failure(): ! Gaussian process model was not fit.

Backtrace:

  1. tune::tune_bayes(...)
  2. tune:::tune_bayes.workflow(...)
  3. tune:::tune_bayes_workflow(...)
  4. tune:::check_gp_failure(gp_mod, prev_gp_mod) Run rlang::last_trace() to see the full context. rlang::last_trace() <error/rlang_error> Error in check_gp_failure(): ! Gaussian process model was not fit.

    Backtrace: ▆

  5. ├─tune::tune_bayes(...)
  6. └─tune:::tune_bayes.workflow(...)
  7. └─tune:::tune_bayes_workflow(...)
  8. └─tune:::check_gp_failure(gp_mod, prev_gp_mod)
  9. └─rlang::abort("Gaussian process model was not fit.")
hfrick commented 1 year ago

Hi @amin0511ss, Thanks for reporting this! Could you post a reproducible example, please? I can't run your example because I'm missing a lot of elements you're using, such as the workflow object and the grid object.

The reprex makes it easy to ensure that your example code is indeed reproducible and has helpful tips for do's and don'ts.

hfrick commented 1 year ago

And a sorta wild guess which may also be a red herring: The error says "! The parameter object contains unknowns." Are you trying to tune over the mtry parameter? That, per default, contains an unknown in the range of possible values because the upper limit depends on how many predictors are in the model/data. This parameter needs to be finalized (i.e., the upper limit set) before it can be used to tune.

hfrick commented 1 year ago

I'm going to close this now, assuming it has been resolved. If not, please open another issue!

github-actions[bot] commented 1 year ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.