Calculate model performance metrics
Arguments
- data
A data frame containing the columns specified in
truth
andestimate
.- truth
The column name containing the true values.
- estimate
The column name containing the predicted values.
- event_level
A character string indicating which level of the outcome is considered the "event".
- ...
Additional arguments passed to yardstick::metrics.
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 metrics
metrics(pred_data, truth = vs_factor, estimate = pred)
} # }