df <- tibble(
obs = factor(c(1, 0, 0, 1, 0, 0, 1, 0, 0, 0)),
pred = factor(c(1, 0, 0, 0, 0, 1, 1, 0, 0, 0))
)
acc <- yardstick::accuracy(df, truth = obs, estimate = pred)
recall <- yardstick::sens(df, truth = obs, estimate = pred)
spec <- yardstick::spec(df, truth = obs, estimate = pred)
precision <- yardstick::ppv(df, truth = obs, estimate = pred)
npv <- yardstick::npv(df, truth = obs, estimate = pred)
f1_score <- yardstick::f_meas(df, truth = obs, estimate = pred)
data.frame(acc$.estimate, recall$.estimate, spec$.estimate, precision$.estimate, npv$.estimate, f1_score$.estimate) %>%
rename("Accuracy" = acc..estimate,
"Recall" = recall..estimate,
"Specificity" = spec..estimate,
"Precision" = precision..estimate,
"NPV" = npv..estimate,
"F1-Score" = f1_score..estimate) %>%
knitr::kable()