MulaiMulai sekarang secara gratis

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.

Latihan ini adalah bagian dari kursus

Machine Learning with Tree-Based Models in R

Lihat Kursus

Petunjuk latihan

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

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# 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
  ___()
Edit dan Jalankan Kode