LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Machine Learning with Tree-Based Models in R

Kurs anzeigen

Anleitung zur Übung

  • 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.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# 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 bearbeiten und ausführen