Skip to content

Feature request: collect_notes #363

@EmilHvitfeldt

Description

@EmilHvitfeldt

What it says in the title. A function to collect all the errors in a fast and easy way.

basic prototype

collect_notes <- function(x) {
  x$.notes %>%
  bind_rows()
}
library(tidymodels)
set.seed(6735)
mtcars1 <- mtcars
mtcars1$disp <- "no value"

folds <- vfold_cv(mtcars1, v = 5)

spline_rec <- recipe(mpg ~ ., data = mtcars1) %>%
  step_ns(disp) %>%
  step_ns(wt)

lin_mod <- linear_reg() %>%
  set_engine("lm")

control <- control_resamples(save_pred = TRUE)

spline_res <- fit_resamples(lin_mod, spline_rec, folds, control = control)
#> x Fold1: preprocessor 1/1: Error: All columns selected for the step should be num...
#> x Fold2: preprocessor 1/1: Error: All columns selected for the step should be num...
#> x Fold3: preprocessor 1/1: Error: All columns selected for the step should be num...
#> x Fold4: preprocessor 1/1: Error: All columns selected for the step should be num...
#> x Fold5: preprocessor 1/1: Error: All columns selected for the step should be num...
#> Warning: All models failed. See the `.notes` column.

collect_notes <- function(x) {
  x$.notes %>%
  bind_rows()
}

spline_res %>%
  collect_notes()
#> # A tibble: 5 x 1
#>   .notes                                                                      
#>   <chr>                                                                       
#> 1 preprocessor 1/1: Error: All columns selected for the step should be numeric
#> 2 preprocessor 1/1: Error: All columns selected for the step should be numeric
#> 3 preprocessor 1/1: Error: All columns selected for the step should be numeric
#> 4 preprocessor 1/1: Error: All columns selected for the step should be numeric
#> 5 preprocessor 1/1: Error: All columns selected for the step should be numeric

Created on 2021-03-28 by the reprex package (v0.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions