Tidymodels: Which factor level is the default positive class?

I'm following along in Julia Silge's amazing tidymodel blogs. It occurred to me that I don't know which outcome level for a classification problem is the positive class (class of interest). Suppose I have an outcome variable with factor levels: "No Repair" and "Repair". When I run the code below is the sensitivity calculated with "No Repair" as the positive class since it's the first factor level?

                      metrics = metric_set(sensitivity,specificity,roc_auc))

Suppose I run the code below. Does it relevel the factor so that "Repair" is the positive class? Thanks.

repair_recipe <- recipe(Repair ~ ., data = repair_train) %>%
  step_relevel(Repair,ref_level = "Repair")
1 Like

It should treat the first level as the event. There is an option to do the opposite too. When you load yardstick, you should see:

> library(yardstick)
For binary classification, the first factor level is assumed to be the event.
Use the argument `event_level = "second"` to alter this as needed.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.