1

I would like to tell yardstick that the default level for my logistic model is the second level. I know I can specify individual statistics with event_level = "second" but I would prefer to set the event_level with a global option. When I try it does not seem to work.

library(tidymodels)
data("two_class_example")
sens(two_class_example, truth, predicted, event_level = "second")
#> # A tibble: 1 × 3
#>   .metric .estimator .estimate
#>   <chr>   <chr>          <dbl>
#> 1 sens    binary         0.793

options(yardstick.event_level = "second")
sens(two_class_example, truth, predicted)
#> # A tibble: 1 × 3
#>   .metric .estimator .estimate
#>   <chr>   <chr>          <dbl>
#> 1 sens    binary         0.880

Created on 2023-07-17 with reprex v2.0.2

Is this a bug or am I doing something wrong?

itsMeInMiami
  • 2,324
  • 1
  • 13
  • 34

1 Answers1

1

On 2020-07-13 we moved away from the global option. In the current version (1.2.0), setting this option will now produce an warning, but won’t have any effect.

topepo
  • 13,534
  • 3
  • 39
  • 52
  • Thanks for the information Max. I see no warning in the reprex above. I see in the code a depreciation warning if I use yardstick.event_first but not yardstick.event_level. Is there any way to specify the event level for all the modeling in a project? – itsMeInMiami Jul 18 '23 at 02:57
  • I had seen the reference to `yardstick.event_level = `option here: https://stackoverflow.com/questions/68561374/logistic-regression-with-tidymodels-how-to-set-event-level-second-in-last-fi. Is that bogus? – itsMeInMiami Jul 18 '23 at 03:06
  • This seems like black magic but I think it works. my_yardstick_event_level <- function() { "second" } assignInNamespace( "yardstick_event_level", my_yardstick_event_level, ns = "yardstick" ) Max is there a better way to do this? – itsMeInMiami Jul 18 '23 at 03:32