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

parsnip could not locate an implementation for boost_tree regression model specifications using the catboost engine. #998

Closed
vidarsumo opened this issue Aug 31, 2023 · 2 comments

Comments

@vidarsumo
Copy link

The problem

I'm unable to tune catboost (and lightgbm) in parallel using tune_race_anova. Both work sequentially. I've had this problem before but then I solved it with parsnip::set_dependency.
I get the same error when using tune_grid(). However, if I install development version of parsinp then tune_grid() works in parallel but tune_race_anova still fails with the same message.

I've tried to add catboost and treesnip to the pkgs argument in control_race without success.

This also seems to be connected to Windows as I was able to run this using docker.

Reproducible example

library(tidymodels)
library(catboost)
library(treesnip)

data_use_tbl <- mtcars %>% 
  as_tibble()

resamples <- data_use_tbl %>% vfold_cv()

rec <- recipe(mpg ~ ., data = data_use_tbl)

boost_spec <- boost_tree(
  mode = "regression",
  trees = tune(),
  learn_rate = tune()
) %>% 
  set_engine("catboost", allow_writing_files = FALSE)

wflw <- workflow() %>% 
  add_recipe(rec) %>% 
  add_model(boost_spec)


set.seed(124)

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

doParallel::registerDoParallel()

tune_results <- finetune::tune_race_anova(
  object     = wflw,
  resamples  = resamples,
  grid       = 30,
  control    = finetune::control_race(allow_par = TRUE, verbose = TRUE)
)
#> Warning: All models failed. Run `show_notes(.Last.tune.result)` for more
#> information.
#> Error in `test_parameters_gls()`:
#> ! There were no valid metrics for the ANOVA model.
#> Backtrace:
#>     ▆
#>  1. ├─finetune::tune_race_anova(...)
#>  2. └─finetune:::tune_race_anova.workflow(...)
#>  3.   └─finetune:::tune_race_anova_workflow(...)
#>  4.     └─finetune:::test_parameters_gls(res, control$alpha)
#>  5.       └─rlang::abort("There were no valid metrics for the ANOVA model.")

foreach::registerDoSEQ()
gc()
#>           used  (Mb) gc trigger  (Mb) max used  (Mb)
#> Ncells 2640292 141.1    4318425 230.7  4318425 230.7
#> Vcells 4517022  34.5   10146329  77.5  7006457  53.5

Created on 2023-08-31 with reprex v2.0.2

────────────────────────────────────────────────────────────────────────
Error:
! parsnip could not locate an implementation for `boost_tree` regression
  model specifications using the `catboost` engine.
> sessioninfo::session_info()
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.3.1 (2023-06-16 ucrt)
 os       Windows 10 x64 (build 19045)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  Icelandic_Iceland.utf8
 ctype    Icelandic_Iceland.utf8
 tz       Atlantic/Reykjavik
 date     2023-08-31
 rstudio  2023.06.1+524 Mountain Hydrangea (desktop)
 pandoc   NA

─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────────
 package      * version    date (UTC) lib source
 backports      1.4.1      2021-12-13 [1] CRAN (R 4.2.0)
 broom        * 1.0.5      2023-06-09 [1] CRAN (R 4.3.0)
 cachem         1.0.8      2023-05-01 [1] CRAN (R 4.3.0)
 callr          3.7.3      2022-11-02 [1] CRAN (R 4.2.2)
 catboost     * 1.2.1      2023-08-31 [1] url (https://github.com/catboost/catboost/releases/download/v1.2.1/catboost-R-Windows-1.2.1.tgz)
 class          7.3-22     2023-05-03 [2] CRAN (R 4.3.1)
 cli            3.6.1      2023-03-23 [1] CRAN (R 4.2.3)
 codetools      0.2-19     2023-02-01 [2] CRAN (R 4.3.1)
 colorspace     2.1-0      2023-01-23 [1] CRAN (R 4.2.2)
 crayon         1.5.2      2022-09-29 [1] CRAN (R 4.2.2)
 data.table     1.14.8     2023-02-17 [1] CRAN (R 4.2.3)
 devtools     * 2.4.5      2022-10-11 [1] CRAN (R 4.2.2)
 dials        * 1.2.0      2023-04-03 [1] CRAN (R 4.2.3)
 DiceDesign     1.9        2021-02-13 [1] CRAN (R 4.2.0)
 digest         0.6.33     2023-07-07 [1] CRAN (R 4.3.1)
 doParallel     1.0.17     2022-02-07 [1] CRAN (R 4.2.0)
 dplyr        * 1.1.2      2023-04-20 [1] CRAN (R 4.2.3)
 ellipsis       0.3.2      2021-04-29 [1] CRAN (R 4.2.0)
 fansi          1.0.4      2023-01-22 [1] CRAN (R 4.2.2)
 fastmap        1.1.1      2023-02-24 [1] CRAN (R 4.2.3)
 foreach        1.5.2      2022-02-02 [1] CRAN (R 4.2.0)
 fs             1.6.3      2023-07-20 [1] CRAN (R 4.3.1)
 furrr          0.3.1      2022-08-15 [1] CRAN (R 4.2.2)
 future         1.33.0     2023-07-01 [1] CRAN (R 4.3.1)
 future.apply   1.11.0     2023-05-21 [1] CRAN (R 4.3.0)
 generics       0.1.3      2022-07-05 [1] CRAN (R 4.2.2)
 ggplot2      * 3.4.3      2023-08-14 [1] CRAN (R 4.3.1)
 globals        0.16.2     2022-11-21 [1] CRAN (R 4.2.2)
 glue           1.6.2      2022-02-24 [1] CRAN (R 4.2.0)
 gower          1.0.1      2022-12-22 [1] CRAN (R 4.2.2)
 GPfit          1.0-8      2019-02-08 [1] CRAN (R 4.2.0)
 gtable         0.3.4      2023-08-21 [1] CRAN (R 4.3.1)
 hardhat        1.3.0      2023-03-30 [1] CRAN (R 4.2.3)
 htmltools      0.5.6      2023-08-10 [1] CRAN (R 4.3.1)
 htmlwidgets    1.6.2      2023-03-17 [1] CRAN (R 4.2.3)
 httpuv         1.6.11     2023-05-11 [1] CRAN (R 4.3.0)
 infer        * 1.0.4      2022-12-02 [1] CRAN (R 4.2.2)
 ipred          0.9-14     2023-03-09 [1] CRAN (R 4.2.3)
 iterators      1.0.14     2022-02-05 [1] CRAN (R 4.2.0)
 jsonlite       1.8.7      2023-06-29 [1] CRAN (R 4.3.1)
 later          1.3.1      2023-05-02 [1] CRAN (R 4.3.0)
 lattice        0.21-8     2023-04-05 [2] CRAN (R 4.3.1)
 lava           1.7.2.1    2023-02-27 [1] CRAN (R 4.2.3)
 lhs            1.1.6      2022-12-17 [1] CRAN (R 4.2.2)
 lifecycle      1.0.3      2022-10-07 [1] CRAN (R 4.2.2)
 listenv        0.9.0      2022-12-16 [1] CRAN (R 4.2.2)
 lubridate      1.9.2      2023-02-10 [1] CRAN (R 4.2.2)
 magrittr       2.0.3      2022-03-30 [1] CRAN (R 4.2.0)
 MASS           7.3-60     2023-05-04 [2] CRAN (R 4.3.1)
 Matrix         1.6-1      2023-08-14 [1] CRAN (R 4.3.1)
 memoise        2.0.1      2021-11-26 [1] CRAN (R 4.2.0)
 mime           0.12       2021-09-28 [1] CRAN (R 4.2.0)
 miniUI         0.1.1.1    2018-05-18 [1] CRAN (R 4.2.0)
 modeldata    * 1.2.0      2023-08-09 [1] CRAN (R 4.3.1)
 munsell        0.5.0      2018-06-12 [1] CRAN (R 4.2.0)
 nnet           7.3-19     2023-05-03 [2] CRAN (R 4.3.1)
 parallelly     1.36.0     2023-05-26 [1] CRAN (R 4.3.0)
 parsnip      * 1.1.1      2023-08-17 [1] CRAN (R 4.3.1)
 pillar         1.9.0      2023-03-22 [1] CRAN (R 4.2.3)
 pkgbuild       1.4.2      2023-06-26 [1] CRAN (R 4.3.1)
 pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 4.2.0)
 pkgload        1.3.2.1    2023-07-08 [1] CRAN (R 4.3.1)
 prettyunits    1.1.1      2020-01-24 [1] CRAN (R 4.2.0)
 processx       3.8.2      2023-06-30 [1] CRAN (R 4.3.1)
 prodlim        2023.08.28 2023-08-28 [1] CRAN (R 4.3.1)
 profvis        0.3.8      2023-05-02 [1] CRAN (R 4.3.0)
 promises       1.2.1      2023-08-10 [1] CRAN (R 4.3.1)
 ps             1.7.5      2023-04-18 [1] CRAN (R 4.2.3)
 purrr        * 1.0.2      2023-08-10 [1] CRAN (R 4.3.1)
 R6             2.5.1      2021-08-19 [1] CRAN (R 4.2.0)
 Rcpp           1.0.11     2023-07-06 [1] CRAN (R 4.3.1)
 recipes      * 1.0.8      2023-08-25 [1] CRAN (R 4.3.1)
 remotes        2.4.2.1    2023-07-18 [1] CRAN (R 4.3.0)
 rlang          1.1.1      2023-04-28 [1] CRAN (R 4.3.0)
 rpart          4.1.19     2022-10-21 [2] CRAN (R 4.3.1)
 rsample      * 1.2.0      2023-08-23 [1] CRAN (R 4.3.1)
 rstudioapi     0.15.0     2023-07-07 [1] CRAN (R 4.3.1)
 scales       * 1.2.1      2022-08-20 [1] CRAN (R 4.2.2)
 sessioninfo    1.2.2      2021-12-06 [1] CRAN (R 4.2.0)
 shiny          1.7.5      2023-08-12 [1] CRAN (R 4.3.1)
 stringi        1.7.12     2023-01-11 [1] CRAN (R 4.2.2)
 stringr        1.5.0      2022-12-02 [1] CRAN (R 4.2.2)
 survival       3.5-5      2023-03-12 [2] CRAN (R 4.3.1)
 tibble       * 3.2.1      2023-03-20 [1] CRAN (R 4.2.3)
 tidymodels   * 1.1.1      2023-08-24 [1] CRAN (R 4.3.1)
 tidyr        * 1.3.0      2023-01-24 [1] CRAN (R 4.2.2)
 tidyselect     1.2.0      2022-10-10 [1] CRAN (R 4.2.2)
 timechange     0.2.0      2023-01-11 [1] CRAN (R 4.2.2)
 timeDate       4022.108   2023-01-07 [1] CRAN (R 4.2.2)
 treesnip     * 0.1.0.9000 2022-05-04 [1] Github (curso-r/treesnip@58d4d47)
 tune         * 1.1.2      2023-08-23 [1] CRAN (R 4.3.1)
 urlchecker     1.0.1      2021-11-30 [1] CRAN (R 4.2.0)
 usethis      * 2.2.2      2023-07-06 [1] CRAN (R 4.3.1)
 utf8           1.2.3      2023-01-31 [1] CRAN (R 4.2.2)
 vctrs          0.6.3      2023-06-14 [1] CRAN (R 4.3.0)
 withr          2.5.0      2022-03-03 [1] CRAN (R 4.2.0)
 workflows    * 1.1.3      2023-02-22 [1] CRAN (R 4.2.3)
 workflowsets * 1.0.1      2023-04-06 [1] CRAN (R 4.2.3)
 xtable         1.8-4      2019-04-21 [1] CRAN (R 4.2.0)
 yardstick    * 1.2.0      2023-04-21 [1] CRAN (R 4.2.3)

 [1] C:/Users/vidar/AppData/Local/R/win-library/4.3
 [2] C:/Program Files/R/R-4.3.1/library

───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
@simonpcouch
Copy link
Contributor

Thanks for the issue!

This issue seems better fit for the treesnip package, where there are a number of similar issues: curso-r/treesnip#69, curso-r/treesnip#68. We've created a follow-up package to treesnip, bonsai, and we absolutely plan on introducing support for catboost if/when the package makes it to CRAN!

You may have better luck building your own custom model specification for this use case.

@simonpcouch simonpcouch closed this as not planned Won't fix, can't repro, duplicate, stale Sep 5, 2023
@github-actions
Copy link

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.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants