View source: R/accuracy_uncertainty.R
brierScore | R Documentation |
Compute a multinominal Brier score from predicted class probabilities and observed class label. Lower values are associated with a more accurate classifier.
brierScore(x, classLabels, actual = "actual")
x |
|
classLabels |
vector of predicted class labels (probabilities), corresponding to column names in |
actual |
name of column containing the observed class, should be character vector not factor |
a single Brier score, representative of data in x
D.E. Beaudette
Brier, Glenn W. 1950. "Verification of Forecasts Expressed in Terms of Probability." Monthly Weather Review 78 (1): 1-3. doi:10.1175/1520-0493(1950)078<0001:VOFEIT>2.0.CO;2.
# columns 'a', 'b', 'c' contain predicted probabilities
# column 'actual' contains observed class label
# a good classifier
d.good <- data.frame(
a = c(0.05, 0.05, 0.10),
b = c(0.90, 0.85, 0.75),
c = c(0.05, 0.10, 0.15),
actual = c('b', 'b', 'b'),
stringsAsFactors = FALSE
)
# a rather bad classifier
d.bad <- data.frame(
a = c(0.05, 0.05, 0.10),
b = c(0.90, 0.85, 0.75),
c = c(0.05, 0.10, 0.15),
actual = c('c', 'c', 'c'),
stringsAsFactors = FALSE
)
# class labels are factors
d.factors <- data.frame(
a = c(0.05, 0.05, 0.10),
b = c(0.90, 0.85, 0.75),
c = c(0.05, 0.10, 0.15),
actual = c('b', 'b', 'b'),
stringsAsFactors = TRUE
)
# relatively low value = accurate
brierScore(x = d.good, classLabels = c('a', 'b', 'c'), actual = 'actual')
# high values = not accuate
brierScore(x = d.bad, classLabels = c('a', 'b', 'c'), actual = 'actual')
# message related to conversion of factor -> character
brierScore(x = d.factors, classLabels = c('a', 'b', 'c'), actual = 'actual')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.