Create a confusion matrix
Examples
if (FALSE) { # \dontrun{
library(dplyr)
data(mtcars)
# Create a binary outcome
mtcars <- mtcars %>%
mutate(vs_factor = factor(vs))
# Fit a model
model <- glm(vs ~ mpg + cyl, data = mtcars, family = "binomial")
# Make predictions
preds <- predict(model, type = "response")
# Create prediction data frame
pred_data <- mtcars %>%
mutate(pred = factor(ifelse(preds > 0.5, 1, 0)))
# Calculate confusion matrix
conf_mat(pred_data, truth = vs_factor, estimate = pred)
} # }