0

I am trying to use verbose = TRUE to see the progress of the tuning grid. It does not seem to work for me, do I have it in the wrong spot or am I using it incorrectly? At the bottom is a screenshot of what I want and below is reproducible code that does not have the desired output.

library(tidyverse)
library(tidymodels)
options(tidymodels.dark = TRUE)

parks <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-06-22/parks.csv')

modeling_df <- parks %>% 
  select(pct_near_park_data, spend_per_resident_data, med_park_size_data) %>% 
  rename(nearness = "pct_near_park_data",
         spending = "spend_per_resident_data",
         acres = "med_park_size_data") %>% 
  mutate(nearness = (parse_number(nearness)/100)) %>% 
  mutate(spending = parse_number(spending))

set.seed(123)
park_split <- initial_split(modeling_df)
park_train <- training(park_split)
park_test <- testing(park_split)

tree_rec <- recipe(nearness ~., data = park_train)
tree_prep <- prep(tree_rec)
juiced <- juice(tree_prep)

tune_spec <- rand_forest(
  mtry = tune(),
  trees = 1000,
  min_n = tune()
) %>% 
  set_mode("regression") %>% 
  set_engine("ranger")

tune_wf <- workflow() %>% 
  add_recipe(tree_rec) %>% 
  add_model(tune_spec)

set.seed(234)
park_folds <- vfold_cv(park_train)

set.seed(345)
tune_res <- tune_grid(
  tune_wf,
  resamples = park_folds,
  grid = 20,
 control = control_grid(verbose = TRUE)
)

# Results of running the code
> tune_res <- tune_grid(
+   tune_wf,
+   resamples = park_folds,
+   grid = 20,
+   control = control_grid(verbose = TRUE)
+ )
i Creating pre-processing data to finalize unknown parameter: mtry

Here is an example of what I want it to look like Example of what I want

Indescribled
  • 320
  • 1
  • 10
  • 1
    Apart from you specific problem, I found that you can use `options(tune.dark = TRUE)` to print the message in easier to see colors. https://github.com/tidymodels/tune/pull/109 – hnagaty Jun 28 '21 at 07:16

1 Answers1

4

Can you use reprex to make your examples to ensure that you are running this in a fresh session and there are no other packages loaded that may be interfering with your options?

This is what I get with your example code:

library(tidyverse)
library(tidymodels)
#> Registered S3 method overwritten by 'tune':
#>   method                   from   
#>   required_pkgs.model_spec parsnip
options(tidymodels.dark = TRUE)

parks <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-06-22/parks.csv')
#> 
#> ── Column specification ────────────────────────────────────────────────────────
#> cols(
#>   .default = col_double(),
#>   city = col_character(),
#>   park_pct_city_data = col_character(),
#>   pct_near_park_data = col_character(),
#>   spend_per_resident_data = col_character(),
#>   city_dup = col_character()
#> )
#> ℹ Use `spec()` for the full column specifications.

modeling_df <- parks %>% 
   select(pct_near_park_data, spend_per_resident_data, med_park_size_data) %>% 
   rename(nearness = "pct_near_park_data",
          spending = "spend_per_resident_data",
          acres = "med_park_size_data") %>% 
   mutate(nearness = (parse_number(nearness)/100)) %>% 
   mutate(spending = parse_number(spending))

set.seed(123)
park_split <- initial_split(modeling_df)
park_train <- training(park_split)
park_test <- testing(park_split)

tree_rec <- recipe(nearness ~., data = park_train)
tree_prep <- prep(tree_rec)
juiced <- juice(tree_prep)

tune_spec <- rand_forest(
   mtry = tune(),
   trees = 1000,
   min_n = tune()
) %>% 
   set_mode("regression") %>% 
   set_engine("ranger")

tune_wf <- workflow() %>% 
   add_recipe(tree_rec) %>% 
   add_model(tune_spec)

set.seed(234)
park_folds <- vfold_cv(park_train, v = 5)

set.seed(345)
tune_res <- tune_grid(
   tune_wf,
   resamples = park_folds,
   grid = 20,
   control = control_grid(verbose = TRUE)
)
#> i Creating pre-processing data to finalize unknown parameter: mtry
#> i Fold1: preprocessor 1/1
#> ✓ Fold1: preprocessor 1/1
#> i Fold1: preprocessor 1/1, model 1/20
#> ✓ Fold1: preprocessor 1/1, model 1/20
#> i Fold1: preprocessor 1/1, model 1/20 (predictions)
#> i Fold1: preprocessor 1/1, model 2/20
#> ✓ Fold1: preprocessor 1/1, model 2/20
#> i Fold1: preprocessor 1/1, model 2/20 (predictions)
#> i Fold1: preprocessor 1/1, model 3/20
#> ✓ Fold1: preprocessor 1/1, model 3/20
#> i Fold1: preprocessor 1/1, model 3/20 (predictions)
#> i Fold1: preprocessor 1/1, model 4/20
#> ✓ Fold1: preprocessor 1/1, model 4/20
#> i Fold1: preprocessor 1/1, model 4/20 (predictions)
#> i Fold1: preprocessor 1/1, model 5/20
#> ✓ Fold1: preprocessor 1/1, model 5/20
#> i Fold1: preprocessor 1/1, model 5/20 (predictions)
#> i Fold1: preprocessor 1/1, model 6/20
#> ✓ Fold1: preprocessor 1/1, model 6/20
#> i Fold1: preprocessor 1/1, model 6/20 (predictions)
#> i Fold1: preprocessor 1/1, model 7/20
#> ✓ Fold1: preprocessor 1/1, model 7/20
#> i Fold1: preprocessor 1/1, model 7/20 (predictions)
#> i Fold1: preprocessor 1/1, model 8/20
#> ✓ Fold1: preprocessor 1/1, model 8/20
#> i Fold1: preprocessor 1/1, model 8/20 (predictions)
#> i Fold1: preprocessor 1/1, model 9/20
#> ✓ Fold1: preprocessor 1/1, model 9/20
#> i Fold1: preprocessor 1/1, model 9/20 (predictions)
#> i Fold1: preprocessor 1/1, model 10/20
#> ✓ Fold1: preprocessor 1/1, model 10/20
#> i Fold1: preprocessor 1/1, model 10/20 (predictions)
#> i Fold1: preprocessor 1/1, model 11/20
#> ✓ Fold1: preprocessor 1/1, model 11/20
#> i Fold1: preprocessor 1/1, model 11/20 (predictions)
#> i Fold1: preprocessor 1/1, model 12/20
#> ✓ Fold1: preprocessor 1/1, model 12/20
#> i Fold1: preprocessor 1/1, model 12/20 (predictions)
#> i Fold1: preprocessor 1/1, model 13/20
#> ✓ Fold1: preprocessor 1/1, model 13/20
#> i Fold1: preprocessor 1/1, model 13/20 (predictions)
#> i Fold1: preprocessor 1/1, model 14/20
#> ✓ Fold1: preprocessor 1/1, model 14/20
#> i Fold1: preprocessor 1/1, model 14/20 (predictions)
#> i Fold1: preprocessor 1/1, model 15/20
#> ✓ Fold1: preprocessor 1/1, model 15/20
#> i Fold1: preprocessor 1/1, model 15/20 (predictions)
#> i Fold1: preprocessor 1/1, model 16/20
#> ✓ Fold1: preprocessor 1/1, model 16/20
#> i Fold1: preprocessor 1/1, model 16/20 (predictions)
#> i Fold1: preprocessor 1/1, model 17/20
#> ✓ Fold1: preprocessor 1/1, model 17/20
#> i Fold1: preprocessor 1/1, model 17/20 (predictions)
#> i Fold1: preprocessor 1/1, model 18/20
#> ✓ Fold1: preprocessor 1/1, model 18/20
#> i Fold1: preprocessor 1/1, model 18/20 (predictions)
#> i Fold1: preprocessor 1/1, model 19/20
#> ✓ Fold1: preprocessor 1/1, model 19/20
#> i Fold1: preprocessor 1/1, model 19/20 (predictions)
#> i Fold1: preprocessor 1/1, model 20/20
#> ✓ Fold1: preprocessor 1/1, model 20/20
#> i Fold1: preprocessor 1/1, model 20/20 (predictions)
#> i Fold2: preprocessor 1/1
#> ✓ Fold2: preprocessor 1/1
#> i Fold2: preprocessor 1/1, model 1/20
#> ✓ Fold2: preprocessor 1/1, model 1/20
#> i Fold2: preprocessor 1/1, model 1/20 (predictions)
#> i Fold2: preprocessor 1/1, model 2/20
#> ✓ Fold2: preprocessor 1/1, model 2/20
#> i Fold2: preprocessor 1/1, model 2/20 (predictions)
#> i Fold2: preprocessor 1/1, model 3/20
#> ✓ Fold2: preprocessor 1/1, model 3/20
#> i Fold2: preprocessor 1/1, model 3/20 (predictions)
#> i Fold2: preprocessor 1/1, model 4/20
#> ✓ Fold2: preprocessor 1/1, model 4/20
#> i Fold2: preprocessor 1/1, model 4/20 (predictions)
#> i Fold2: preprocessor 1/1, model 5/20
#> ✓ Fold2: preprocessor 1/1, model 5/20
#> i Fold2: preprocessor 1/1, model 5/20 (predictions)
#> i Fold2: preprocessor 1/1, model 6/20
#> ✓ Fold2: preprocessor 1/1, model 6/20
#> i Fold2: preprocessor 1/1, model 6/20 (predictions)
#> i Fold2: preprocessor 1/1, model 7/20
#> ✓ Fold2: preprocessor 1/1, model 7/20
#> i Fold2: preprocessor 1/1, model 7/20 (predictions)
#> i Fold2: preprocessor 1/1, model 8/20
#> ✓ Fold2: preprocessor 1/1, model 8/20
#> i Fold2: preprocessor 1/1, model 8/20 (predictions)
#> i Fold2: preprocessor 1/1, model 9/20
#> ✓ Fold2: preprocessor 1/1, model 9/20
#> i Fold2: preprocessor 1/1, model 9/20 (predictions)
#> i Fold2: preprocessor 1/1, model 10/20
#> ✓ Fold2: preprocessor 1/1, model 10/20
#> i Fold2: preprocessor 1/1, model 10/20 (predictions)
#> i Fold2: preprocessor 1/1, model 11/20
#> ✓ Fold2: preprocessor 1/1, model 11/20
#> i Fold2: preprocessor 1/1, model 11/20 (predictions)
#> i Fold2: preprocessor 1/1, model 12/20
#> ✓ Fold2: preprocessor 1/1, model 12/20
#> i Fold2: preprocessor 1/1, model 12/20 (predictions)
#> i Fold2: preprocessor 1/1, model 13/20
#> ✓ Fold2: preprocessor 1/1, model 13/20
#> i Fold2: preprocessor 1/1, model 13/20 (predictions)
#> i Fold2: preprocessor 1/1, model 14/20
#> ✓ Fold2: preprocessor 1/1, model 14/20
#> i Fold2: preprocessor 1/1, model 14/20 (predictions)
#> i Fold2: preprocessor 1/1, model 15/20
#> ✓ Fold2: preprocessor 1/1, model 15/20
#> i Fold2: preprocessor 1/1, model 15/20 (predictions)
#> i Fold2: preprocessor 1/1, model 16/20
#> ✓ Fold2: preprocessor 1/1, model 16/20
#> i Fold2: preprocessor 1/1, model 16/20 (predictions)
#> i Fold2: preprocessor 1/1, model 17/20
#> ✓ Fold2: preprocessor 1/1, model 17/20
#> i Fold2: preprocessor 1/1, model 17/20 (predictions)
#> i Fold2: preprocessor 1/1, model 18/20
#> ✓ Fold2: preprocessor 1/1, model 18/20
#> i Fold2: preprocessor 1/1, model 18/20 (predictions)
#> i Fold2: preprocessor 1/1, model 19/20
#> ✓ Fold2: preprocessor 1/1, model 19/20
#> i Fold2: preprocessor 1/1, model 19/20 (predictions)
#> i Fold2: preprocessor 1/1, model 20/20
#> ✓ Fold2: preprocessor 1/1, model 20/20
#> i Fold2: preprocessor 1/1, model 20/20 (predictions)
#> i Fold3: preprocessor 1/1
#> ✓ Fold3: preprocessor 1/1
#> i Fold3: preprocessor 1/1, model 1/20
#> ✓ Fold3: preprocessor 1/1, model 1/20
#> i Fold3: preprocessor 1/1, model 1/20 (predictions)
#> i Fold3: preprocessor 1/1, model 2/20
#> ✓ Fold3: preprocessor 1/1, model 2/20
#> i Fold3: preprocessor 1/1, model 2/20 (predictions)
#> i Fold3: preprocessor 1/1, model 3/20
#> ✓ Fold3: preprocessor 1/1, model 3/20
#> i Fold3: preprocessor 1/1, model 3/20 (predictions)
#> i Fold3: preprocessor 1/1, model 4/20
#> ✓ Fold3: preprocessor 1/1, model 4/20
#> i Fold3: preprocessor 1/1, model 4/20 (predictions)
#> i Fold3: preprocessor 1/1, model 5/20
#> ✓ Fold3: preprocessor 1/1, model 5/20
#> i Fold3: preprocessor 1/1, model 5/20 (predictions)
#> i Fold3: preprocessor 1/1, model 6/20
#> ✓ Fold3: preprocessor 1/1, model 6/20
#> i Fold3: preprocessor 1/1, model 6/20 (predictions)
#> i Fold3: preprocessor 1/1, model 7/20
#> ✓ Fold3: preprocessor 1/1, model 7/20
#> i Fold3: preprocessor 1/1, model 7/20 (predictions)
#> i Fold3: preprocessor 1/1, model 8/20
#> ✓ Fold3: preprocessor 1/1, model 8/20
#> i Fold3: preprocessor 1/1, model 8/20 (predictions)
#> i Fold3: preprocessor 1/1, model 9/20
#> ✓ Fold3: preprocessor 1/1, model 9/20
#> i Fold3: preprocessor 1/1, model 9/20 (predictions)
#> i Fold3: preprocessor 1/1, model 10/20
#> ✓ Fold3: preprocessor 1/1, model 10/20
#> i Fold3: preprocessor 1/1, model 10/20 (predictions)
#> i Fold3: preprocessor 1/1, model 11/20
#> ✓ Fold3: preprocessor 1/1, model 11/20
#> i Fold3: preprocessor 1/1, model 11/20 (predictions)
#> i Fold3: preprocessor 1/1, model 12/20
#> ✓ Fold3: preprocessor 1/1, model 12/20
#> i Fold3: preprocessor 1/1, model 12/20 (predictions)
#> i Fold3: preprocessor 1/1, model 13/20
#> ✓ Fold3: preprocessor 1/1, model 13/20
#> i Fold3: preprocessor 1/1, model 13/20 (predictions)
#> i Fold3: preprocessor 1/1, model 14/20
#> ✓ Fold3: preprocessor 1/1, model 14/20
#> i Fold3: preprocessor 1/1, model 14/20 (predictions)
#> i Fold3: preprocessor 1/1, model 15/20
#> ✓ Fold3: preprocessor 1/1, model 15/20
#> i Fold3: preprocessor 1/1, model 15/20 (predictions)
#> i Fold3: preprocessor 1/1, model 16/20
#> ✓ Fold3: preprocessor 1/1, model 16/20
#> i Fold3: preprocessor 1/1, model 16/20 (predictions)
#> i Fold3: preprocessor 1/1, model 17/20
#> ✓ Fold3: preprocessor 1/1, model 17/20
#> i Fold3: preprocessor 1/1, model 17/20 (predictions)
#> i Fold3: preprocessor 1/1, model 18/20
#> ✓ Fold3: preprocessor 1/1, model 18/20
#> i Fold3: preprocessor 1/1, model 18/20 (predictions)
#> i Fold3: preprocessor 1/1, model 19/20
#> ✓ Fold3: preprocessor 1/1, model 19/20
#> i Fold3: preprocessor 1/1, model 19/20 (predictions)
#> i Fold3: preprocessor 1/1, model 20/20
#> ✓ Fold3: preprocessor 1/1, model 20/20
#> i Fold3: preprocessor 1/1, model 20/20 (predictions)
#> i Fold4: preprocessor 1/1
#> ✓ Fold4: preprocessor 1/1
#> i Fold4: preprocessor 1/1, model 1/20
#> ✓ Fold4: preprocessor 1/1, model 1/20
#> i Fold4: preprocessor 1/1, model 1/20 (predictions)
#> i Fold4: preprocessor 1/1, model 2/20
#> ✓ Fold4: preprocessor 1/1, model 2/20
#> i Fold4: preprocessor 1/1, model 2/20 (predictions)
#> i Fold4: preprocessor 1/1, model 3/20
#> ✓ Fold4: preprocessor 1/1, model 3/20
#> i Fold4: preprocessor 1/1, model 3/20 (predictions)
#> i Fold4: preprocessor 1/1, model 4/20
#> ✓ Fold4: preprocessor 1/1, model 4/20
#> i Fold4: preprocessor 1/1, model 4/20 (predictions)
#> i Fold4: preprocessor 1/1, model 5/20
#> ✓ Fold4: preprocessor 1/1, model 5/20
#> i Fold4: preprocessor 1/1, model 5/20 (predictions)
#> i Fold4: preprocessor 1/1, model 6/20
#> ✓ Fold4: preprocessor 1/1, model 6/20
#> i Fold4: preprocessor 1/1, model 6/20 (predictions)
#> i Fold4: preprocessor 1/1, model 7/20
#> ✓ Fold4: preprocessor 1/1, model 7/20
#> i Fold4: preprocessor 1/1, model 7/20 (predictions)
#> i Fold4: preprocessor 1/1, model 8/20
#> ✓ Fold4: preprocessor 1/1, model 8/20
#> i Fold4: preprocessor 1/1, model 8/20 (predictions)
#> i Fold4: preprocessor 1/1, model 9/20
#> ✓ Fold4: preprocessor 1/1, model 9/20
#> i Fold4: preprocessor 1/1, model 9/20 (predictions)
#> i Fold4: preprocessor 1/1, model 10/20
#> ✓ Fold4: preprocessor 1/1, model 10/20
#> i Fold4: preprocessor 1/1, model 10/20 (predictions)
#> i Fold4: preprocessor 1/1, model 11/20
#> ✓ Fold4: preprocessor 1/1, model 11/20
#> i Fold4: preprocessor 1/1, model 11/20 (predictions)
#> i Fold4: preprocessor 1/1, model 12/20
#> ✓ Fold4: preprocessor 1/1, model 12/20
#> i Fold4: preprocessor 1/1, model 12/20 (predictions)
#> i Fold4: preprocessor 1/1, model 13/20
#> ✓ Fold4: preprocessor 1/1, model 13/20
#> i Fold4: preprocessor 1/1, model 13/20 (predictions)
#> i Fold4: preprocessor 1/1, model 14/20
#> ✓ Fold4: preprocessor 1/1, model 14/20
#> i Fold4: preprocessor 1/1, model 14/20 (predictions)
#> i Fold4: preprocessor 1/1, model 15/20
#> ✓ Fold4: preprocessor 1/1, model 15/20
#> i Fold4: preprocessor 1/1, model 15/20 (predictions)
#> i Fold4: preprocessor 1/1, model 16/20
#> ✓ Fold4: preprocessor 1/1, model 16/20
#> i Fold4: preprocessor 1/1, model 16/20 (predictions)
#> i Fold4: preprocessor 1/1, model 17/20
#> ✓ Fold4: preprocessor 1/1, model 17/20
#> i Fold4: preprocessor 1/1, model 17/20 (predictions)
#> i Fold4: preprocessor 1/1, model 18/20
#> ✓ Fold4: preprocessor 1/1, model 18/20
#> i Fold4: preprocessor 1/1, model 18/20 (predictions)
#> i Fold4: preprocessor 1/1, model 19/20
#> ✓ Fold4: preprocessor 1/1, model 19/20
#> i Fold4: preprocessor 1/1, model 19/20 (predictions)
#> i Fold4: preprocessor 1/1, model 20/20
#> ✓ Fold4: preprocessor 1/1, model 20/20
#> i Fold4: preprocessor 1/1, model 20/20 (predictions)
#> i Fold5: preprocessor 1/1
#> ✓ Fold5: preprocessor 1/1
#> i Fold5: preprocessor 1/1, model 1/20
#> ✓ Fold5: preprocessor 1/1, model 1/20
#> i Fold5: preprocessor 1/1, model 1/20 (predictions)
#> i Fold5: preprocessor 1/1, model 2/20
#> ✓ Fold5: preprocessor 1/1, model 2/20
#> i Fold5: preprocessor 1/1, model 2/20 (predictions)
#> i Fold5: preprocessor 1/1, model 3/20
#> ✓ Fold5: preprocessor 1/1, model 3/20
#> i Fold5: preprocessor 1/1, model 3/20 (predictions)
#> i Fold5: preprocessor 1/1, model 4/20
#> ✓ Fold5: preprocessor 1/1, model 4/20
#> i Fold5: preprocessor 1/1, model 4/20 (predictions)
#> i Fold5: preprocessor 1/1, model 5/20
#> ✓ Fold5: preprocessor 1/1, model 5/20
#> i Fold5: preprocessor 1/1, model 5/20 (predictions)
#> i Fold5: preprocessor 1/1, model 6/20
#> ✓ Fold5: preprocessor 1/1, model 6/20
#> i Fold5: preprocessor 1/1, model 6/20 (predictions)
#> i Fold5: preprocessor 1/1, model 7/20
#> ✓ Fold5: preprocessor 1/1, model 7/20
#> i Fold5: preprocessor 1/1, model 7/20 (predictions)
#> i Fold5: preprocessor 1/1, model 8/20
#> ✓ Fold5: preprocessor 1/1, model 8/20
#> i Fold5: preprocessor 1/1, model 8/20 (predictions)
#> i Fold5: preprocessor 1/1, model 9/20
#> ✓ Fold5: preprocessor 1/1, model 9/20
#> i Fold5: preprocessor 1/1, model 9/20 (predictions)
#> i Fold5: preprocessor 1/1, model 10/20
#> ✓ Fold5: preprocessor 1/1, model 10/20
#> i Fold5: preprocessor 1/1, model 10/20 (predictions)
#> i Fold5: preprocessor 1/1, model 11/20
#> ✓ Fold5: preprocessor 1/1, model 11/20
#> i Fold5: preprocessor 1/1, model 11/20 (predictions)
#> i Fold5: preprocessor 1/1, model 12/20
#> ✓ Fold5: preprocessor 1/1, model 12/20
#> i Fold5: preprocessor 1/1, model 12/20 (predictions)
#> i Fold5: preprocessor 1/1, model 13/20
#> ✓ Fold5: preprocessor 1/1, model 13/20
#> i Fold5: preprocessor 1/1, model 13/20 (predictions)
#> i Fold5: preprocessor 1/1, model 14/20
#> ✓ Fold5: preprocessor 1/1, model 14/20
#> i Fold5: preprocessor 1/1, model 14/20 (predictions)
#> i Fold5: preprocessor 1/1, model 15/20
#> ✓ Fold5: preprocessor 1/1, model 15/20
#> i Fold5: preprocessor 1/1, model 15/20 (predictions)
#> i Fold5: preprocessor 1/1, model 16/20
#> ✓ Fold5: preprocessor 1/1, model 16/20
#> i Fold5: preprocessor 1/1, model 16/20 (predictions)
#> i Fold5: preprocessor 1/1, model 17/20
#> ✓ Fold5: preprocessor 1/1, model 17/20
#> i Fold5: preprocessor 1/1, model 17/20 (predictions)
#> i Fold5: preprocessor 1/1, model 18/20
#> ✓ Fold5: preprocessor 1/1, model 18/20
#> i Fold5: preprocessor 1/1, model 18/20 (predictions)
#> i Fold5: preprocessor 1/1, model 19/20
#> ✓ Fold5: preprocessor 1/1, model 19/20
#> i Fold5: preprocessor 1/1, model 19/20 (predictions)
#> i Fold5: preprocessor 1/1, model 20/20
#> ✓ Fold5: preprocessor 1/1, model 20/20
#> i Fold5: preprocessor 1/1, model 20/20 (predictions)

Created on 2021-06-27 by the reprex package (v2.0.0)

I do see the verbose output.

I suspect that you may have turned on parallel processing at some point, which turns off the ability to return verbose logging. It's not currently possible to collect logging from the workers with the parallel backends we support.

Julia Silge
  • 10,848
  • 2
  • 40
  • 48