# Example 1: known truth and prediction status
df <-
data.frame(
truth = c(1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0)
, pred = c(1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0)
)
confusion_matrix(df$truth, df$pred, thresholds = 1)
# Example 2: Use with a logistic regression model
mod <- glm(
formula = spam ~ word_freq_our + word_freq_over + capital_run_length_total
, data = spambase
, family = binomial()
)
confusion_matrix(mod)
confusion_matrix(mod, thresholds = 0.5)
Run the code above in your browser using DataLab