calib_plot | R Documentation |
Produce a calibration plot for a set of predicted probabilities for a binary classifier.
calib_plot(
form,
data,
cuts = 10,
refline = TRUE,
smooth = FALSE,
fitline = FALSE,
rug = FALSE
)
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. |
cuts |
The number of bins of probabilities. Default = 10. |
refline |
Whether or not to include a 45 degree reference line. Default = TRUE. |
smooth |
Whether or not to include a smoothed loess curve for each models' probabilities. Default = FALSE. |
fitline |
Whether or not to include a best-fit line for each models' probabilities. Default = FALSE. |
rug |
Whether or not to include a rug plot of the observed probabilities. Usually works best with only one model. Default = FALSE. |
m1 <- glm(mpg > 20 ~ cyl + disp + hp, family = 'binomial', data = mtcars)
results <- data.frame(outcome = mtcars$mpg > 20, lr_1 = predict(m1, type = 'response'))
calib_plot(outcome ~ lr_1, data = results, cuts = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.