summary.conf_mat | R Documentation |
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.
## S3 method for class 'conf_mat'
summary(
object,
prevalence = NULL,
beta = 1,
estimator = NULL,
event_level = yardstick_event_level(),
...
)
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. |
A tibble containing various classification metrics.
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.
conf_mat()
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)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.