prg_plot | R Documentation |
Produce a precision-recall Gain plot for a set of predicted probabilities for a binary classifier. Follows the paper by Flach and Kull: https://proceedings.neurips.cc/paper/2015/file/33e8075e9970de0cfea955afd4644bb2-Paper.pdf. Code adapted from: https://github.com/meeliskull/prg/tree/master/R_package
prg_plot(form, data, max_intervals = 1000)
form |
A formula where the left-hand side is the variable representing the observed outcome, 0 or 1, and the right-hand side represents the column names of the different model probabilities. |
data |
A data frame that contains at least two columns, one of which is the observed outcome and the others that are predicted probabilities. |
max_intervals |
The maximum number of thresholds to evaluate. Default = 1000. |
library(ranger)
library(palmerpenguins)
pp <- penguins[complete.cases(penguins),]
m1 <- ranger(species == 'Adelie' ~ island + bill_length_mm + flipper_length_mm + body_mass_g + sex,
data = pp, probability = TRUE)
p_obj <- predict(m1, data = pp)
results <- data.frame(preds_m1 = p_obj$predictions[,2],
obs = pp$species == 'Adelie')
prg_plot(obs ~ preds_m1, data = results)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.