juliasilge / supervised-ML-case-studies-course

Supervised machine learning case studies in R! 💫 A free interactive tidymodels course
https://supervised-ml-course.netlify.app/
MIT License
221 stars 76 forks source link

Error in Chapter model when running locally #66

Closed hassannasir closed 3 years ago

hassannasir commented 3 years ago

I am trying to run the following code from Chapter 3 on my machine.

set.seed(234)

rf_res <- vote_wf %>%
    fit_resamples(
        vote_folds,
        metrics = metric_set(roc_auc, sens, spec),
        control = control_resamples(save_pred = TRUE)
    )

And receiving the following errors related to metrics arguments:

Error: 
The combination of metric functions must be:
- only numeric metrics
- a mix of class metrics and class probability metrics

The following metric function types are being mixed:
- prob (roc_auc)
- class (sens)
- other (spec <namespace:read>)

The same happens when I am running the glm model.

If I remove the metrics argument, everything works fine. But then I have to find alternative ways to computing roc_auc, sens and spec (e.g. as shown by @juliasilge elsewhere).

juliasilge commented 3 years ago

The problem here is that readr::spec() is overriding the yardstick sensitivity metric. I will need to go in and edit this in the course itself, but for now to make things run locally for you, try this:

set.seed(234)

rf_res <- vote_wf %>%
  fit_resamples(
    vote_folds,
    metrics = metric_set(roc_auc, sensitivity, specificity),
    control = control_resamples(save_pred = TRUE)
  )