##################################################
### Single model & single test dataset
###
## Predicted probabilities of 10 positives and 10 negatives
set.seed(1)
scores <- c(runif(10, 0.4, 1), runif(10, 0, 0.6))
labels <- c(rep(1, 10), rep(0, 10))
## Brier score and log loss
prob_metrics(scores = scores, labels = labels)
##################################################
### Multiple models & multiple test datasets
###
## The "poor_er" and "good_er" samples are drawn from beta distributions,
## so their scores can be read as probabilities
samps <- create_sim_samples(4, 100, 100, c("poor_er", "good_er"))
mdat <- mmdata(samps[["scores"]], samps[["labels"]],
modnames = samps[["modnames"]],
dsids = samps[["dsids"]]
)
pm <- prob_metrics(mdat)
## Show the Brier scores only
subset(pm, metrics == "brier")
## The D2 scores, which say how much of each loss the model explains
subset(
prob_metrics(mdat, metrics = c("d2_brier", "d2_logloss")),
dsids == 1
)
Run the code above in your browser using DataLab