Aan de slagGa gratis aan de slag

Plot ROC curves

You saw again that the boosted tree yields the highest AUC. Numbers are fine, but pictures are better! Why not visualize these results?

You are going to illustrate model performance by plotting all ROC curves on one common plot. As the AUC is literally the area under these ROC curves, the boosted model should have the largest area under its ROC curve and be the one in the upper left corner of the plot.

The predictions tibble, preds_combined, is still loaded.

Deze oefening maakt deel uit van de cursus

Machine Learning with Tree-Based Models in R

Cursus bekijken

Oefeninstructies

  • Reshape the preds_combined tibble so that all columns that start with "preds_" are rows instead of columns. Convert the names to a "model" column and the values to a column called "predictions".
  • Group the results by model.
  • Calculate the ROC values for all cutoffs.
  • Produce a graphical plot of the curves.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Reshape the predictions into long format
predictions_long <- tidyr::pivot_longer(___,
                                        cols = starts_with("___"),
                                        names_to = "___",
                                        values_to = "___")

predictions_long %>% 
  # Group by model
  ___(___) %>% 
  # Calculate values for every cutoff
  ___(truth = ___, 
      estimate = ___) %>%
  # Create a plot from the calculated data
  ___()
Code bewerken en uitvoeren