View source: R/prob-brier_class.R
brier_class | R Documentation |
Compute the Brier score for a classification model.
brier_class(data, ...)
## S3 method for class 'data.frame'
brier_class(data, truth, ..., na_rm = TRUE, case_weights = NULL)
brier_class_vec(truth, estimate, na_rm = TRUE, case_weights = NULL, ...)
data |
A |
... |
A set of unquoted column names or one or more
|
truth |
The column identifier for the true class results
(that is a |
na_rm |
A |
case_weights |
The optional column identifier for case weights.
This should be an unquoted column name that evaluates to a numeric column
in |
estimate |
If |
The Brier score is analogous to the mean squared error in regression models. The difference between a binary indicator for a class and its corresponding class probability are squared and averaged.
This function uses the convention in Kruppa et al (2014) and divides the result by two.
Smaller values of the score are associated with better model performance.
A tibble
with columns .metric
, .estimator
,
and .estimate
and 1 row of values.
For grouped data frames, the number of rows returned will be the same as the number of groups.
For brier_class_vec()
, a single numeric
value (or NA
).
Brier scores can be computed in the same way for any number of classes. Because of this, no averaging types are supported.
Max Kuhn
Kruppa, J., Liu, Y., Diener, H.-C., Holste, T., Weimar, C., Koonig, I. R., and Ziegler, A. (2014) Probability estimation with machine learning methods for dichotomous and multicategory outcome: Applications. Biometrical Journal, 56 (4): 564-583.
Other class probability metrics:
average_precision()
,
classification_cost()
,
gain_capture()
,
mn_log_loss()
,
pr_auc()
,
roc_auc()
,
roc_aunp()
,
roc_aunu()
# Two class
data("two_class_example")
brier_class(two_class_example, truth, Class1)
# Multiclass
library(dplyr)
data(hpc_cv)
# You can use the col1:colN tidyselect syntax
hpc_cv %>%
filter(Resample == "Fold01") %>%
brier_class(obs, VF:L)
# Groups are respected
hpc_cv %>%
group_by(Resample) %>%
brier_class(obs, VF:L)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.