curso-r / treesnip

Parsnip backends for `tree`, `lightGBM` and `Catboost`
https://curso-r.github.io/treesnip
GNU General Public License v3.0
85 stars 13 forks source link

Engine 'catboost' is not supported for `boost_tree()`. See `show_engines('boost_tree')`. #69

Open zhaoliang0302 opened 1 year ago

zhaoliang0302 commented 1 year ago

Hi, error occurs after tuning grid with catboost in treesnip package:

remotes::install_github("curso-r/treesnip@catboost")
library(treesnip)

catboost_model <-
  boost_tree( mode = "classification",
              mtry = tune(), # default [1, ?]
              trees = 1000, # default [1, 2000]
              min_n = 20, # default [2, 40]
              tree_depth = 6, # default [1, 15]
              learn_rate = 0.05, # default [-10, -1]
              engine = "catboost"
  )

catboost_wf <-
  workflow() %>%
  add_model(catboost_model) %>% 
  add_recipe(model_recipe)

catboost_results <-
  catboost_wf %>% 
  tune_grid(resamples = miR_cv,
            grid = 5,
            control = control_grid(save_pred = TRUE),
            metrics = metric_set(accuracy,roc_auc)
  )
#Warning message:
#All models failed. Run `show_notes(.Last.tune.result)` for more information.

show_notes(.Last.tune.result)

#unique notes:
#------------------------------------------------------------------------------------------
#Error in `check_spec_mode_engine_val()`:
#! Engine 'catboost' is not supported for `boost_tree()`. See `show_engines('boost_tree')`.
vidarsumo commented 8 months ago

Run this first:

parsnip::set_dependency("boost_tree", eng = "catboost", pkg = "catboost", mode = "regression")
parsnip::set_dependency("boost_tree", eng = "catboost", pkg = "treesnip", mode = "regression")

Should work.