# 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')
Run the code above in your browser using DataLab