tidymodels / parsnip

A tidy unified interface to models
https://parsnip.tidymodels.org
Other
584 stars 88 forks source link

Ranger engine not outputting verbose messages #1004

Closed jxu closed 10 months ago

jxu commented 10 months ago

You need a large dataset for this (not sure which built-in datasets are large enough). The ranger fit should produce progress messages like

Growing trees.. Progress: 16%. Estimated remaining time: 2 minutes, 45 seconds.
Growing trees.. Progress: 42%. Estimated remaining time: 1 minute, 25 seconds.

However, parsnip fit doesn't show progress, even with verbosity=2 setting.

rf_mod <- rand_forest(mode="classification") %>%
  set_engine("ranger") 
rf_fit <- rf_mod %>% 
  fit(price ~ ., data=train,
      control=control_parsnip(verbosity=2, catch=F))
jxu commented 10 months ago

I got verbose output to show up with set_engine("ranger", verbose=T, num.threads=32). Also parsnip seems to default to 1 thread even though ranger defaults to number of CPUs. Does it change the defaults?

EmilHvitfeldt commented 10 months ago

With regards to the progress bar. That is happening because the verbose argument has been defaulted to be FALSE:

https://github.com/tidymodels/parsnip/blob/907d2164a093f10cbbc1921e4b73264ca4053f6b/R/rand_forest_data.R#L119-L135

You can overwrite it by setting verbose = TRUE in set_engine() as you have seen.

rf_mod <- rand_forest(mode = "classification") %>%
  set_engine("ranger", verbose = TRUE) 

With regards to the choice of num.threads = 1. We strongly believe that code should run single threaded by default, with an easy way to opt into multi threaded calculations. This stops a number of problems from happening:

jxu commented 10 months ago

Ok, thanks for the info.

jxu commented 10 months ago

I think verbose default should be set to true. Tidyverse functions (ex. read_csv) print a lot of progress output anyway.

github-actions[bot] commented 10 months 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.