##################################################
### Single model & single test dataset
###
## Load a dataset with 10 positives and 10 negatives
data(P10N10)
## Get every metric at every cutoff
tab <- metric_table(scores = P10N10$scores, labels = P10N10$labels)
head(tab)
## The cutoff that maximizes the F-score
tab[which.max(tab$fscore), c("rank", "score", "precision", "fscore")]
##################################################
### Add metrics beyond the default set
###
lifted <- metric_table(
scores = P10N10$scores, labels = P10N10$labels,
metrics = c("lift", "jaccard")
)
head(lifted[, c("rank", "score", "precision", "lift", "jaccard")])
##################################################
### Read the metrics of thresholds you already have
###
## 14 is a run of six tied scores, so the rank is the end of the run
metric_table(
scores = P10N10$scores, labels = P10N10$labels,
at = c(17, 14, 6)
)[, c("at", "rank", "score", "sensitivity", "precision")]
##################################################
### Reuse an object that is already calculated
###
points <- evalmod(
scores = P10N10$scores, labels = P10N10$labels,
mode = "basic"
)
head(metric_table(points))
Run the code above in your browser using DataLab