Skip to contents

Calculate model performance metrics

Usage

metrics(data, truth, estimate, event_level = NULL, ...)

Arguments

data

A data frame containing the columns specified in truth and estimate.

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.

Value

A tibble with model performance 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)
} # }