Tidymodels Error Message: Error: In metric: `roc_auc`

I've been trying to learn the Tidymodels package for the first time and immediately ran into a problem with logistic regression. I keep getting the error message: "Error: In metric: roc_auc" and I can't seem to find an answer for why this isn't working anywhere online. Is there maybe an issue with the data?

#I uploaded the data to github
df_model = read.csv('https://raw.githubusercontent.com/jslucf/spotify/main/spotifydata.csv')

df_split = initial_split(df_model, strata = decade)
df_training = training(df_split)
df_testing = testing(df_split)
df_bootstraps = bootstraps(df_training)

df_workflow = workflow() %>%
add_formula(playlist_genre ~ . )

glm_model = logistic_reg() %>%

glm_bootstraps = df_workflow %>%
add_model(glm_model) %>%
fit_resamples(resamples = df_bootstraps,
control = control_resamples(save_pred = T))

Is it because there are a number of factors in playlist_genre, but you are trying to use logistic regression, which is for binary classification?

Yes, you are right and I just figured out why. So I was following along with a tutorial in one of Julia Silge's Youtube walkthroughs (on a different dataset). I thought she was predicting a three-level factor in her logistic regression model in the video, which led me to believe the engine would just automatically detect multi-level classification. However, your post caused me to go through her video again and this time I realized she actually had a different target variable entirely (which was in fact two-levels).

Drove myself crazy for no reason, but I am happy to know the solution was something so obvious. Thank you for pointing me in the right direction! Happy holiday!

1 Like

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.