summary.conf_mat {yardstick} | R Documentation |
Summary Statistics for Confusion Matrices
Description
Various statistical summaries of confusion matrices are
produced and returned in a tibble. These include those shown in the help
pages for sens()
, recall()
, and accuracy()
, among others.
Usage
## S3 method for class 'conf_mat'
summary(
object,
prevalence = NULL,
beta = 1,
estimator = NULL,
event_level = yardstick_event_level(),
...
)
Arguments
object |
An object of class |
prevalence |
A number in |
beta |
A numeric value used to weight precision and
recall for |
estimator |
One of: |
event_level |
A single string. Either |
... |
Not currently used. |
Value
A tibble containing various classification metrics.
Relevant Level
There is no common convention on which factor level should
automatically be considered the "event" or "positive" result
when computing binary classification metrics. In yardstick
, the default
is to use the first level. To alter this, change the argument
event_level
to "second"
to consider the last level of the factor the
level of interest. For multiclass extensions involving one-vs-all
comparisons (such as macro averaging), this option is ignored and
the "one" level is always the relevant result.
See Also
Examples
data("two_class_example")
cmat <- conf_mat(two_class_example, truth = "truth", estimate = "predicted")
summary(cmat)
summary(cmat, prevalence = 0.70)
library(dplyr)
library(tidyr)
data("hpc_cv")
# Compute statistics per resample then summarize
all_metrics <- hpc_cv %>%
group_by(Resample) %>%
conf_mat(obs, pred) %>%
mutate(summary_tbl = lapply(conf_mat, summary)) %>%
unnest(summary_tbl)
all_metrics %>%
group_by(.metric) %>%
summarise(
mean = mean(.estimate, na.rm = TRUE),
sd = sd(.estimate, na.rm = TRUE)
)